diff --git a/app/logical/sources/strategies/foundation.rb b/app/logical/sources/strategies/foundation.rb index 738abbd52..cd28a2f45 100644 --- a/app/logical/sources/strategies/foundation.rb +++ b/app/logical/sources/strategies/foundation.rb @@ -4,6 +4,7 @@ # Page URLs # # * https://foundation.app/@mochiiimo/~/97376 +# * https://foundation.app/@huwari/~/88982 (video) # # Profile URLs # @@ -34,13 +35,17 @@ module Sources def image_urls return [url.gsub(/\?.*/, "")] if url =~ IMAGE_URL - page&.search("meta[property='og:image']").map do |img| - img["content"].gsub(/\?.*/, "") + image = page&.at(".fullscreen img, .fullscreen video")&.[](:src)&.gsub(/\?.*/, "") + + if image =~ %r{assets\.foundation\.app/(?:\w+/)+(\w+)/nft_\w+\.(\w+)}i + image = "https://f8n-ipfs-production.imgix.net/#{$1}/nft.#{$2}" end + + [image] end def preview_urls - image_urls.map { |img| "#{img}?fit=fill&max-h=600" } + [page&.at("meta[property='og:image']")&.[](:content)] end def page_url diff --git a/test/unit/sources/foundation_test.rb b/test/unit/sources/foundation_test.rb index a126322b1..573435f98 100644 --- a/test/unit/sources/foundation_test.rb +++ b/test/unit/sources/foundation_test.rb @@ -5,21 +5,26 @@ module Sources context "The source for a Foundation picture" do setup do @post_url = "https://foundation.app/@dadachyo/~/103724" + @post_with_video = "https://foundation.app/@huwari/~/88982" @image_url = "https://f8n-ipfs-production.imgix.net/QmPhpz6E9TFRpvdVTviM8Hy9o9rxrnPW5Ywj471NnSNkpi/nft.jpg" @image1 = Sources::Strategies.find(@post_url) @image2 = Sources::Strategies.find(@image_url) + @image3 = Sources::Strategies.find(@post_with_video) end should "get the artist name" do assert_equal("dadachyo", @image1.artist_name) + assert_equal("huwari", @image3.artist_name) end should "get the artist commentary title" do assert_equal("Rose tea", @image1.artist_commentary_title) + assert_equal("bus", @image3.artist_commentary_title) end should "get profile url" do assert_equal("https://foundation.app/@dadachyo", @image1.profile_url) + assert_equal("https://foundation.app/@huwari", @image3.profile_url) end should "get the image url" do @@ -30,6 +35,7 @@ module Sources should "download an image" do assert_downloaded(13_908_349, @image1.image_url) assert_downloaded(13_908_349, @image2.image_url) + assert_downloaded(13_391_766, @image3.image_url) end should "find the correct artist" do @@ -40,6 +46,7 @@ module Sources should "not raise errors" do assert_nothing_raised { @image1.to_h } assert_nothing_raised { @image2.to_h } + assert_nothing_raised { @image3.to_h } end end end