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

Commit

Permalink
Fix japanese episode download if episode isn't available in specified…
Browse files Browse the repository at this point in the history
… language with archive (#207)
  • Loading branch information
bytedream committed May 24, 2023
1 parent b24827d commit 4bd172d
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion crunchy-cli-core/src/archive/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,34 @@ impl Filter for ArchiveFilter {

let mut episodes = vec![];
for season in seasons {
episodes.extend(season.episodes().await?)
let season_locale = season
.audio_locales
.get(0)
.cloned()
.unwrap_or(Locale::ja_JP);
let mut eps = season.episodes().await?;
let before_len = eps.len();
eps.retain(|e| e.audio_locale == season_locale);
if eps.len() != before_len {
if eps.len() == 0 {
if matches!(self.visited, Visited::Series) {
warn!(
"Season {} is not available with {} audio",
season.season_number, season_locale
)
}
} else {
let last_episode = eps.last().unwrap();
warn!(
"Season {} is only available with {} audio until episode {} ({})",
season.season_number,
season_locale,
last_episode.episode_number,
last_episode.title
)
}
}
episodes.extend(eps)
}

if Format::has_relative_episodes_fmt(&self.archive.output) {
Expand Down

0 comments on commit 4bd172d

Please sign in to comment.