Only prompt for Neologin cookie once when running rails neopets:import
This commit is contained in:
parent
a57b3629db
commit
ec0b8d9cb9
3 changed files with 28 additions and 8 deletions
|
@ -1,7 +1,31 @@
|
|||
module Neologin
|
||||
def self.cookie
|
||||
raise "must run neopets:import:neologin first" if @cookie.nil?
|
||||
@cookie
|
||||
end
|
||||
|
||||
def self.cookie?
|
||||
@cookie.present?
|
||||
end
|
||||
|
||||
def self.cookie=(new_cookie)
|
||||
@cookie = new_cookie
|
||||
end
|
||||
end
|
||||
|
||||
namespace :neopets do
|
||||
task :import => [
|
||||
"neopets:import:neologin",
|
||||
"neopets:import:nc_mall",
|
||||
"neopets:import:rainbow_pool",
|
||||
"neopets:import:styling_studio",
|
||||
]
|
||||
|
||||
namespace :import do
|
||||
task :neologin do
|
||||
unless Neologin.cookie?
|
||||
Neologin.cookie = STDIN.getpass("Neologin cookie: ")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,9 +3,7 @@ require "async/http/internet/instance"
|
|||
|
||||
namespace "neopets:import" do
|
||||
desc "Import all basic image hashes from the Rainbow Pool, onto PetTypes"
|
||||
task :rainbow_pool => :environment do
|
||||
neologin = STDIN.getpass("Neologin cookie: ")
|
||||
|
||||
task :rainbow_pool => ["neopets:import:neologin", :environment] do
|
||||
puts "Importing from Rainbow Pool…"
|
||||
|
||||
all_pet_types = PetType.all.to_a
|
||||
|
@ -18,7 +16,7 @@ namespace "neopets:import" do
|
|||
Species.order(:name).each do |species|
|
||||
begin
|
||||
hashes_by_color_name = RainbowPool.load_hashes_for_species(
|
||||
species.id, neologin)
|
||||
species.id, Neologin.cookie)
|
||||
rescue => error
|
||||
puts "Failed to load #{species.name} page, skipping: #{error.message}"
|
||||
next
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
namespace "neopets:import" do
|
||||
desc "Import alt style info from the NC Styling Studio"
|
||||
task :styling_studio => :environment do
|
||||
neologin = STDIN.getpass("Neologin cookie: ")
|
||||
|
||||
task :styling_studio => ["neopets:import:neologin", :environment] do
|
||||
puts "Importing from Styling Studio…"
|
||||
|
||||
all_species = Species.order(:name).to_a
|
||||
|
@ -21,7 +19,7 @@ namespace "neopets:import" do
|
|||
begin
|
||||
styles_by_species_id[species.id] = Neopets::NCMall.load_styles(
|
||||
species_id: species.id,
|
||||
neologin:,
|
||||
neologin: Neologin.cookie,
|
||||
)
|
||||
rescue => error
|
||||
puts "\n⚠️ Error loading for #{species.human_name}, skipping: #{error.message}"
|
||||
|
|
Loading…
Reference in a new issue