From 2f090f3924fcaaa38129507771c969986edc4205 Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Sun, 29 Dec 2024 15:26:26 -0800 Subject: [PATCH] Oops, improve series name parsing in Styling Studio auto-importer Ahh right, that's part of why I skipped Prismatics: it's no longer true that the first word of the style is its series name. In this change, I try to parse out everything before the pet name part of the style name, and default to skipping it if we can't quite get it right. --- lib/tasks/neopets/import/styling_studio.rake | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/tasks/neopets/import/styling_studio.rake b/lib/tasks/neopets/import/styling_studio.rake index f9d86c2a..88606945 100644 --- a/lib/tasks/neopets/import/styling_studio.rake +++ b/lib/tasks/neopets/import/styling_studio.rake @@ -55,13 +55,18 @@ namespace "neopets:import" do "#{record.thumbnail_url.inspect} -> #{style[:image].inspect}" end - new_series_name = style[:name].match(/\A\S+/)[0] # first word - if !record.real_series_name? - record.series_name = new_series_name - puts "✅ [#{label}]: Series name is now #{new_series_name.inspect}" - elsif record.series_name != new_series_name - puts "⚠️ [#{label}: Series name may have changed, handle manually? " + - "#{record.series_name.inspect} -> #{new_series_name.inspect}" + if style[:name].end_with?(record.pet_name) + new_series_name = style[:name].split(record.pet_name).first.strip + if !record.real_series_name? + record.series_name = new_series_name + puts "✅ [#{label}]: Series name is now #{new_series_name.inspect}" + elsif record.series_name != new_series_name + puts "⚠️ [#{label}: Series name may have changed, handle manually? " + + "#{record.series_name.inspect} -> #{new_series_name.inspect}" + end + else + puts "⚠️ [#{label}: Unable to detect series name, handle manually? " + + "#{record.full_name.inspect} -> #{style[:name].inspect}" end if record.changed?