tumblr: rewrite html pages to image url.

This commit is contained in:
evazion
2017-06-25 01:03:23 -05:00
parent 118843b26a
commit 030052bf14
2 changed files with 19 additions and 0 deletions

View File

@@ -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

View File

@@ -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