Merge branch 'master' into fix-pixiv-profile-url

This commit is contained in:
evazion
2020-06-24 00:06:55 -05:00
committed by GitHub
103 changed files with 1639 additions and 2247 deletions

View File

@@ -43,7 +43,7 @@ module Sources
should "get the image url" do
assert_equal("https://pic.nijie.net/03/nijie_picture/728995_20170505014820_0.jpg", @site.image_url)
assert_http_size(132_555, @site.image_url)
assert_downloaded(132_555, @site.image_url)
end
should "get the canonical url" do
@@ -53,7 +53,7 @@ module Sources
should "get the preview url" do
assert_equal("https://pic.nijie.net/03/__rs_l170x170/nijie_picture/728995_20170505014820_0.jpg", @site.preview_url)
assert_equal([@site.preview_url], @site.preview_urls)
assert_http_exists(@site.preview_url)
assert_downloaded(132_555, @site.preview_url)
end
should "get the profile" do
@@ -187,8 +187,6 @@ module Sources
desc = <<-EOS.strip_heredoc.chomp
foo [b]bold[/b] [i]italics[/i] [s]strike[/s] red
<http://nijie.info/view.php?id=218944>
EOS
@@ -207,8 +205,8 @@ module Sources
assert_equal("https://nijie.info/members.php?id=236014", site.profile_url)
assert_nothing_raised { site.to_h }
assert_http_size(3619, site.image_url)
assert_http_exists(site.preview_url)
assert_downloaded(3619, site.image_url)
assert_downloaded(3619, site.preview_url)
end
end

View File

@@ -15,10 +15,7 @@ module Sources
def get_source(source)
@site = Sources::Strategies.find(source)
@site
rescue Net::OpenTimeout
skip "Remote connection to #{source} failed"
end
context "in all cases" do
@@ -73,17 +70,6 @@ module Sources
end
end
context "A https://www.pixiv.net/fanbox/creator/*/post/* source" do
should_eventually "work" do
@site = Sources::Strategies.find("http://www.pixiv.net/fanbox/creator/554149/post/82555")
assert_equal("TYONE(お仕事募集中)", @site.artist_name)
assert_equal("https://www.pixiv.net/users/554149", @site.profile_url)
assert_equal("https://fanbox.pixiv.net/images/post/82555/Lyyeb6dDLcQZmy09nqLZapuS.jpeg", @site.image_url)
assert_nothing_raised { @site.to_h }
end
end
context "A https://www.pixiv.net/*/artworks/* source" do
should "work" do
@site = Sources::Strategies.find("https://www.pixiv.net/en/artworks/64476642")
@@ -249,6 +235,10 @@ module Sources
assert_includes(@translated_tags, "foo")
end
should "not translate tags for digital media" do
assert_equal(false, @tags.include?("Photoshop"))
end
should "normalize 10users入り tags" do
assert_includes(@tags, "風景10users入り")
assert_includes(@translated_tags, "scenery")
@@ -280,7 +270,7 @@ module Sources
should "not translate '1000users入り' to '1'" do
FactoryBot.create(:tag, name: "1", post_count: 1)
source = get_source("https://www.pixiv.net/member_illust.php?mode=medium&illust_id=60665428")
tags = %w[1000users入り Fate/GrandOrder アルジュナ(Fate) アルトリア・ペンドラゴン イシュタル(Fate) グランブルーファンタジー マシュ・キリエライト マーリン(Fate) 両儀式 手袋 CLIP\ STUDIO\ PAINT Photoshop]
tags = %w[1000users入り Fate/GrandOrder アルジュナ(Fate) アルトリア・ペンドラゴン イシュタル(Fate) グランブルーファンタジー マシュ・キリエライト マーリン(Fate) 両儀式 手袋]
assert_equal(tags.sort, source.tags.map(&:first).sort)
assert_equal(["fate/grand_order"], source.translated_tags.map(&:name))

View File

@@ -169,7 +169,7 @@ module Sources
context "The source for a 'http://ve.media.tumblr.com/*' video post with inline images" do
setup do
@url = "https://ve.media.tumblr.com/tumblr_os31dkexhK1wsfqep.mp4"
@url = "https://va.media.tumblr.com/tumblr_os31dkexhK1wsfqep.mp4"
@ref = "https://noizave.tumblr.com/post/162222617101"
end
@@ -177,7 +177,7 @@ module Sources
should "get the video and inline images" do
site = Sources::Strategies.find(@url, @ref)
urls = %w[
https://ve.media.tumblr.com/tumblr_os31dkexhK1wsfqep.mp4
https://va.media.tumblr.com/tumblr_os31dkexhK1wsfqep.mp4
https://media.tumblr.com/afed9f5b3c33c39dc8c967e262955de2/tumblr_inline_os31dclyCR1v11u29_1280.png
]

View File

@@ -244,6 +244,14 @@ module Sources
end
end
context "A profile banner image" do
should "work" do
@site = Sources::Strategies.find("https://pbs.twimg.com/profile_banners/1225702850002468864/1588597370/1500x500")
assert_equal(@site.image_url, @site.url)
assert_nothing_raised { @site.to_h }
end
end
context "A tweet containing non-normalized Unicode text" do
should "be normalized to nfkc" do
site = Sources::Strategies.find("https://twitter.com/aprilarcus/status/367557195186970624")