add ugoira support in view

This commit is contained in:
r888888888
2014-10-16 14:25:05 -07:00
parent 3bb06c2be4
commit 4c73fb9f79
10 changed files with 69 additions and 8 deletions

View File

@@ -34,6 +34,7 @@ module Downloads
data[:ugoira_frame_data] = source.ugoira_frame_data
data[:ugoira_width] = source.ugoira_width
data[:ugoira_height] = source.ugoira_height
data[:ugoira_content_type] = source.ugoira_content_type
return [source.file_url, headers, data]
else
return [url, headers, data]

View File

@@ -1,12 +1,12 @@
class PixivUgoiraService
attr_reader :width, :height, :frame_data
attr_reader :width, :height, :frame_data, :content_type
def process(post)
save_frame_data(post)
end
def save_frame_data(post)
PixivUgoiraFrameData.create(:data => @frame_data, :post_id => post.id)
PixivUgoiraFrameData.create(:data => @frame_data, :content_type => @content_type, :post_id => post.id)
end
def generate_resizes(source_path, output_path, preview_path)
@@ -17,5 +17,6 @@ class PixivUgoiraService
@frame_data = data[:ugoira_frame_data]
@width = data[:ugoira_width]
@height = data[:ugoira_height]
@content_type = data[:ugoira_content_type]
end
end

View File

@@ -5,7 +5,7 @@ require 'csv'
module Sources
module Strategies
class Pixiv < Base
attr_reader :zip_url, :ugoira_frame_data, :ugoira_width, :ugoira_height
attr_reader :zip_url, :ugoira_frame_data, :ugoira_width, :ugoira_height, :ugoira_content_type
def self.url_match?(url)
url =~ /^https?:\/\/(?:\w+\.)?pixiv\.net/
@@ -46,7 +46,7 @@ module Sources
@artist_name, @profile_url = get_profile_from_page(page)
@pixiv_moniker = get_moniker_from_page(page)
@image_url = get_image_url_from_page(page)
@zip_url, @ugoira_frame_data, @ugoira_width, @ugoira_height = get_zip_url_from_page(page)
@zip_url, @ugoira_frame_data, @ugoira_width, @ugoira_height, @ugoira_content_type = get_zip_url_from_page(page)
@tags = get_tags_from_page(page)
@page_count = get_page_count_from_page(page)
@@ -190,6 +190,7 @@ module Sources
data = JSON.parse(json)
zip_url = data["src"].sub("_ugoira600x600.zip", "_ugoira1920x1080.zip")
frame_data = data["frames"]
content_type = data["mime_type"]
if javascript =~ /illustSize\s*=\s*\[\s*(\d+)\s*,\s*(\d+)\s*\]/
image_width = $1.to_i
@@ -199,7 +200,7 @@ module Sources
image_height = 600
end
return [zip_url, frame_data, image_width, image_height]
return [zip_url, frame_data, image_width, image_height, content_type]
end
end