sources: rename Sources::Strategies to Source::Extractor.
Rename Sources::Strategies to Source::Extractor. A Source::Extractor represents a thing that extracts information from a given URL.
This commit is contained in:
@@ -9,7 +9,7 @@ module Sources
|
||||
|
||||
context "A page url" do
|
||||
setup do
|
||||
@site = Sources::Strategies.find("https://www.deviantart.com/aeror404/art/Holiday-Elincia-424551484")
|
||||
@site = Source::Extractor.find("https://www.deviantart.com/aeror404/art/Holiday-Elincia-424551484")
|
||||
end
|
||||
|
||||
should "work" do
|
||||
@@ -26,7 +26,7 @@ module Sources
|
||||
|
||||
context "The source for a deleted DeviantArt image URL" do
|
||||
should "work" do
|
||||
@site = Sources::Strategies.find("https://pre00.deviantart.net/423b/th/pre/i/2017/281/e/0/mindflayer_girl01_by_nickbeja-dbpxdt8.png")
|
||||
@site = Source::Extractor.find("https://pre00.deviantart.net/423b/th/pre/i/2017/281/e/0/mindflayer_girl01_by_nickbeja-dbpxdt8.png")
|
||||
@artist = create(:artist, name: "nickbeja", url_string: "https://nickbeja.deviantart.com")
|
||||
|
||||
assert_equal(["https://pre00.deviantart.net/423b/th/pre/i/2017/281/e/0/mindflayer_girl01_by_nickbeja-dbpxdt8.png"], @site.image_urls)
|
||||
@@ -40,7 +40,7 @@ module Sources
|
||||
|
||||
context "The source for a download-disabled DeviantArt artwork page" do
|
||||
should "get the image url" do
|
||||
@site = Sources::Strategies.find("https://noizave.deviantart.com/art/test-no-download-697415967")
|
||||
@site = Source::Extractor.find("https://noizave.deviantart.com/art/test-no-download-697415967")
|
||||
|
||||
# https://img00.deviantart.net/56ee/i/2017/219/2/3/test__no_download_by_noizave-dbj81lr.jpg (md5: 25a03b5a6744b6b914a13b3cd50e3c2c, size: 37638)
|
||||
# orig file: https://danbooru.donmai.us/posts/463438 (md5: eb97244675e47dbd77ffcd2d7e15aeab, size: 59401)
|
||||
@@ -56,7 +56,7 @@ module Sources
|
||||
|
||||
context "The source for a download-enabled DeviantArt artwork page" do
|
||||
should "get the download image url" do
|
||||
@site = Sources::Strategies.find("https://www.deviantart.com/len1/art/All-that-Glitters-II-774592781")
|
||||
@site = Source::Extractor.find("https://www.deviantart.com/len1/art/All-that-Glitters-II-774592781")
|
||||
|
||||
# http://origin-orig.deviantart.net/a713/f/2018/333/3/6/all_that_glitters_ii_by_len1-dct67m5.jpg (md5: d16bb8620600334caa029ebb9bc426a6, size: 1402017)
|
||||
assert_match(%r{\Ahttps://wixmp-ed30a86b8c4ca887773594c2\.wixmp\.com/f/a6289ca5-2205-4118-af55-c6934fba0930/dct67m5-51e8db38-9167-4f5c-931d-561ea4d3810d\.jpg}, @site.image_urls.sole)
|
||||
@@ -71,7 +71,7 @@ module Sources
|
||||
|
||||
context "The source for a DeviantArt image url" do
|
||||
should "fetch the source data" do
|
||||
@site = Sources::Strategies.find("https://pre00.deviantart.net/b5e6/th/pre/f/2016/265/3/5/legend_of_galactic_heroes_by_hideyoshi-daihpha.jpg")
|
||||
@site = Source::Extractor.find("https://pre00.deviantart.net/b5e6/th/pre/f/2016/265/3/5/legend_of_galactic_heroes_by_hideyoshi-daihpha.jpg")
|
||||
|
||||
# http://origin-orig.deviantart.net/9e1f/f/2016/265/3/5/legend_of_galactic_heroes_by_hideyoshi-daihpha.jpg (md5: 4cfec3d50ebbb924077cc5c90e705d4e, size: 906621)
|
||||
assert_match(%r{\Ahttps://wixmp-ed30a86b8c4ca887773594c2\.wixmp\.com/f/b1f96af6-56a3-47a8-b7f4-406f243af3a3/daihpha-9f1fcd2e-7557-4db5-951b-9aedca9a3ae7\.jpg}, @site.image_urls.sole)
|
||||
@@ -86,7 +86,7 @@ module Sources
|
||||
|
||||
context "The source for a origin-orig.deviantart.net image url without a referer" do
|
||||
should "work" do
|
||||
@site = Sources::Strategies.find("http://origin-orig.deviantart.net/7b5b/f/2017/160/c/5/test_post_please_ignore_by_noizave-dbc3a48.png")
|
||||
@site = Source::Extractor.find("http://origin-orig.deviantart.net/7b5b/f/2017/160/c/5/test_post_please_ignore_by_noizave-dbc3a48.png")
|
||||
|
||||
# md5: 9dec050536dbdb09ab63cb9c5a48f8b7
|
||||
assert_match(%r{\Ahttps://wixmp-ed30a86b8c4ca887773594c2\.wixmp\.com/f/83d3eb4d-13e5-4aea-a08f-8d4331d033c4/dbc3a48-10b9e2e8-b176-4820-ab9e-23449c11e7c9\.png}, @site.image_urls.sole)
|
||||
@@ -103,7 +103,7 @@ module Sources
|
||||
|
||||
context "The source for a img00.deviantart.net sample image url" do
|
||||
should "return the full size image url" do
|
||||
@site = Sources::Strategies.find("https://img00.deviantart.net/a233/i/2017/160/5/1/test_post_please_ignore_by_noizave-dbc3a48.png")
|
||||
@site = Source::Extractor.find("https://img00.deviantart.net/a233/i/2017/160/5/1/test_post_please_ignore_by_noizave-dbc3a48.png")
|
||||
|
||||
assert_match(%r{\Ahttps://wixmp-ed30a86b8c4ca887773594c2\.wixmp\.com/f/83d3eb4d-13e5-4aea-a08f-8d4331d033c4/dbc3a48-10b9e2e8-b176-4820-ab9e-23449c11e7c9\.png}, @site.image_urls.sole)
|
||||
assert_downloaded(3619, @site.image_urls.sole)
|
||||
@@ -114,7 +114,7 @@ module Sources
|
||||
|
||||
context "The source for a th00.deviantart.net/*/PRE/* thumbnail url" do
|
||||
should "return the full size image url" do
|
||||
@site = Sources::Strategies.find("http://th00.deviantart.net/fs71/PRE/f/2014/065/3/b/goruto_by_xyelkiltrox-d797tit.png")
|
||||
@site = Source::Extractor.find("http://th00.deviantart.net/fs71/PRE/f/2014/065/3/b/goruto_by_xyelkiltrox-d797tit.png")
|
||||
|
||||
# http://origin-orig.deviantart.net/0f1e/f/2014/065/3/b/goruto_by_xyelkiltrox-d797tit.png (md5: d779f5a7da29ec90d777a8db38d07994, size: 3391584)
|
||||
assert_match(%r{\Ahttps://wixmp-ed30a86b8c4ca887773594c2\.wixmp\.com/f/d8995973-0b32-4a7d-8cd8-d847d083689a/d797tit-1eac22e0-38b6-4eae-adcb-1b72843fd62a\.png}, @site.image_urls.sole)
|
||||
@@ -126,7 +126,7 @@ module Sources
|
||||
|
||||
context "A source for a *.deviantart.net/*/:title_by_:artist.jpg url artist name containing underscores" do
|
||||
should "find the correct artist" do
|
||||
@site = Sources::Strategies.find("https://orig00.deviantart.net/4274/f/2010/230/8/a/pkmn_king_and_queen_by_mikoto_chan.jpg")
|
||||
@site = Source::Extractor.find("https://orig00.deviantart.net/4274/f/2010/230/8/a/pkmn_king_and_queen_by_mikoto_chan.jpg")
|
||||
@artist = create(:artist, name: "mikoto-chan", url_string: "https://www.deviantart.com/mikoto-chan")
|
||||
|
||||
assert_equal("mikoto-chan", @site.artist_name)
|
||||
@@ -144,7 +144,7 @@ module Sources
|
||||
|
||||
context "without a referer" do
|
||||
should "work" do
|
||||
@site = Sources::Strategies.find(@url)
|
||||
@site = Source::Extractor.find(@url)
|
||||
|
||||
assert_equal([@site.url], @site.image_urls)
|
||||
assert_equal("47ness", @site.artist_name)
|
||||
@@ -157,7 +157,7 @@ module Sources
|
||||
|
||||
context "with a referer" do
|
||||
should "work" do
|
||||
@site = Sources::Strategies.find(@url, @ref)
|
||||
@site = Source::Extractor.find(@url, @ref)
|
||||
|
||||
# http://origin-orig.deviantart.net/a418/f/2007/120/c/9/cool_like_me_by_47ness.jpg (md5: da78e7c192d42470acda7d87ade64849, size: 265496)
|
||||
assert_match(%r{\Ahttps://wixmp-ed30a86b8c4ca887773594c2\.wixmp\.com/f/ece2238f-5c8f-48e4-afda-304cab294acd/dwcohb-8189be91-691d-4212-b3a0-0b77e86a57d1\.jpg}, @site.image_urls.sole)
|
||||
@@ -181,7 +181,7 @@ module Sources
|
||||
|
||||
context "without a referer" do
|
||||
should "work" do
|
||||
@site = Sources::Strategies.find(@url)
|
||||
@site = Source::Extractor.find(@url)
|
||||
|
||||
assert_equal([@url], @site.image_urls)
|
||||
assert_nil(@site.artist_name)
|
||||
@@ -194,7 +194,7 @@ module Sources
|
||||
|
||||
context "with a referer" do
|
||||
should "work" do
|
||||
@site = Sources::Strategies.find(@url, @ref)
|
||||
@site = Source::Extractor.find(@url, @ref)
|
||||
|
||||
assert_match(%r!\Ahttps://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/intermediary/f/8b472d70-a0d6-41b5-9a66-c35687090acc/d23jbr4-8a06af02-70cb-46da-8a96-42a6ba73cdb4.jpg!, @site.image_urls.sole)
|
||||
assert_equal("edsfox", @site.artist_name)
|
||||
@@ -215,7 +215,7 @@ module Sources
|
||||
|
||||
context "with a referer" do
|
||||
should "work" do
|
||||
@site = Sources::Strategies.find(@url, @ref)
|
||||
@site = Source::Extractor.find(@url, @ref)
|
||||
|
||||
assert_match(%r!\Ahttps://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/intermediary/f/8b472d70-a0d6-41b5-9a66-c35687090acc/d23jbr4-8a06af02-70cb-46da-8a96-42a6ba73cdb4.jpg!, @site.image_urls.sole)
|
||||
assert_equal("edsfox", @site.artist_name)
|
||||
@@ -236,7 +236,7 @@ module Sources
|
||||
|
||||
context "with a referer" do
|
||||
should "work" do
|
||||
@site = Sources::Strategies.find(@url, @ref)
|
||||
@site = Source::Extractor.find(@url, @ref)
|
||||
|
||||
assert_equal(@ref, @site.page_url)
|
||||
assert_equal([@artist], @site.artists)
|
||||
@@ -247,7 +247,7 @@ module Sources
|
||||
|
||||
context "The source for a non-downloadable animated gif with id<=790677560" do
|
||||
should "return working image url" do
|
||||
@site = Sources::Strategies.find("https://www.deviantart.com/heartgear/art/Silent-Night-579982816")
|
||||
@site = Source::Extractor.find("https://www.deviantart.com/heartgear/art/Silent-Night-579982816")
|
||||
|
||||
# md5: 62caac1863aa264a56d548b4b7607097
|
||||
assert_match(%r!\Ahttps://images-wixmp-ed30a86b8c4ca887773594c2\.wixmp\.com/f/ea95be00-c5aa-4063-bd55-f5a9183912f7/d9lb1ls-7d625444-0003-4123-bf00-274737ca7fdd.gif\?token=!, @site.image_urls.sole)
|
||||
@@ -258,7 +258,7 @@ module Sources
|
||||
context "The source for a non-downloadable flash file" do
|
||||
should "return working image url" do
|
||||
skip
|
||||
@site = Sources::Strategies.find("https://www.deviantart.com/heartgear/art/SL-40v3-522007633")
|
||||
@site = Source::Extractor.find("https://www.deviantart.com/heartgear/art/SL-40v3-522007633")
|
||||
|
||||
# md5: 6adf1a3d532f898f44cf9948cbc7db7d
|
||||
assert_match(%r!\Ahttps://api-da\.wixmp\.com/_api/download/file\?downloadToken=!, @site.image_urls.sole)
|
||||
@@ -268,7 +268,7 @@ module Sources
|
||||
|
||||
context "The source for a non-downloadable video file" do
|
||||
should "return working image url" do
|
||||
@site = Sources::Strategies.find("https://www.deviantart.com/gs-mantis/art/Chen-Goes-Fishing-505847233")
|
||||
@site = Source::Extractor.find("https://www.deviantart.com/gs-mantis/art/Chen-Goes-Fishing-505847233")
|
||||
|
||||
# md5: 344ac2b9fd5a87982af4b648aa2b2b0d
|
||||
assert_equal(["https://wixmp-ed30a86b8c4ca887773594c2.wixmp.com/v/mp4/fe046bc7-4d68-4699-96c1-19aa464edff6/d8d6281-91959e92-214f-4b2d-a138-ace09f4b6d09.1080p.8e57939eba634743a9fa41185e398d00.mp4"], @site.image_urls)
|
||||
@@ -278,7 +278,7 @@ module Sources
|
||||
|
||||
context "The source for an DeviantArt artwork page" do
|
||||
setup do
|
||||
@site = Sources::Strategies.find("http://noizave.deviantart.com/art/test-post-please-ignore-685436408")
|
||||
@site = Source::Extractor.find("http://noizave.deviantart.com/art/test-post-please-ignore-685436408")
|
||||
end
|
||||
|
||||
should "get the image url" do
|
||||
@@ -338,7 +338,7 @@ module Sources
|
||||
|
||||
context "The source for a login-only DeviantArt artwork page" do
|
||||
setup do
|
||||
@site = Sources::Strategies.find("http://noizave.deviantart.com/art/hidden-work-685458369")
|
||||
@site = Source::Extractor.find("http://noizave.deviantart.com/art/hidden-work-685458369")
|
||||
end
|
||||
|
||||
should "get the image url" do
|
||||
@@ -350,7 +350,7 @@ module Sources
|
||||
|
||||
context "A source with malformed links in the artist commentary" do
|
||||
should "fix the links" do
|
||||
@site = Sources::Strategies.find("https://teemutaiga.deviantart.com/art/Kisu-620666655")
|
||||
@site = Source::Extractor.find("https://teemutaiga.deviantart.com/art/Kisu-620666655")
|
||||
|
||||
assert_match(%r!"Print available at Inprnt":\[http://www.inprnt.com/gallery/teemutaiga/kisu\]!, @site.dtext_artist_commentary_desc)
|
||||
end
|
||||
@@ -358,7 +358,7 @@ module Sources
|
||||
|
||||
context "An artist entry with a profile url that is missing the 'www'" do
|
||||
should "still find the artist" do
|
||||
@site = Sources::Strategies.find("http://noizave.deviantart.com/art/test-post-please-ignore-685436408")
|
||||
@site = Source::Extractor.find("http://noizave.deviantart.com/art/test-post-please-ignore-685436408")
|
||||
@artist = create(:artist, name: "noizave", url_string: "https://deviantart.com/noizave")
|
||||
|
||||
assert_equal([@artist], @site.artists)
|
||||
|
||||
Reference in New Issue
Block a user