use format idx instead of audio idx

This commit is contained in:
Simon Benezan 2024-05-07 15:18:44 +02:00
parent ab63dcd2e0
commit af4b1c7e41

View file

@ -321,8 +321,6 @@ impl Downloader {
if let Some(offsets) = offsets { if let Some(offsets) = offsets {
let mut root_format_idx = 0; let mut root_format_idx = 0;
let mut root_format_length = 0; let mut root_format_length = 0;
let mut audio_count: usize = 0;
let mut subtitle_count: usize = 0;
for (i, format) in self.formats.iter().enumerate() { for (i, format) in self.formats.iter().enumerate() {
let offset = offsets.get(&i).copied().unwrap_or_default(); let offset = offsets.get(&i).copied().unwrap_or_default();
let format_len = format let format_len = format
@ -340,15 +338,13 @@ impl Downloader {
for _ in &format.audios { for _ in &format.audios {
if let Some(offset) = &offsets.get(&i) { if let Some(offset) = &offsets.get(&i) {
audio_offsets.insert(audio_count, **offset); audio_offsets.insert(i, **offset);
} }
audio_count += 1
} }
for _ in &format.subtitles { for _ in &format.subtitles {
if let Some(offset) = &offsets.get(&i) { if let Some(offset) = &offsets.get(&i) {
subtitle_offsets.insert(subtitle_count, **offset); subtitle_offsets.insert(i, **offset);
} }
subtitle_count += 1
} }
} }