From b98fba15080f123f0f625a6b877ab153e84200ce Mon Sep 17 00:00:00 2001 From: Andrea Rogers Date: Sat, 16 Oct 2021 19:11:40 -0400 Subject: [PATCH] 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. --- squid_dl/downloader.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/squid_dl/downloader.py b/squid_dl/downloader.py index 4443fa7..aac6dce 100644 --- a/squid_dl/downloader.py +++ b/squid_dl/downloader.py @@ -87,10 +87,10 @@ def do_download( except Empty: break - if entry["id"] is None: - continue - else: + try: id_dir = entry["id"] + except TypeError: + continue try: os.mkdir(id_dir) @@ -194,10 +194,10 @@ def check_dl(in_q: Queue, out_q: Queue): except Empty: break - if entry["id"] is None: - continue - else: + try: id_dir = entry["id"] + except TypeError: + continue if os.path.isdir(id_dir): try: