Newgrounds: fix exception for deleted videos

Fixup for 8c0f2255f9
This commit is contained in:
nonamethanks
2022-11-11 12:28:23 +01:00
parent 8c0f2255f9
commit d525df9ad5
2 changed files with 11 additions and 1 deletions

View File

@@ -15,7 +15,7 @@ module Source
[url]
elsif video_data.present?
sample = video_data&.[]("sources")&.max_by { |k, _v| k.gsub(/p$/, "").to_i }&.dig(1, 0, "src")
final = [Source::URL.parse(sample).full_image_url, sample].find { |u| http_exists?(u) }
final = [Source::URL.parse(sample)&.full_image_url, sample].compact.find { |u| http_exists?(u) }
[final].compact
else
urls = []

View File

@@ -82,11 +82,21 @@ module Sources
strategy_should_work(
"https://www.newgrounds.com/art/view/natthelich/nopicture",
deleted: true,
image_urls: [],
profile_url: "https://natthelich.newgrounds.com",
artist_name: "natthelich"
)
end
context "A deleted or non-existing video" do
strategy_should_work(
"https://www.newgrounds.com/portal/view/802594",
deleted: true,
image_urls: [],
profile_url: nil
)
end
context "A www.newgrounds.com/dump/item URL" do
strategy_should_work(
"https://www.newgrounds.com/dump/item/a1f417d20f5eaef31e26ac3c4956b3d4",