From c1b79d4c44d1d1ebdfbdecd4d654defdebe0e9a2 Mon Sep 17 00:00:00 2001 From: Aleteoryx Date: Mon, 6 Jan 2025 15:35:58 -0500 Subject: [PATCH] that's that --- README.md | 7 ++++--- src/main.rs | 44 ++++++++++++++++++++++++-------------------- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 673963aa3817e569f7a7e5f12efb568f8a406124..b153ba2ce756acd29a480b8971b60c9dcd5f30f1 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ the main script does the following: - load in all images from the db in the git submodule -- prompt for an emoji slug on character-spoken stamps -- generate slugs for plaintext ones [TODO] -- create the repo files [TODO] +- for ones with only one character, generate emote packs +- generate a manifest + +the code here is terrible. i will refactor it *eventually* diff --git a/src/main.rs b/src/main.rs index 6d201856ca8146cdc88076f967f3e722536b75c4..47b32b2ade01e5270d0308ea0de55d1382eb9c96 100644 --- a/src/main.rs +++ b/src/main.rs @@ -104,28 +104,31 @@ fn handle_region(client: &Client, repo_dir: &Path, region: &'static let character = model::Character::from(cid); let character_slug = character.get_str("prefix").unwrap(); - let zip_path = character_out_dir.join(&character_slug).with_extension("zip"); - let mut writer = - ZipWriter::new( - File::create(&zip_path).unwrap()); let mut emotes: BTreeMap = BTreeMap::new(); - println!("Generating character stamp pack for {}...", character); - - for stamp in &character_stamps { - match stamp.character { - model::StampCharacter::Solo{ character_id } | - model::StampCharacter::SoloExtra{ character_id, .. } if character_id as u8 == cid => { - let character_slug = stamp.character.to_string() + "_" + &H::escape_name(&stamp.name); - writer.start_file(character_slug.clone() + ".png", options); - writer.write_all(&fs::read(cache_dir.join(&stamp.assetbundle_name).with_extension("png")).unwrap()); - emotes.insert(character_slug.clone(), character_slug + ".png"); - }, - _ => () + let zip_path = character_out_dir.join(&character_slug).with_extension("zip"); + { + let mut writer = + ZipWriter::new( + File::create(&zip_path).unwrap()); + + println!("Generating character stamp pack for {}...", character); + + for stamp in &character_stamps { + match stamp.character { + model::StampCharacter::Solo{ character_id } | + model::StampCharacter::SoloExtra{ character_id, .. } if character_id as u8 == cid => { + let character_slug = stamp.character.to_string() + "_" + &H::escape_name(&stamp.name); + writer.start_file(character_slug.clone() + ".png", options); + writer.write_all(&fs::read(cache_dir.join(&stamp.assetbundle_name).with_extension("png")).unwrap()); + emotes.insert(character_slug.clone(), character_slug + ".png"); + }, + _ => () + } } - } - writer.finish(); + writer.finish().unwrap(); + } File::create( character_out_dir @@ -135,6 +138,7 @@ fn handle_region(client: &Client, repo_dir: &Path, region: &'static .write_all(&serde_json::to_vec(&emotes).unwrap()); let pack_path = format!("Project SEKAI/{region}/characters/{character_slug}"); + let pack_uri_path = pack_path.replace(" ", "%20"); packs_list.insert( pack_path.clone(), @@ -142,9 +146,9 @@ fn handle_region(client: &Client, repo_dir: &Path, region: &'static name: format!("Project SEKAI ({region}): {}", character.get_str(&format!("name_{region}")).unwrap()), description: "Made possible by the sekai-viewer project. ".into(), homepage: "https://git.amehut.dev/~aleteoryx/pjsekai_emote_packs".into(), - files: BASE_DOWNLOAD_PATH.to_string() + &pack_path + ".json", - src: BASE_DOWNLOAD_PATH.to_string() + &pack_path + ".zip", + src: BASE_DOWNLOAD_PATH.to_string() + &pack_uri_path + ".zip", src_sha256: sha256::try_digest(&zip_path).unwrap(), + files: pack_uri_path + ".json", license: "N/A".into() }); }