Fix wrong audio and subtitle video reference number (#384)

This commit is contained in:
bytedream 2024-04-23 16:00:42 +02:00
parent 777b39aba1
commit 541f0e2747

View file

@ -128,6 +128,7 @@ struct FFmpegAudioMeta {
path: TempPath, path: TempPath,
locale: Locale, locale: Locale,
start_time: Option<TimeDelta>, start_time: Option<TimeDelta>,
video_idx: usize,
} }
struct FFmpegSubtitleMeta { struct FFmpegSubtitleMeta {
@ -135,6 +136,7 @@ struct FFmpegSubtitleMeta {
locale: Locale, locale: Locale,
cc: bool, cc: bool,
start_time: Option<TimeDelta>, start_time: Option<TimeDelta>,
video_idx: usize,
} }
pub struct DownloadFormat { pub struct DownloadFormat {
@ -433,7 +435,7 @@ impl Downloader {
} }
// downloads all audios // 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() { for (j, (stream_data, locale)) in format.audios.iter().enumerate() {
let path = self let path = self
.download_audio( .download_audio(
@ -445,6 +447,7 @@ impl Downloader {
path, path,
locale: locale.clone(), locale: locale.clone(),
start_time: audio_offsets.get(&j).cloned(), start_time: audio_offsets.get(&j).cloned(),
video_idx: i,
}) })
} }
} }
@ -507,6 +510,7 @@ impl Downloader {
locale: subtitle.locale.clone(), locale: subtitle.locale.clone(),
cc: !not_cc, cc: !not_cc,
start_time: subtitle_offsets.get(&j).cloned(), start_time: subtitle_offsets.get(&j).cloned(),
video_idx: i,
}) })
} }
} }
@ -632,7 +636,11 @@ impl Downloader {
if videos.len() == 1 { if videos.len() == 1 {
meta.locale.to_human_readable() meta.locale.to_human_readable()
} else { } else {
format!("{} [Video: #{}]", meta.locale.to_human_readable(), i + 1,) format!(
"{} [Video: #{}]",
meta.locale.to_human_readable(),
meta.video_idx + 1
)
} }
), ),
]); ]);
@ -679,7 +687,7 @@ impl Downloader {
title += " (CC)" title += " (CC)"
} }
if videos.len() > 1 { if videos.len() > 1 {
title += &format!(" [Video: #{}]", i + 1) title += &format!(" [Video: #{}]", meta.video_idx + 1)
} }
title title
}), }),