mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 04:02:00 -06:00
Change delimiter of audio template option to _ and make it configurable via the CRUNCHY_CLI_FORMAT_DELIMITER env variable (#311)
This commit is contained in:
parent
f8309f2e80
commit
0f06c7ac71
1 changed files with 39 additions and 11 deletions
|
|
@ -8,6 +8,7 @@ use crunchyroll_rs::{Concert, Episode, Locale, MediaCollection, Movie, MusicVide
|
||||||
use log::{debug, info};
|
use log::{debug, info};
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
use std::env;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
|
@ -420,11 +421,18 @@ impl Format {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(a, _)| a.to_string())
|
.map(|(a, _)| a.to_string())
|
||||||
.collect::<Vec<String>>()
|
.collect::<Vec<String>>()
|
||||||
.join("|"),
|
.join(
|
||||||
true, universal,
|
&env::var("CRUNCHY_CLI_FORMAT_DELIMITER")
|
||||||
|
.map_or("_".to_string(), |e| e),
|
||||||
|
),
|
||||||
|
true,
|
||||||
|
universal,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.replace("{resolution}", &sanitize(self.resolution.to_string(), true, universal))
|
.replace(
|
||||||
|
"{resolution}",
|
||||||
|
&sanitize(self.resolution.to_string(), true, universal),
|
||||||
|
)
|
||||||
.replace(
|
.replace(
|
||||||
"{width}",
|
"{width}",
|
||||||
&sanitize(self.resolution.width.to_string(), true, universal),
|
&sanitize(self.resolution.width.to_string(), true, universal),
|
||||||
|
|
@ -434,12 +442,21 @@ impl Format {
|
||||||
&sanitize(self.resolution.height.to_string(), true, universal),
|
&sanitize(self.resolution.height.to_string(), true, universal),
|
||||||
)
|
)
|
||||||
.replace("{series_id}", &sanitize(&self.series_id, true, universal))
|
.replace("{series_id}", &sanitize(&self.series_id, true, universal))
|
||||||
.replace("{series_name}", &sanitize(&self.series_name, true, universal))
|
.replace(
|
||||||
|
"{series_name}",
|
||||||
|
&sanitize(&self.series_name, true, universal),
|
||||||
|
)
|
||||||
.replace("{season_id}", &sanitize(&self.season_id, true, universal))
|
.replace("{season_id}", &sanitize(&self.season_id, true, universal))
|
||||||
.replace("{season_name}", &sanitize(&self.season_title, true, universal))
|
.replace(
|
||||||
|
"{season_name}",
|
||||||
|
&sanitize(&self.season_title, true, universal),
|
||||||
|
)
|
||||||
.replace(
|
.replace(
|
||||||
"{season_number}",
|
"{season_number}",
|
||||||
&format!("{:0>2}", sanitize(self.season_number.to_string(), true, universal)),
|
&format!(
|
||||||
|
"{:0>2}",
|
||||||
|
sanitize(self.season_number.to_string(), true, universal)
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.replace("{episode_id}", &sanitize(&self.episode_id, true, universal))
|
.replace("{episode_id}", &sanitize(&self.episode_id, true, universal))
|
||||||
.replace(
|
.replace(
|
||||||
|
|
@ -452,13 +469,17 @@ impl Format {
|
||||||
"{:0>2}",
|
"{:0>2}",
|
||||||
sanitize(
|
sanitize(
|
||||||
self.relative_episode_number.unwrap_or_default().to_string(),
|
self.relative_episode_number.unwrap_or_default().to_string(),
|
||||||
true, universal,
|
true,
|
||||||
|
universal,
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.replace(
|
.replace(
|
||||||
"{sequence_number}",
|
"{sequence_number}",
|
||||||
&format!("{:0>2}", sanitize(self.sequence_number.to_string(), true, universal)),
|
&format!(
|
||||||
|
"{:0>2}",
|
||||||
|
sanitize(self.sequence_number.to_string(), true, universal)
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.replace(
|
.replace(
|
||||||
"{relative_sequence_number}",
|
"{relative_sequence_number}",
|
||||||
|
|
@ -468,7 +489,8 @@ impl Format {
|
||||||
self.relative_sequence_number
|
self.relative_sequence_number
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
.to_string(),
|
.to_string(),
|
||||||
true, universal,
|
true,
|
||||||
|
universal,
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
@ -478,11 +500,17 @@ impl Format {
|
||||||
)
|
)
|
||||||
.replace(
|
.replace(
|
||||||
"{release_month}",
|
"{release_month}",
|
||||||
&format!("{:0>2}", sanitize(self.release_month.to_string(), true, universal)),
|
&format!(
|
||||||
|
"{:0>2}",
|
||||||
|
sanitize(self.release_month.to_string(), true, universal)
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.replace(
|
.replace(
|
||||||
"{release_day}",
|
"{release_day}",
|
||||||
&format!("{:0>2}", sanitize(self.release_day.to_string(), true, universal)),
|
&format!(
|
||||||
|
"{:0>2}",
|
||||||
|
sanitize(self.release_day.to_string(), true, universal)
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
PathBuf::from(path)
|
PathBuf::from(path)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue