no longer require presence of ugoira tag to process ugoira posts

This commit is contained in:
r888888888
2014-10-23 16:34:31 -07:00
parent c9ee4f242f
commit 981e6dab67
4 changed files with 11 additions and 12 deletions

View File

@@ -14,7 +14,7 @@ module Downloads
@file_path = file_path
# we sometimes need to capture data from the source page
@data = {:is_ugoira => options[:is_ugoira]}
@data = {}
end
def download!

View File

@@ -18,6 +18,7 @@ module Downloads
# http://i2.pixiv.net/img-zip-ugoira/img/2014/08/05/06/01/10/44524589_ugoira1920x1080.zip
if url =~ %r!\Ahttps?://i\d+\.pixiv\.net/img-zip-ugoira/img/\d{4}/\d{2}/\d{2}/\d{2}/\d{2}/\d{2}/\d+_ugoira\d+x\d+\.zip\z!i
data[:is_ugoira] = true
data[:ugoira_frame_data] = source.ugoira_frame_data
data[:ugoira_width] = source.ugoira_width
data[:ugoira_height] = source.ugoira_height

View File

@@ -19,9 +19,11 @@ class PixivUgoiraService
end
def load(data)
@frame_data = data[:ugoira_frame_data]
@width = data[:ugoira_width]
@height = data[:ugoira_height]
@content_type = data[:ugoira_content_type]
if data[:is_ugoira]
@frame_data = data[:ugoira_frame_data]
@width = data[:ugoira_width]
@height = data[:ugoira_height]
@content_type = data[:ugoira_content_type]
end
end
end

View File

@@ -149,7 +149,7 @@ class Upload < ActiveRecord::Base
end
def async_conversion?
has_ugoira_tag?
is_ugoira?
end
def ugoira_service
@@ -366,16 +366,12 @@ class Upload < ActiveRecord::Base
source =~ /^https?:\/\// && file_path.blank?
end
def has_ugoira_tag?
tag_string =~ /\bugoira\b/i
end
# Downloads the file to destination_path
def download_from_source(destination_path)
self.file_path = destination_path
download = Downloads::File.new(source, destination_path, :is_ugoira => has_ugoira_tag?)
download = Downloads::File.new(source, destination_path)
download.download!
ugoira_service.load(download.data) if has_ugoira_tag?
ugoira_service.load(download.data)
end
end