Fix multiplexing of downloads without a video track

E.g., --subs-only and --audio-only
This commit is contained in:
rlaphoenix 2023-04-17 14:06:57 +01:00
parent 96aa7c1e0a
commit 86322159b6
1 changed files with 7 additions and 4 deletions

View File

@ -15,6 +15,7 @@ from concurrent.futures import ThreadPoolExecutor
from copy import deepcopy from copy import deepcopy
from functools import partial from functools import partial
from http.cookiejar import MozillaCookieJar from http.cookiejar import MozillaCookieJar
from itertools import zip_longest
from pathlib import Path from pathlib import Path
from threading import Event, Lock from threading import Event, Lock
from typing import Any, Callable, Optional from typing import Any, Callable, Optional
@ -616,14 +617,15 @@ class dl:
total=None, total=None,
start=False start=False
) )
for x in title.tracks.videos for x in title.tracks.videos or [None]
] ]
with Live( with Live(
Padding(progress, (0, 5, 1, 5)), Padding(progress, (0, 5, 1, 5)),
console=console console=console
): ):
for track, task in zip(title.tracks.videos, tasks): for task, video_track in zip_longest(tasks, title.tracks.videos, fillvalue=None):
title.tracks.videos = [track] if video_track:
title.tracks.videos = [video_track]
progress.start_task(task) # TODO: Needed? progress.start_task(task) # TODO: Needed?
muxed_path, return_code = title.tracks.mux( muxed_path, return_code = title.tracks.mux(
str(title), str(title),
@ -636,7 +638,8 @@ class dl:
elif return_code >= 2: elif return_code >= 2:
self.log.error(f"Failed to Mux video to Matroska file ({return_code})") self.log.error(f"Failed to Mux video to Matroska file ({return_code})")
sys.exit(1) sys.exit(1)
track.delete() if video_track:
video_track.delete()
for track in title.tracks: for track in title.tracks:
track.delete() track.delete()
else: else: