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

View File

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