Skip to content

Commit

Permalink
Fix wrong audio and subtitle video reference number (#384)
Browse files Browse the repository at this point in the history
  • Loading branch information
bytedream committed Apr 23, 2024
1 parent 777b39a commit 541f0e2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions crunchy-cli-core/src/utils/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,15 @@ struct FFmpegAudioMeta {
path: TempPath,
locale: Locale,
start_time: Option<TimeDelta>,
video_idx: usize,
}

struct FFmpegSubtitleMeta {
path: TempPath,
locale: Locale,
cc: bool,
start_time: Option<TimeDelta>,
video_idx: usize,
}

pub struct DownloadFormat {
Expand Down Expand Up @@ -433,7 +435,7 @@ impl Downloader {
}

// downloads all audios
for format in &self.formats {
for (i, format) in self.formats.iter().enumerate() {
for (j, (stream_data, locale)) in format.audios.iter().enumerate() {
let path = self
.download_audio(
Expand All @@ -445,6 +447,7 @@ impl Downloader {
path,
locale: locale.clone(),
start_time: audio_offsets.get(&j).cloned(),
video_idx: i,
})
}
}
Expand Down Expand Up @@ -507,6 +510,7 @@ impl Downloader {
locale: subtitle.locale.clone(),
cc: !not_cc,
start_time: subtitle_offsets.get(&j).cloned(),
video_idx: i,
})
}
}
Expand Down Expand Up @@ -632,7 +636,11 @@ impl Downloader {
if videos.len() == 1 {
meta.locale.to_human_readable()
} else {
format!("{} [Video: #{}]", meta.locale.to_human_readable(), i + 1,)
format!(
"{} [Video: #{}]",
meta.locale.to_human_readable(),
meta.video_idx + 1
)
}
),
]);
Expand Down Expand Up @@ -679,7 +687,7 @@ impl Downloader {
title += " (CC)"
}
if videos.len() > 1 {
title += &format!(" [Video: #{}]", i + 1)
title += &format!(" [Video: #{}]", meta.video_idx + 1)
}
title
}),
Expand Down

0 comments on commit 541f0e2

Please sign in to comment.