downloader: fix NoneType error

Sometimes YoutubeDL()'s extract_info can't retrieve a video's metadata
(e.g. if the video has been privated or age-restricted) and ends up
making an empty or incomplete entry on the playlist's info_dict.

Catching this TypeError exception fixes workers from crashing and
burning when they encounter these empty or incomplete entries.
This commit is contained in:
Andrea Rogers 2021-10-16 19:11:40 -04:00
commit b98fba1508

View file

@ -87,10 +87,10 @@ def do_download(
except Empty: except Empty:
break break
if entry["id"] is None: try:
continue
else:
id_dir = entry["id"] id_dir = entry["id"]
except TypeError:
continue
try: try:
os.mkdir(id_dir) os.mkdir(id_dir)
@ -194,10 +194,10 @@ def check_dl(in_q: Queue, out_q: Queue):
except Empty: except Empty:
break break
if entry["id"] is None: try:
continue
else:
id_dir = entry["id"] id_dir = entry["id"]
except TypeError:
continue
if os.path.isdir(id_dir): if os.path.isdir(id_dir):
try: try: