From 36a78361d73ee9e402bbe8f03d3c1bc752ef998b Mon Sep 17 00:00:00 2001 From: evazion Date: Sat, 4 Oct 2014 01:42:09 -0500 Subject: [PATCH] Normalize URLs to the mode=medium page correctly. This handles a few new cases that weren't handled correctly previously. * http://i1.pixiv.net/img-zip-ugoira/img/2014/10/03/17/29/16/46323924_ugoira1920x1080.zip * http://i1.pixiv.net/c/600x600/img-master/img/2014/10/02/13/51/23/46304396_p0_master1200.jpg * http://www.pixiv.net/member_illust.php?mode=manga&illust_id=18557054 * http://www.pixiv.net/member_illust.php?mode=manga_big&illust_id=18557054&page=1 * http://www.pixiv.net/i/18557054 --- app/logical/sources/strategies/pixiv.rb | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/app/logical/sources/strategies/pixiv.rb b/app/logical/sources/strategies/pixiv.rb index ac5d0d2e3..0b9b675c4 100644 --- a/app/logical/sources/strategies/pixiv.rb +++ b/app/logical/sources/strategies/pixiv.rb @@ -112,17 +112,8 @@ module Sources end def normalized_url - @normalized_url ||= begin - if url =~ /\/(\d+)(?:_big)?(?:_m|_p\d+)?\.(?:jpg|jpeg|png|gif)/i - "http://www.pixiv.net/member_illust.php?mode=medium&illust_id=#{$1}" - elsif url =~ /mode=big/ - url.sub(/mode=big/, "mode=medium") - elsif url =~ /member_illust\.php/ && url =~ /illust_id=/ - url - else - nil - end - end + illust_id = illust_id_from_url(@url) + "http://www.pixiv.net/member_illust.php?mode=medium&illust_id=#{illust_id}" end # Refer to http://danbooru.donmai.us/wiki_pages/58938 for documentation on the Pixiv API.