1
Fork 0
mirror of https://github.com/redstrate/Auracite.git synced 2025-05-01 16:37:45 +00:00

Add an --id parameter for manually typing the Lodestone ID

This is useful as Auracite has no name conflict resolution yet.
This commit is contained in:
Joshua Goins 2025-04-28 15:59:13 -04:00
parent ed4d7b9c82
commit 614985e5d1
2 changed files with 43 additions and 12 deletions

View file

@ -31,7 +31,7 @@ pub mod bridge {
} }
} }
use crate::archive_character_blocking; use crate::{archive_character_blocking, search_character_blocking};
use auracite::ArchiveError; use auracite::ArchiveError;
use cxx_kde_frameworks::ki18n::i18n; use cxx_kde_frameworks::ki18n::i18n;
use cxx_qt_lib::QString; use cxx_qt_lib::QString;
@ -47,11 +47,12 @@ impl bridge::Backend {
use_dalamud: bool, use_dalamud: bool,
filename: &QString, filename: &QString,
) { ) {
match archive_character_blocking( let Some(id) = search_character_blocking(&character_name.to_string()) else {
&character_name.to_string(), self.archive_failed(&i18n("Character not found"));
use_dalamud, return;
&filename.to_string(), };
) {
match archive_character_blocking(id, use_dalamud, &filename.to_string()) {
Ok(_) => self.archive_successful(), Ok(_) => self.archive_successful(),
Err(err) => { Err(err) => {
match err { match err {

View file

@ -11,8 +11,17 @@ use std::fs::write;
pub mod bridge; pub mod bridge;
fn search_character_blocking(character_name: &String) -> Option<u64> {
let rt = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.ok()?;
rt.block_on(search_character(&character_name.to_string()))
}
fn archive_character_blocking( fn archive_character_blocking(
character_name: &String, id: u64,
use_dalamud: bool, use_dalamud: bool,
filename: &String, filename: &String,
) -> Result<(), ArchiveError> { ) -> Result<(), ArchiveError> {
@ -21,10 +30,6 @@ fn archive_character_blocking(
.build() .build()
.map_err(|_| ArchiveError::UnknownError)?; .map_err(|_| ArchiveError::UnknownError)?;
let id = rt
.block_on(search_character(&character_name.to_string()))
.expect("Character not found!");
let inner = rt.block_on(archive_character(id, use_dalamud))?; let inner = rt.block_on(archive_character(id, use_dalamud))?;
write(filename, inner)?; write(filename, inner)?;
@ -73,6 +78,11 @@ fn main() {
name_option.set_value_name(&QString::from("name")); name_option.set_value_name(&QString::from("name"));
command_line_parser.add_option(&name_option); command_line_parser.add_option(&name_option);
let mut id_option = QCommandLineOption::from(&QString::from("id"));
id_option.set_description(&i18n("The character's Lodestone ID."));
id_option.set_value_name(&QString::from("id"));
command_line_parser.add_option(&id_option);
let mut dalamud_option = QCommandLineOption::from(&QString::from("dalamud")); let mut dalamud_option = QCommandLineOption::from(&QString::from("dalamud"));
dalamud_option.set_description(&i18n( dalamud_option.set_description(&i18n(
"Whether to import more data from the Auracite Dalamud plugin.", "Whether to import more data from the Auracite Dalamud plugin.",
@ -93,8 +103,10 @@ fn main() {
println!("Downloading character data for {}...", character_name); println!("Downloading character data for {}...", character_name);
let id = search_character_blocking(&character_name).expect("Couldn't find character!");
archive_character_blocking( archive_character_blocking(
&character_name, id,
command_line_parser.is_set(&QString::from("dalamud")), command_line_parser.is_set(&QString::from("dalamud")),
&format!("{}.zip", character_name), &format!("{}.zip", character_name),
); );
@ -102,6 +114,24 @@ fn main() {
return; return;
} }
if command_line_parser.is_set(&QString::from("id")) {
let id = command_line_parser
.value(&QString::from("id"))
.to_string()
.parse()
.expect("Not a valid ID!");
println!("Downloading character data for {}...", id);
archive_character_blocking(
id,
command_line_parser.is_set(&QString::from("dalamud")),
&format!("{}.zip", id), // TODO: give it the character's name
);
return;
}
let mut engine = QQmlApplicationEngine::new(); let mut engine = QQmlApplicationEngine::new();
if let Some(mut engine) = engine.as_mut() { if let Some(mut engine) = engine.as_mut() {