Compare commits
5 commits
main
...
jedmund/do
| Author | SHA1 | Date | |
|---|---|---|---|
| a0e2f27345 | |||
| c76b79e4b8 | |||
| df1bc9427a | |||
| 29c52469a3 | |||
| db9be1aee9 |
8 changed files with 166 additions and 99 deletions
|
|
@ -1,2 +1,2 @@
|
||||||
name_en,name_jp,granblue_id,rarity,element,series,flb,ulb,max_level,min_hp,max_hp,max_hp_flb,max_hp_ulb,min_atk,max_atk,max_atk_flb,max_atk_ulb,subaura,limit,transcendence,max_atk_xlb,max_hp_xlb,summon_id,release_date,flb_date,ulb_date,wiki_en,wiki_ja,gamewith,kamigame,transcendence_date,nicknames_en,nicknames_jp
|
name_en,name_jp,granblue_id,rarity,element,series,flb,ulb,max_level,min_hp,max_hp,max_hp_flb,max_hp_ulb,min_atk,max_atk,max_atk_flb,max_atk_ulb,subaura,limit,transcendence,max_atk_xlb,max_hp_xlb,summon_id,release_date,flb_date,ulb_date,wiki_en,wiki_ja,gamewith,kamigame,transcendence_date,nicknames_en,nicknames_jp
|
||||||
Mars (Summer),マーズ(水着ver),2040428000,3,6,,true,false,150,131,804,972,,362,2082,2512,,true,false,false,,,2040428000,2024-07-16,2024-07-16,,Mars_(Summer),マーズ (SSR)水着バージョン,457007,SSR/水着マーズ,,,
|
Mars (Summer),マーズ(水着ver),2040428000,3,6,,true,false,150,131,804,972,,362,2082,2512,,true,false,false,,,3337,2024-07-16,2024-07-16,,Mars_(Summer),マーズ (SSR)水着バージョン,457007,SSR/水着マーズ,,,
|
||||||
|
|
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
name_en,name_jp,granblue_id,rarity,element,series,flb,ulb,max_level,min_hp,max_hp,max_hp_flb,max_hp_ulb,min_atk,max_atk,max_atk_flb,max_atk_ulb,subaura,limit,transcendence,max_atk_xlb,max_hp_xlb,summon_id,release_date,flb_date,ulb_date,wiki_en,wiki_ja,gamewith,kamigame,transcendence_date,nicknames_en,nicknames_jp
|
name_en,name_jp,granblue_id,rarity,element,series,flb,ulb,max_level,min_hp,max_hp,max_hp_flb,max_hp_ulb,min_atk,max_atk,max_atk_flb,max_atk_ulb,subaura,limit,transcendence,max_atk_xlb,max_hp_xlb,summon_id,release_date,flb_date,ulb_date,wiki_en,wiki_ja,gamewith,kamigame,transcendence_date,nicknames_en,nicknames_jp
|
||||||
Beelzebub (Summer),ベルゼバブ(水着ver),2040429000,3,3,,true,false,150,115,793,1132,,442,2137,2985,,true,false,false,,,{3319},2024-07-31,2024-07-31,,Beelzebub_(Summer),ベルゼバブ (SSR)水着,458158,水着ベルゼバブ,,"{babu,bubz}",
|
Beelzebub (Summer),ベルゼバブ(水着ver),2040429000,3,3,,true,false,150,115,793,1132,,442,2137,2985,,true,false,false,,,3319,2024-07-31,2024-07-31,,Beelzebub_(Summer),ベルゼバブ (SSR)水着,458158,水着ベルゼバブ,,"{babu,bubz}",
|
||||||
Wedges of the Sky,蒼空の楔,2040430000,3,1,,false,false,100,109,668,,,277,1740,,,true,false,false,,,{3338},2024-08-09,,,Wedges_of_the_Sky,蒼空の楔 (SSR),458492,蒼空の楔,,"{boost,dragons}",
|
Wedges of the Sky,蒼空の楔,2040430000,3,1,,false,false,100,109,668,,,277,1740,,,true,false,false,,,3338,2024-08-09,,,Wedges_of_the_Sky,蒼空の楔 (SSR),458492,蒼空の楔,,"{boost,dragons}",
|
||||||
|
|
|
||||||
|
|
|
@ -5,84 +5,23 @@ module Granblue
|
||||||
class DownloadManager
|
class DownloadManager
|
||||||
class << self
|
class << self
|
||||||
def download_for_object(type, granblue_id, test_mode: false, verbose: false, storage: :both)
|
def download_for_object(type, granblue_id, test_mode: false, verbose: false, storage: :both)
|
||||||
@test_mode = test_mode
|
downloader_options = {
|
||||||
@verbose = verbose
|
test_mode: test_mode,
|
||||||
@storage = storage
|
verbose: verbose,
|
||||||
|
storage: storage
|
||||||
|
}
|
||||||
|
|
||||||
case type
|
case type
|
||||||
when 'character'
|
when 'character'
|
||||||
download_character(granblue_id)
|
CharacterDownloader.new(granblue_id, **downloader_options).download
|
||||||
when 'weapon'
|
when 'weapon'
|
||||||
download_weapon(granblue_id)
|
WeaponDownloader.new(granblue_id, **downloader_options).download
|
||||||
when 'summon'
|
when 'summon'
|
||||||
download_summon(granblue_id)
|
SummonDownloader.new(granblue_id, **downloader_options).download
|
||||||
else
|
else
|
||||||
log_info "Unknown object type: #{type}"
|
log_info "Unknown object type: #{type}" if verbose || test_mode
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def download_character(id)
|
|
||||||
character = Character.find_by(granblue_id: id)
|
|
||||||
return unless character
|
|
||||||
|
|
||||||
downloader_options = {
|
|
||||||
test_mode: @test_mode,
|
|
||||||
verbose: @verbose,
|
|
||||||
storage: @storage
|
|
||||||
}
|
|
||||||
|
|
||||||
%W[#{id}_01 #{id}_02].each do |variant_id|
|
|
||||||
CharacterDownloader.new(variant_id, **downloader_options).download
|
|
||||||
end
|
|
||||||
|
|
||||||
CharacterDownloader.new("#{id}_03", **downloader_options).download if character.flb
|
|
||||||
CharacterDownloader.new("#{id}_04", **downloader_options).download if character.ulb
|
|
||||||
end
|
|
||||||
|
|
||||||
def download_weapon(id)
|
|
||||||
weapon = Weapon.find_by(granblue_id: id)
|
|
||||||
return unless weapon
|
|
||||||
|
|
||||||
downloader_options = {
|
|
||||||
test_mode: @test_mode,
|
|
||||||
verbose: @verbose,
|
|
||||||
storage: @storage
|
|
||||||
}
|
|
||||||
|
|
||||||
WeaponDownloader.new(id, **downloader_options).download
|
|
||||||
|
|
||||||
return unless weapon.transcendence
|
|
||||||
|
|
||||||
WeaponDownloader.new("#{id}_02", **downloader_options).download
|
|
||||||
WeaponDownloader.new("#{id}_03", **downloader_options).download
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def download_summon(id)
|
|
||||||
summon = Summon.find_by(granblue_id: id)
|
|
||||||
return unless summon
|
|
||||||
|
|
||||||
downloader_options = {
|
|
||||||
test_mode: @test_mode,
|
|
||||||
verbose: @verbose,
|
|
||||||
storage: @storage
|
|
||||||
}
|
|
||||||
|
|
||||||
SummonDownloader.new(id, **downloader_options).download
|
|
||||||
SummonDownloader.new("#{id}_02", **downloader_options).download if summon.ulb
|
|
||||||
|
|
||||||
return unless summon.transcendence
|
|
||||||
|
|
||||||
SummonDownloader.new("#{id}_03", **downloader_options).download
|
|
||||||
SummonDownloader.new("#{id}_04", **downloader_options).download
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def log_info(message)
|
|
||||||
puts message if @verbose || @test_mode
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,48 @@
|
||||||
module Granblue
|
module Granblue
|
||||||
module Downloader
|
module Downloader
|
||||||
class CharacterDownloader < BaseDownloader
|
class CharacterDownloader < BaseDownloader
|
||||||
|
def download
|
||||||
|
character = Character.find_by(granblue_id: @id)
|
||||||
|
return unless character
|
||||||
|
|
||||||
|
download_variants(character)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def download_variants(character)
|
||||||
|
# All characters have 01 and 02 variants
|
||||||
|
variants = ["#{@id}_01", "#{@id}_02"]
|
||||||
|
|
||||||
|
# Add FLB variant if available
|
||||||
|
variants << "#{@id}_03" if character.flb
|
||||||
|
|
||||||
|
# Add ULB variant if available
|
||||||
|
variants << "#{@id}_04" if character.ulb
|
||||||
|
|
||||||
|
log_info "Downloading character variants: #{variants.join(', ')}" if @verbose
|
||||||
|
|
||||||
|
variants.each do |variant_id|
|
||||||
|
download_variant(variant_id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def download_variant(variant_id)
|
||||||
|
log_info "-> #{variant_id}" if @verbose
|
||||||
|
return if @test_mode
|
||||||
|
|
||||||
|
SIZES.each_with_index do |size, index|
|
||||||
|
path = download_path(size)
|
||||||
|
url = build_variant_url(variant_id, size)
|
||||||
|
process_download(url, size, path, last: index == SIZES.size - 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def build_variant_url(variant_id, size)
|
||||||
|
directory = directory_for_size(size)
|
||||||
|
"#{@base_url}/#{directory}/#{variant_id}.jpg"
|
||||||
|
end
|
||||||
|
|
||||||
def object_type
|
def object_type
|
||||||
'character'
|
'character'
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,50 @@
|
||||||
module Granblue
|
module Granblue
|
||||||
module Downloader
|
module Downloader
|
||||||
class SummonDownloader < BaseDownloader
|
class SummonDownloader < BaseDownloader
|
||||||
|
def download
|
||||||
|
summon = Summon.find_by(granblue_id: @id)
|
||||||
|
return unless summon
|
||||||
|
|
||||||
|
download_variants(summon)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def download_variants(summon)
|
||||||
|
# All summons have base variant
|
||||||
|
variants = [@id]
|
||||||
|
|
||||||
|
# Add ULB variant if available
|
||||||
|
variants << "#{@id}_02" if summon.ulb
|
||||||
|
|
||||||
|
# Add Transcendence variants if available
|
||||||
|
if summon.transcendence
|
||||||
|
variants.push("#{@id}_03", "#{@id}_04")
|
||||||
|
end
|
||||||
|
|
||||||
|
log_info "Downloading summon variants: #{variants.join(', ')}" if @verbose
|
||||||
|
|
||||||
|
variants.each do |variant_id|
|
||||||
|
download_variant(variant_id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def download_variant(variant_id)
|
||||||
|
log_info "-> #{variant_id}" if @verbose
|
||||||
|
return if @test_mode
|
||||||
|
|
||||||
|
SIZES.each_with_index do |size, index|
|
||||||
|
path = download_path(size)
|
||||||
|
url = build_variant_url(variant_id, size)
|
||||||
|
process_download(url, size, path, last: index == SIZES.size - 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def build_variant_url(variant_id, size)
|
||||||
|
directory = directory_for_size(size)
|
||||||
|
"#{@base_url}/#{directory}/#{variant_id}.jpg"
|
||||||
|
end
|
||||||
|
|
||||||
def object_type
|
def object_type
|
||||||
'summon'
|
'summon'
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,47 @@
|
||||||
module Granblue
|
module Granblue
|
||||||
module Downloader
|
module Downloader
|
||||||
class WeaponDownloader < BaseDownloader
|
class WeaponDownloader < BaseDownloader
|
||||||
|
def download
|
||||||
|
weapon = Weapon.find_by(granblue_id: @id)
|
||||||
|
return unless weapon
|
||||||
|
|
||||||
|
download_variants(weapon)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def download_variants(weapon)
|
||||||
|
# All weapons have base variant
|
||||||
|
variants = [@id]
|
||||||
|
|
||||||
|
# Add transcendence variants if available
|
||||||
|
if weapon.transcendence
|
||||||
|
variants.push("#{@id}_02", "#{@id}_03")
|
||||||
|
end
|
||||||
|
|
||||||
|
log_info "Downloading weapon variants: #{variants.join(', ')}" if @verbose
|
||||||
|
|
||||||
|
variants.each do |variant_id|
|
||||||
|
download_variant(variant_id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def download_variant(variant_id)
|
||||||
|
log_info "-> #{variant_id}" if @verbose
|
||||||
|
return if @test_mode
|
||||||
|
|
||||||
|
SIZES.each_with_index do |size, index|
|
||||||
|
path = download_path(size)
|
||||||
|
url = build_variant_url(variant_id, size)
|
||||||
|
process_download(url, size, path, last: index == SIZES.size - 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def build_variant_url(variant_id, size)
|
||||||
|
directory = directory_for_size(size)
|
||||||
|
"#{@base_url}/#{directory}/#{variant_id}.jpg"
|
||||||
|
end
|
||||||
|
|
||||||
def object_type
|
def object_type
|
||||||
'weapon'
|
'weapon'
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,12 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require_relative '../logging_helper'
|
require_relative '../logging_helper'
|
||||||
|
require_relative '../granblue/downloaders/base_downloader'
|
||||||
|
require_relative '../granblue/downloaders/character_downloader'
|
||||||
|
require_relative '../granblue/downloaders/weapon_downloader'
|
||||||
|
require_relative '../granblue/downloaders/summon_downloader'
|
||||||
|
require_relative '../granblue/downloaders/elemental_weapon_downloader'
|
||||||
|
require_relative '../granblue/download_manager'
|
||||||
|
|
||||||
module PostDeployment
|
module PostDeployment
|
||||||
class ImageDownloader
|
class ImageDownloader
|
||||||
|
|
@ -12,6 +18,12 @@ module PostDeployment
|
||||||
both: 'to local disk and S3'
|
both: 'to local disk and S3'
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
|
SUPPORTED_TYPES = {
|
||||||
|
'character' => Granblue::Downloader::CharacterDownloader,
|
||||||
|
'summon' => Granblue::Downloader::SummonDownloader,
|
||||||
|
'weapon' => Granblue::Downloader::WeaponDownloader
|
||||||
|
}.freeze
|
||||||
|
|
||||||
def initialize(test_mode:, verbose:, storage:, new_records:, updated_records:)
|
def initialize(test_mode:, verbose:, storage:, new_records:, updated_records:)
|
||||||
@test_mode = test_mode
|
@test_mode = test_mode
|
||||||
@verbose = verbose
|
@verbose = verbose
|
||||||
|
|
@ -21,35 +33,34 @@ module PostDeployment
|
||||||
end
|
end
|
||||||
|
|
||||||
def run
|
def run
|
||||||
|
return if @test_mode
|
||||||
|
|
||||||
log_header 'Downloading images...', '+'
|
log_header 'Downloading images...', '+'
|
||||||
|
|
||||||
[@new_records, @updated_records].each do |records|
|
SUPPORTED_TYPES.each do |type, downloader_class|
|
||||||
records.each do |type, items|
|
download_type_images(type, downloader_class)
|
||||||
next if items.empty?
|
|
||||||
download_type_images(type, items)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def download_type_images(type, items)
|
def download_type_images(type, downloader_class)
|
||||||
if @verbose
|
records = (@new_records[type] || []) + (@updated_records[type] || [])
|
||||||
log_header "Processing #{type.pluralize} (#{items.size} records)...", "-"
|
return if records.empty?
|
||||||
puts "\n"
|
|
||||||
|
puts "\nDownloading #{type} images..." if @verbose
|
||||||
|
records.each do |record|
|
||||||
|
# Get the ID either from the granblue_id hash key (test mode) or method (normal mode)
|
||||||
|
id = record.respond_to?(:granblue_id) ? record.granblue_id : record[:granblue_id]
|
||||||
|
|
||||||
|
downloader = downloader_class.new(
|
||||||
|
id,
|
||||||
|
test_mode: @test_mode,
|
||||||
|
verbose: @verbose,
|
||||||
|
storage: @storage
|
||||||
|
)
|
||||||
|
downloader.download
|
||||||
end
|
end
|
||||||
|
|
||||||
download_options = {
|
|
||||||
test_mode: @test_mode,
|
|
||||||
verbose: @verbose,
|
|
||||||
storage: @storage
|
|
||||||
}
|
|
||||||
|
|
||||||
items.each do |item|
|
|
||||||
id = @test_mode ? item[:granblue_id] : item.id
|
|
||||||
download_single_image(type, id, download_options)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def download_single_image(type, id, options)
|
def download_single_image(type, id, options)
|
||||||
|
|
|
||||||
|
|
@ -105,11 +105,7 @@ module PostDeployment
|
||||||
count = items.size
|
count = items.size
|
||||||
puts "\n#{type.capitalize}: #{count} #{label.downcase} #{count == 1 ? 'record' : 'records'}"
|
puts "\n#{type.capitalize}: #{count} #{label.downcase} #{count == 1 ? 'record' : 'records'}"
|
||||||
items.each do |item|
|
items.each do |item|
|
||||||
if @test_mode
|
puts " - #{item[:name_en]} (ID: #{item[:granblue_id]})"
|
||||||
puts " - #{item[:name_en]} (ID: #{item[:granblue_id]})"
|
|
||||||
else
|
|
||||||
puts " - #{item.name_en} (ID: #{item.granblue_id})"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue