mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 12:12:00 -06:00
Add more output format options (#284)
This commit is contained in:
parent
0da81a4814
commit
19935df545
3 changed files with 79 additions and 5 deletions
|
|
@ -15,7 +15,7 @@ use anyhow::Result;
|
||||||
use chrono::Duration;
|
use chrono::Duration;
|
||||||
use crunchyroll_rs::media::{Resolution, Subtitle};
|
use crunchyroll_rs::media::{Resolution, Subtitle};
|
||||||
use crunchyroll_rs::Locale;
|
use crunchyroll_rs::Locale;
|
||||||
use log::debug;
|
use log::{debug, warn};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
|
@ -43,12 +43,16 @@ pub struct Archive {
|
||||||
{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 \
|
{width} → Width of the video\n \
|
||||||
|
{height} → Height of the video\n \
|
||||||
{season_number} → Number of the season\n \
|
{season_number} → Number of the season\n \
|
||||||
{episode_number} → Number of the episode\n \
|
{episode_number} → Number of the episode\n \
|
||||||
{relative_episode_number} → Number of the episode relative to its season\n \
|
{relative_episode_number} → Number of the episode relative to its season\n \
|
||||||
{sequence_number} → Like '{episode_number}' but without possible non-number characters\n \
|
{sequence_number} → Like '{episode_number}' but without possible non-number characters\n \
|
||||||
{relative_sequence_number} → Like '{relative_episode_number}' but with support for episode 0's and .5's\n \
|
{relative_sequence_number} → Like '{relative_episode_number}' but with support for episode 0's and .5's\n \
|
||||||
|
{release_year} → Release year of the video\n \
|
||||||
|
{release_month} → Release month of the video\n \
|
||||||
|
{release_day} → Release day of the video\n \
|
||||||
{series_id} → ID of the series\n \
|
{series_id} → ID of the series\n \
|
||||||
{season_id} → ID of the season\n \
|
{season_id} → ID of the season\n \
|
||||||
{episode_id} → ID of the episode")]
|
{episode_id} → ID of the episode")]
|
||||||
|
|
@ -157,6 +161,15 @@ impl Execute for Archive {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.output.contains("{resolution}")
|
||||||
|
|| self
|
||||||
|
.output_specials
|
||||||
|
.as_ref()
|
||||||
|
.map_or(false, |os| os.contains("{resolution}"))
|
||||||
|
{
|
||||||
|
warn!("The '{{resolution}}' format option is deprecated and will be removed in a future version. Please use '{{width}}' and '{{height}}' instead")
|
||||||
|
}
|
||||||
|
|
||||||
self.audio = all_locale_in_locales(self.audio.clone());
|
self.audio = all_locale_in_locales(self.audio.clone());
|
||||||
self.subtitle = all_locale_in_locales(self.subtitle.clone());
|
self.subtitle = all_locale_in_locales(self.subtitle.clone());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,12 +39,16 @@ pub struct Download {
|
||||||
{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 \
|
{width} → Width of the video\n \
|
||||||
|
{height} → Height of the video\n \
|
||||||
{season_number} → Number of the season\n \
|
{season_number} → Number of the season\n \
|
||||||
{episode_number} → Number of the episode\n \
|
{episode_number} → Number of the episode\n \
|
||||||
{relative_episode_number} → Number of the episode relative to its season\n \
|
{relative_episode_number} → Number of the episode relative to its season\n \
|
||||||
{sequence_number} → Like '{episode_number}' but without possible non-number characters\n \
|
{sequence_number} → Like '{episode_number}' but without possible non-number characters\n \
|
||||||
{relative_sequence_number} → Like '{relative_episode_number}' but with support for episode 0's and .5's\n \
|
{relative_sequence_number} → Like '{relative_episode_number}' but with support for episode 0's and .5's\n \
|
||||||
|
{release_year} → Release year of the video\n \
|
||||||
|
{release_month} → Release month of the video\n \
|
||||||
|
{release_day} → Release day of the video\n \
|
||||||
{series_id} → ID of the series\n \
|
{series_id} → ID of the series\n \
|
||||||
{season_id} → ID of the season\n \
|
{season_id} → ID of the season\n \
|
||||||
{episode_id} → ID of the episode")]
|
{episode_id} → ID of the episode")]
|
||||||
|
|
@ -153,6 +157,15 @@ impl Execute for Download {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.output.contains("{resolution}")
|
||||||
|
|| self
|
||||||
|
.output_specials
|
||||||
|
.as_ref()
|
||||||
|
.map_or(false, |os| os.contains("{resolution}"))
|
||||||
|
{
|
||||||
|
warn!("The '{{resolution}}' format option is deprecated and will be removed in a future version. Please use '{{width}}' and '{{height}}' instead")
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use crate::utils::filter::real_dedup_vec;
|
||||||
use crate::utils::log::tab_info;
|
use crate::utils::log::tab_info;
|
||||||
use crate::utils::os::{is_special_file, sanitize};
|
use crate::utils::os::{is_special_file, sanitize};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use chrono::Duration;
|
use chrono::{Datelike, Duration};
|
||||||
use crunchyroll_rs::media::{Resolution, Stream, Subtitle, VariantData};
|
use crunchyroll_rs::media::{Resolution, Stream, Subtitle, VariantData};
|
||||||
use crunchyroll_rs::{Concert, Episode, Locale, MediaCollection, Movie, MusicVideo};
|
use crunchyroll_rs::{Concert, Episode, Locale, MediaCollection, Movie, MusicVideo};
|
||||||
use log::{debug, info};
|
use log::{debug, info};
|
||||||
|
|
@ -17,6 +17,10 @@ pub struct SingleFormat {
|
||||||
pub title: String,
|
pub title: String,
|
||||||
pub description: String,
|
pub description: String,
|
||||||
|
|
||||||
|
pub release_year: u64,
|
||||||
|
pub release_month: u64,
|
||||||
|
pub release_day: u64,
|
||||||
|
|
||||||
pub audio: Locale,
|
pub audio: Locale,
|
||||||
pub subtitles: Vec<Locale>,
|
pub subtitles: Vec<Locale>,
|
||||||
|
|
||||||
|
|
@ -60,6 +64,9 @@ impl SingleFormat {
|
||||||
},
|
},
|
||||||
title: episode.title.clone(),
|
title: episode.title.clone(),
|
||||||
description: episode.description.clone(),
|
description: episode.description.clone(),
|
||||||
|
release_year: episode.episode_air_date.year() as u64,
|
||||||
|
release_month: episode.episode_air_date.month() as u64,
|
||||||
|
release_day: episode.episode_air_date.day() as u64,
|
||||||
audio: episode.audio_locale.clone(),
|
audio: episode.audio_locale.clone(),
|
||||||
subtitles,
|
subtitles,
|
||||||
series_id: episode.series_id.clone(),
|
series_id: episode.series_id.clone(),
|
||||||
|
|
@ -86,6 +93,9 @@ impl SingleFormat {
|
||||||
identifier: movie.id.clone(),
|
identifier: movie.id.clone(),
|
||||||
title: movie.title.clone(),
|
title: movie.title.clone(),
|
||||||
description: movie.description.clone(),
|
description: movie.description.clone(),
|
||||||
|
release_year: movie.free_available_date.year() as u64,
|
||||||
|
release_month: movie.free_available_date.month() as u64,
|
||||||
|
release_day: movie.free_available_date.day() as u64,
|
||||||
audio: Locale::ja_JP,
|
audio: Locale::ja_JP,
|
||||||
subtitles,
|
subtitles,
|
||||||
series_id: movie.movie_listing_id.clone(),
|
series_id: movie.movie_listing_id.clone(),
|
||||||
|
|
@ -108,6 +118,9 @@ impl SingleFormat {
|
||||||
identifier: music_video.id.clone(),
|
identifier: music_video.id.clone(),
|
||||||
title: music_video.title.clone(),
|
title: music_video.title.clone(),
|
||||||
description: music_video.description.clone(),
|
description: music_video.description.clone(),
|
||||||
|
release_year: music_video.original_release.year() as u64,
|
||||||
|
release_month: music_video.original_release.month() as u64,
|
||||||
|
release_day: music_video.original_release.day() as u64,
|
||||||
audio: Locale::ja_JP,
|
audio: Locale::ja_JP,
|
||||||
subtitles: vec![],
|
subtitles: vec![],
|
||||||
series_id: music_video.id.clone(),
|
series_id: music_video.id.clone(),
|
||||||
|
|
@ -130,6 +143,9 @@ impl SingleFormat {
|
||||||
identifier: concert.id.clone(),
|
identifier: concert.id.clone(),
|
||||||
title: concert.title.clone(),
|
title: concert.title.clone(),
|
||||||
description: concert.description.clone(),
|
description: concert.description.clone(),
|
||||||
|
release_year: concert.original_release.year() as u64,
|
||||||
|
release_month: concert.original_release.month() as u64,
|
||||||
|
release_day: concert.original_release.day() as u64,
|
||||||
audio: Locale::ja_JP,
|
audio: Locale::ja_JP,
|
||||||
subtitles: vec![],
|
subtitles: vec![],
|
||||||
series_id: concert.id.clone(),
|
series_id: concert.id.clone(),
|
||||||
|
|
@ -324,9 +340,16 @@ pub struct Format {
|
||||||
|
|
||||||
pub locales: Vec<(Locale, Vec<Locale>)>,
|
pub locales: Vec<(Locale, Vec<Locale>)>,
|
||||||
|
|
||||||
|
// deprecated
|
||||||
pub resolution: Resolution,
|
pub resolution: Resolution,
|
||||||
|
pub width: u64,
|
||||||
|
pub height: u64,
|
||||||
pub fps: f64,
|
pub fps: f64,
|
||||||
|
|
||||||
|
pub release_year: u64,
|
||||||
|
pub release_month: u64,
|
||||||
|
pub release_day: u64,
|
||||||
|
|
||||||
pub series_id: String,
|
pub series_id: String,
|
||||||
pub series_name: String,
|
pub series_name: String,
|
||||||
|
|
||||||
|
|
@ -364,8 +387,13 @@ impl Format {
|
||||||
title: first_format.title,
|
title: first_format.title,
|
||||||
description: first_format.description,
|
description: first_format.description,
|
||||||
locales,
|
locales,
|
||||||
resolution: first_stream.resolution,
|
resolution: first_stream.resolution.clone(),
|
||||||
|
width: first_stream.resolution.width,
|
||||||
|
height: first_stream.resolution.height,
|
||||||
fps: first_stream.fps,
|
fps: first_stream.fps,
|
||||||
|
release_year: first_format.release_year,
|
||||||
|
release_month: first_format.release_month,
|
||||||
|
release_day: first_format.release_day,
|
||||||
series_id: first_format.series_id,
|
series_id: first_format.series_id,
|
||||||
series_name: first_format.series_name,
|
series_name: first_format.series_name,
|
||||||
season_id: first_format.season_id,
|
season_id: first_format.season_id,
|
||||||
|
|
@ -396,6 +424,14 @@ impl Format {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.replace("{resolution}", &sanitize(self.resolution.to_string(), true))
|
.replace("{resolution}", &sanitize(self.resolution.to_string(), true))
|
||||||
|
.replace(
|
||||||
|
"{width}",
|
||||||
|
&sanitize(self.resolution.width.to_string(), true),
|
||||||
|
)
|
||||||
|
.replace(
|
||||||
|
"{height}",
|
||||||
|
&sanitize(self.resolution.height.to_string(), true),
|
||||||
|
)
|
||||||
.replace("{series_id}", &sanitize(&self.series_id, true))
|
.replace("{series_id}", &sanitize(&self.series_id, true))
|
||||||
.replace("{series_name}", &sanitize(&self.series_name, true))
|
.replace("{series_name}", &sanitize(&self.series_name, true))
|
||||||
.replace("{season_id}", &sanitize(&self.season_id, true))
|
.replace("{season_id}", &sanitize(&self.season_id, true))
|
||||||
|
|
@ -434,6 +470,18 @@ impl Format {
|
||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
)
|
||||||
|
.replace(
|
||||||
|
"{release_year}",
|
||||||
|
&sanitize(self.release_year.to_string(), true),
|
||||||
|
)
|
||||||
|
.replace(
|
||||||
|
"{release_month}",
|
||||||
|
&format!("{:0>2}", sanitize(self.release_month.to_string(), true)),
|
||||||
|
)
|
||||||
|
.replace(
|
||||||
|
"{release_day}",
|
||||||
|
&format!("{:0>2}", sanitize(self.release_day.to_string(), true)),
|
||||||
);
|
);
|
||||||
|
|
||||||
PathBuf::from(path)
|
PathBuf::from(path)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue