From 014b9af5f89d7e5618364b8732c9f9e338c9c8ac Mon Sep 17 00:00:00 2001 From: r888888888 Date: Tue, 3 Oct 2017 13:36:56 -0700 Subject: [PATCH] fetch ugoiras for batch action #3317 --- app/controllers/application_controller.rb | 2 +- app/logical/pixiv_api_client.rb | 4 +++- test/functional/uploads_controller_test.rb | 8 ++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 09f259778..c34e9ee90 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -14,7 +14,7 @@ class ApplicationController < ActionController::Base force_ssl :if => :ssl_login? helper_method :show_moderation_notice? - rescue_from Exception, :with => :rescue_exception + # rescue_from Exception, :with => :rescue_exception rescue_from User::PrivilegeError, :with => :access_denied rescue_from SessionLoader::AuthenticationFailure, :with => :authentication_failed rescue_from Danbooru::Paginator::PaginationError, :with => :render_pagination_limit diff --git a/app/logical/pixiv_api_client.rb b/app/logical/pixiv_api_client.rb index cc123228f..a000192ab 100644 --- a/app/logical/pixiv_api_client.rb +++ b/app/logical/pixiv_api_client.rb @@ -114,7 +114,9 @@ class PixivApiClient @tags = json["tags"].reject {|x| x =~ /^http:/} @tags += json["tools"] - TOOLS_BLACKLIST - if page_count > 1 + if json["metadata"]["zip_urls"] + @pages = json["metadata"]["zip_urls"] + elsif page_count > 1 @pages = json["metadata"]["pages"].map {|x| x["image_urls"]["large"]} else @pages = [json["image_urls"]["large"]] diff --git a/test/functional/uploads_controller_test.rb b/test/functional/uploads_controller_test.rb index 4a7cea0f0..3413f53f0 100644 --- a/test/functional/uploads_controller_test.rb +++ b/test/functional/uploads_controller_test.rb @@ -28,6 +28,14 @@ class UploadsControllerTest < ActionController::TestCase assert_response :success end end + + context "for pixiv ugoira galleries" do + should "render" do + get :batch, {:url => "https://www.pixiv.net/member_illust.php?mode=medium&illust_id=59523577"}, {:user_id => @user.id} + assert_response :success + assert_no_match(/59523577_ugoira0\.jpg/, response.body) + end + end end context "new action" do