From 8fbc6d1d3ac32ff9610e8bcf024ed328895b0d1e Mon Sep 17 00:00:00 2001 From: evazion Date: Tue, 11 Oct 2022 01:31:49 -0500 Subject: [PATCH] gelbooru: fix exception in md5-based post urls. Fix exception when trying to get the image URL for sources like https://gelbooru.com/index.php?page=post&s=list&md5=04f2767c64593c3030ce74ecc2528704. --- app/logical/source/extractor/gelbooru.rb | 2 +- test/unit/sources/gelbooru_test.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/logical/source/extractor/gelbooru.rb b/app/logical/source/extractor/gelbooru.rb index b3d1717ac..51fd5a1f9 100644 --- a/app/logical/source/extractor/gelbooru.rb +++ b/app/logical/source/extractor/gelbooru.rb @@ -59,7 +59,7 @@ module Source end memoize def post_id_from_md5 - return nil unless parsed_url.image_url? && parsed_url.page_url.present? + return nil unless parsed_url.page_url.present? response = http.cache(1.minute).head(parsed_url.page_url) return nil unless response.status == 200 diff --git a/test/unit/sources/gelbooru_test.rb b/test/unit/sources/gelbooru_test.rb index 128514dad..cf690d9f0 100644 --- a/test/unit/sources/gelbooru_test.rb +++ b/test/unit/sources/gelbooru_test.rb @@ -54,5 +54,18 @@ module Sources download_size: 480_621, ) end + + context "A Gelbooru md5 page url" do + strategy_should_work( + "https://gelbooru.com/index.php?page=post&s=list&md5=04f2767c64593c3030ce74ecc2528704", + image_urls: ["https://img3.gelbooru.com/images/04/f2/04f2767c64593c3030ce74ecc2528704.jpg"], + artist_name: "灰色灰烬bot", + profile_url: "https://www.pixiv.net/users/3330425", + tags: %w[1girl back_bow bangs black_pantyhose blue_bow blue_hair blue_ribbon boots bow cape chibi chinese_commentary closed_eyes full_body hair_between_eyes hair_ribbon hat hatsune_miku indai_(3330425) on_ground pantyhose pom_pom_(clothes) rabbit rabbit_yukine rating:general ribbon simple_background sitting solo twintails vocaloid white_background white_cape white_headwear witch_hat yuki_miku yuki_miku_(2014) 初音ミク 雪ミク], + artist_commentary_title: "2010~2021雪ミク", + artist_commentary_desc: "动作参考@速写班长", + download_size: 480_621, + ) + end end end