Fix deviantart regex bugs

This commit is contained in:
Toks
2014-04-28 15:45:11 -04:00
parent cc3c6d989f
commit 0cba44e3bf
2 changed files with 6 additions and 6 deletions

View File

@@ -2,7 +2,7 @@ module Downloads
module Strategies module Strategies
class DeviantArt < Base class DeviantArt < Base
def rewrite(url, headers) def rewrite(url, headers)
if url =~ /https?:\/\/(?:\w+\.)?deviantart\.(?:com|net)/ if url =~ /https?:\/\/(?:.+?\.)?deviantart\.(?:com|net)/
url, headers = rewrite_html_pages(url, headers) url, headers = rewrite_html_pages(url, headers)
url, headers = rewrite_thumbnails(url, headers) url, headers = rewrite_thumbnails(url, headers)
end end
@@ -12,7 +12,7 @@ module Downloads
protected protected
def rewrite_html_pages(url, headers) def rewrite_html_pages(url, headers)
if url =~ %r{^http://\w+\.deviantart\.com/art/\w+} if url =~ %r{^http://.+?\.deviantart\.com/art/}
source = ::Sources::Strategies::DeviantArt.new(url) source = ::Sources::Strategies::DeviantArt.new(url)
source.get source.get
return [source.image_url, headers] return [source.image_url, headers]
@@ -22,10 +22,10 @@ module Downloads
end end
def rewrite_thumbnails(url, headers) def rewrite_thumbnails(url, headers)
if url =~ %r{^(http://\w+.deviantart.net/\w+/)200H/} if url =~ %r{^(http://.+?\.deviantart\.net/.+?/)200H/}
match = $1 match = $1
url.sub!(match + "200H/", match) url.sub!(match + "200H/", match)
elsif url =~ %r{^(http://\w+.deviantart.net/\w+/)PRE/} elsif url =~ %r{^(http://.+?\.deviantart\.net/.+?/)PRE/}
match = $1 match = $1
url.sub!(match + "PRE/", match) url.sub!(match + "PRE/", match)
end end

View File

@@ -2,7 +2,7 @@ module Sources
module Strategies module Strategies
class DeviantArt < Base class DeviantArt < Base
def self.url_match?(url) def self.url_match?(url)
url =~ /^https?:\/\/(?:\w+\.)?deviantart\.(?:com|net)/ url =~ /^https?:\/\/(?:.+?\.)?deviantart\.(?:com|net)/
end end
def site_name def site_name
@@ -10,7 +10,7 @@ module Sources
end end
def unique_id def unique_id
profile_url =~ /https?:\/\/(\w+)\.deviantart\.com/ profile_url =~ /https?:\/\/(.+?)\.deviantart\.com/
"deviantart" + $1 "deviantart" + $1
end end