Skip to content
This repository has been archived by the owner on Jul 4, 2024. It is now read-only.

Commit

Permalink
Rework episode filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
bytedream committed Jun 13, 2024
1 parent e7ac6d8 commit 127e6d9
Show file tree
Hide file tree
Showing 11 changed files with 513 additions and 835 deletions.
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crunchy-cli-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ anyhow = "1.0"
async-speed-limit = "0.4"
clap = { version = "4.5", features = ["derive", "string"] }
chrono = "0.4"
crunchyroll-rs = { version = "0.11.3", features = ["experimental-stabilizations", "tower"] }
crunchyroll-rs = { version = "0.11.4", features = ["experimental-stabilizations", "tower"] }
ctrlc = "3.4"
dialoguer = { version = "0.11", default-features = false }
dirs = "5.0"
Expand Down
47 changes: 43 additions & 4 deletions crunchy-cli-core/src/archive/command.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use crate::archive::filter::ArchiveFilter;
use crate::utils::context::Context;
use crate::utils::download::{
DownloadBuilder, DownloadFormat, DownloadFormatMetadata, MergeBehavior,
};
use crate::utils::ffmpeg::FFmpegPreset;
use crate::utils::filter::Filter;
use crate::utils::filter::{Filter, FilterMediaScope};
use crate::utils::format::{Format, SingleFormat};
use crate::utils::locale::{all_locale_in_locales, resolve_locales, LanguageTagging};
use crate::utils::log::progress;
Expand Down Expand Up @@ -284,9 +283,49 @@ impl Execute for Archive {

for (i, (media_collection, url_filter)) in parsed_urls.into_iter().enumerate() {
let progress_handler = progress!("Fetching series details");
let single_format_collection = ArchiveFilter::new(
let single_format_collection = Filter::new(
url_filter,
self.clone(),
self.audio.clone(),
self.subtitle.clone(),
|scope, locales| {
let audios = locales.into_iter().map(|l| l.to_string()).collect::<Vec<String>>().join(", ");
match scope {
FilterMediaScope::Series(series) => warn!("Series {} is not available with {} audio", series.title, audios),
FilterMediaScope::Season(season) => warn!("Season {} is not available with {} audio", season.season_number, audios),
FilterMediaScope::Episode(episodes) => {
if episodes.len() == 1 {
warn!("Episode {} is not available with {} audio", episodes[0].sequence_number, audios)
} else if episodes.len() == 2 {
warn!("Season {} is only available with {} audio from episode {} to {}", episodes[0].season_number, audios, episodes[0].sequence_number, episodes[1].sequence_number)
} else {
unimplemented!()
}
}
}
Ok(true)
},
|scope, locales| {
let subtitles = locales.into_iter().map(|l| l.to_string()).collect::<Vec<String>>().join(", ");
match scope {
FilterMediaScope::Series(series) => warn!("Series {} is not available with {} subtitles", series.title, subtitles),
FilterMediaScope::Season(season) => warn!("Season {} is not available with {} subtitles", season.season_number, subtitles),
FilterMediaScope::Episode(episodes) => {
if episodes.len() == 1 {
warn!("Episode {} of season {} is not available with {} subtitles", episodes[0].sequence_number, episodes[0].season_title, subtitles)
} else if episodes.len() == 2 {
warn!("Season {} of season {} is only available with {} subtitles from episode {} to {}", episodes[0].season_number, episodes[0].season_title, subtitles, episodes[0].sequence_number, episodes[1].sequence_number)
} else {
unimplemented!()
}
}
}
Ok(true)
},
|season| {
warn!("Skipping premium episodes in season {season}");
Ok(())
},
Format::has_relative_fmt(&self.output),
!self.yes,
self.skip_specials,
ctx.crunchy.premium().await,
Expand Down
Loading

0 comments on commit 127e6d9

Please sign in to comment.