tumblr: rewrite html pages to image url.
This commit is contained in:
@@ -10,6 +10,7 @@ module Downloads
|
||||
def rewrite(url, headers, data = {})
|
||||
url = rewrite_cdn(url)
|
||||
url = rewrite_samples(url, headers)
|
||||
url = rewrite_html_pages(url)
|
||||
|
||||
return [url, headers, data]
|
||||
end
|
||||
@@ -56,6 +57,14 @@ module Downloads
|
||||
url.sub!(%r!\Ahttps?://gs1\.wac\.edgecastcdn\.net/8019B6/data\.tumblr\.com!i, "http://data.tumblr.com")
|
||||
url
|
||||
end
|
||||
|
||||
def rewrite_html_pages(url)
|
||||
if Sources::Strategies::Tumblr.url_match?(url)
|
||||
url = Sources::Strategies::Tumblr.new(url).image_url
|
||||
end
|
||||
|
||||
url
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -74,5 +74,15 @@ module Downloads
|
||||
assert_rewritten(@rewrite, @source)
|
||||
end
|
||||
end
|
||||
|
||||
context "a download for a *.tumblr.com/post/* html page" do
|
||||
should "download the best available version" do
|
||||
@source = "https://noizave.tumblr.com/post/162206271767"
|
||||
@rewrite = "http://data.tumblr.com/3bbfcbf075ddf969c996641b264086fd/tumblr_os2buiIOt51wsfqepo1_raw.png"
|
||||
|
||||
assert_downloaded(3_620, @source)
|
||||
assert_rewritten(@rewrite, @source)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user