Merge pull request #87 from adracea/master

Add padding format option
This commit is contained in:
ByteDream 2022-12-19 17:47:39 +01:00 committed by GitHub
commit 86759557fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 23 deletions

View file

@ -58,16 +58,18 @@ pub struct Archive {
#[arg(help = "Name of the output file")] #[arg(help = "Name of the output file")]
#[arg(long_help = "Name of the output file.\ #[arg(long_help = "Name of the output file.\
If you use one of the following pattern they will get replaced:\n \ If you use one of the following pattern they will get replaced:\n \
{title} Title of the video\n \ {title} Title of the video\n \
{series_name} Name of the series\n \ {series_name} Name of the series\n \
{season_name} Name of the season\n \ {season_name} Name of the season\n \
{audio} Audio language of the video\n \ {audio} Audio language of the video\n \
{resolution} Resolution of the video\n \ {resolution} Resolution of the video\n \
{season_number} Number of the season\n \ {padded_season_number} Number of the season padded to double digits\n \
{episode_number} Number of the episode\n \ {season_number} Number of the season\n \
{series_id} ID of the series\n \ {padded_episode_number} Number of the episode padded to double digits\n \
{season_id} ID of the season\n \ {episode_number} Number of the episode\n \
{episode_id} ID of the episode")] {series_id} ID of the series\n \
{season_id} ID of the season\n \
{episode_id} ID of the episode")]
#[arg(short, long, default_value = "{title}.mkv")] #[arg(short, long, default_value = "{title}.mkv")]
output: String, output: String,

View file

@ -36,16 +36,18 @@ pub struct Download {
#[arg(help = "Name of the output file")] #[arg(help = "Name of the output file")]
#[arg(long_help = "Name of the output file.\ #[arg(long_help = "Name of the output file.\
If you use one of the following pattern they will get replaced:\n \ If you use one of the following pattern they will get replaced:\n \
{title} Title of the video\n \ {title} Title of the video\n \
{series_name} Name of the series\n \ {series_name} Name of the series\n \
{season_name} Name of the season\n \ {season_name} Name of the season\n \
{audio} Audio language of the video\n \ {audio} Audio language of the video\n \
{resolution} Resolution of the video\n \ {resolution} Resolution of the video\n \
{season_number} Number of the season\n \ {padded_season_number} Number of the season padded to double digits\n \
{episode_number} Number of the episode\n \ {season_number} Number of the season\n \
{series_id} ID of the series\n \ {padded_episode_number} Number of the episode padded to double digits\n \
{season_id} ID of the season\n \ {episode_number} Number of the episode\n \
{episode_id} ID of the episode")] {series_id} ID of the series\n \
{season_id} ID of the season\n \
{episode_id} ID of the episode")]
#[arg(short, long, default_value = "{title}.ts")] #[arg(short, long, default_value = "{title}.ts")]
output: String, output: String,

View file

@ -77,9 +77,26 @@ pub fn format_string(s: String, format: &Format, sanitize: bool) -> String {
.replace("{series_name}", &sanitize_func(&format.series_name)) .replace("{series_name}", &sanitize_func(&format.series_name))
.replace("{season_name}", &sanitize_func(&format.season_title)) .replace("{season_name}", &sanitize_func(&format.season_title))
.replace("{audio}", &sanitize_func(&format.audio.to_string())) .replace("{audio}", &sanitize_func(&format.audio.to_string()))
.replace("{resolution}", &sanitize_func(&format.stream.resolution.to_string())) .replace(
.replace("{season_number}", &sanitize_func(&format.season_number.to_string())) "{resolution}",
.replace("{episode_number}", &sanitize_func(&format.number.to_string())) &sanitize_func(&format.stream.resolution.to_string()),
)
.replace(
"{padded_season_number}",
&sanitize_func(&format!("{:0>2}", format.season_number.to_string())),
)
.replace(
"{season_number}",
&sanitize_func(&format.season_number.to_string()),
)
.replace(
"{padded_episode_number}",
&sanitize_func(&format!("{:0>2}", format.number.to_string())),
)
.replace(
"{episode_number}",
&sanitize_func(&format.number.to_string()),
)
.replace("{series_id}", &sanitize_func(&format.series_id)) .replace("{series_id}", &sanitize_func(&format.series_id))
.replace("{season_id}", &sanitize_func(&format.season_id)) .replace("{season_id}", &sanitize_func(&format.season_id))
.replace("{episode_id}", &sanitize_func(&format.id)) .replace("{episode_id}", &sanitize_func(&format.id))