refactor source pixiv test
refactor pixiv download tests refactor upload test refactor nico seiga test refactor twitter tests
This commit is contained in:
@@ -112,10 +112,15 @@ class ArtistsController < ApplicationController
|
||||
end
|
||||
|
||||
def finder
|
||||
@artists = Artist.url_matches(params[:url]).order("id desc").limit(20)
|
||||
if @artists.empty? && params[:referer_url].present? && params[:referer_url] != params[:url]
|
||||
@artists = Artist.url_matches(params[:referer_url]).order("id desc").limit(20)
|
||||
begin
|
||||
@artists = Artist.url_matches(params[:url]).order("id desc").limit(20)
|
||||
if @artists.empty? && params[:referer_url].present? && params[:referer_url] != params[:url]
|
||||
@artists = Artist.url_matches(params[:referer_url]).order("id desc").limit(20)
|
||||
end
|
||||
rescue PixivApiClient::Error => e
|
||||
@artists = []
|
||||
end
|
||||
|
||||
respond_with(@artists) do |format|
|
||||
format.xml do
|
||||
render :xml => @artists.to_xml(:include => [:urls], :root => "artists")
|
||||
@@ -131,5 +136,4 @@ private
|
||||
def load_artist
|
||||
@artist = Artist.find(params[:id])
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -11,13 +11,12 @@ module Sources
|
||||
TIMESTAMP = '(?:[0-9]{4}/[0-9]{2}/[0-9]{2}/[0-9]{2}/[0-9]{2}/[0-9]{2})'
|
||||
EXT = "(?:jpg|jpeg|png|gif)"
|
||||
|
||||
WHITECUBE = /^https?:\/\/wwww\.pixiv\.net\/whitecube/i
|
||||
WEB = "^(?:https?://)?www\\.pixiv\\.net"
|
||||
I12 = "^(?:https?://)?i[0-9]+\\.pixiv\\.net"
|
||||
IMG = "^(?:https?://)?img[0-9]*\\.pixiv\\.net"
|
||||
|
||||
def self.url_match?(url)
|
||||
url !~ WHITECUBE && url =~ /#{WEB}|#{IMG}|#{I12}/i
|
||||
url =~ /#{WEB}|#{IMG}|#{I12}/i
|
||||
end
|
||||
|
||||
def referer_url
|
||||
|
||||
@@ -261,7 +261,7 @@ class Upload < ActiveRecord::Base
|
||||
# by the time this runs we'll have moved source_path to md5_file_path
|
||||
ugoira_service.generate_resizes(md5_file_path, resized_file_path_for(Danbooru.config.large_image_width), resized_file_path_for(Danbooru.config.small_image_width))
|
||||
else
|
||||
ugoira_service.generate_resizes(source_path, resized_file_path_for(Danbooru.config.large_image_width), resized_file_path_for(Danbooru.config.small_image_width))
|
||||
ugoira_service.generate_resizes(source_path, resized_file_path_for(Danbooru.config.large_image_width), resized_file_path_for(Danbooru.config.small_image_width), false)
|
||||
end
|
||||
elsif is_video?
|
||||
generate_video_preview_for(width, height, output_path)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<% if @error_message %>
|
||||
{"success": false, "message": <%= raw @error_message.to_json %>}
|
||||
{"success": false, "message": <%= raw @error_message.encode("utf-8", {:invalid => :replace, :undef => :replace, :replace => "?"}).to_json %>}
|
||||
<% else %>
|
||||
{"success": false, "message": <%= raw @exception.to_s.to_json %>}
|
||||
{"success": false, "message": <%= raw @exception.to_s.encode("utf-8", {:invalid => :replace, :undef => :replace, :replace => "?"}).to_json %>}
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user