~aleteoryx/pjsekai_emote_packs

c1b79d4c44d1d1ebdfbdecd4d654defdebe0e9a2 — Aleteoryx 10 months ago 2d8193c
that's that
2 files changed, 28 insertions(+), 23 deletions(-)

M README.md
M src/main.rs
M README.md => README.md +4 -3
@@ 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*

M src/main.rs => src/main.rs +24 -20
@@ 104,28 104,31 @@ fn handle_region<H: Helpers>(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<String, String> = 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<H: Helpers>(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<H: Helpers>(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. <https:///sekai.best>".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()
      });
  }