mirror of
https://github.com/redstrate/Auracite.git
synced 2025-05-01 08:27:46 +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:
parent
ed4d7b9c82
commit
614985e5d1
2 changed files with 43 additions and 12 deletions
|
@ -31,7 +31,7 @@ pub mod bridge {
|
|||
}
|
||||
}
|
||||
|
||||
use crate::archive_character_blocking;
|
||||
use crate::{archive_character_blocking, search_character_blocking};
|
||||
use auracite::ArchiveError;
|
||||
use cxx_kde_frameworks::ki18n::i18n;
|
||||
use cxx_qt_lib::QString;
|
||||
|
@ -47,11 +47,12 @@ impl bridge::Backend {
|
|||
use_dalamud: bool,
|
||||
filename: &QString,
|
||||
) {
|
||||
match archive_character_blocking(
|
||||
&character_name.to_string(),
|
||||
use_dalamud,
|
||||
&filename.to_string(),
|
||||
) {
|
||||
let Some(id) = search_character_blocking(&character_name.to_string()) else {
|
||||
self.archive_failed(&i18n("Character not found"));
|
||||
return;
|
||||
};
|
||||
|
||||
match archive_character_blocking(id, use_dalamud, &filename.to_string()) {
|
||||
Ok(_) => self.archive_successful(),
|
||||
Err(err) => {
|
||||
match err {
|
||||
|
|
|
@ -11,8 +11,17 @@ use std::fs::write;
|
|||
|
||||
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(
|
||||
character_name: &String,
|
||||
id: u64,
|
||||
use_dalamud: bool,
|
||||
filename: &String,
|
||||
) -> Result<(), ArchiveError> {
|
||||
|
@ -21,10 +30,6 @@ fn archive_character_blocking(
|
|||
.build()
|
||||
.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))?;
|
||||
write(filename, inner)?;
|
||||
|
||||
|
@ -73,6 +78,11 @@ fn main() {
|
|||
name_option.set_value_name(&QString::from("name"));
|
||||
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"));
|
||||
dalamud_option.set_description(&i18n(
|
||||
"Whether to import more data from the Auracite Dalamud plugin.",
|
||||
|
@ -93,8 +103,10 @@ fn main() {
|
|||
|
||||
println!("Downloading character data for {}...", character_name);
|
||||
|
||||
let id = search_character_blocking(&character_name).expect("Couldn't find character!");
|
||||
|
||||
archive_character_blocking(
|
||||
&character_name,
|
||||
id,
|
||||
command_line_parser.is_set(&QString::from("dalamud")),
|
||||
&format!("{}.zip", character_name),
|
||||
);
|
||||
|
@ -102,6 +114,24 @@ fn main() {
|
|||
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();
|
||||
|
||||
if let Some(mut engine) = engine.as_mut() {
|
||||
|
|
Loading…
Add table
Reference in a new issue