#1866: Support Tumblr 500h size

This commit is contained in:
Toks
2013-11-29 16:12:19 -05:00
parent 87209b014b
commit 2ce8520e72
2 changed files with 83 additions and 5 deletions

View File

@@ -11,12 +11,22 @@ module Downloads
protected
def rewrite_thumbnails(url, headers)
if url =~ %r{^http?://.+\.tumblr\.com/(?:\w+/)?(?:tumblr_)?(\w+_)(250|400|500)\..+$}
if url =~ %r{^http?://.+\.tumblr\.com/(?:\w+/)?(?:tumblr_)?(\w+_)(250|400|500|1280)\..+$}
match = $1
size = $2
big_url = url.sub(match + size, match + "1280")
if http_exists?(big_url, headers)
url = big_url
given_size = $2
big_500h_url = url.sub(match + given_size, match + "500h")
if http_exists?(big_500h_url, headers)
return [big_500h_url, headers]
end
if given_size == "1280"
return [url, headers]
end
big_1280_url = url.sub(match + given_size, match + "1280")
if http_exists?(big_1280_url, headers)
return [big_1280_url, headers]
end
end