From 78a3f13f92c62032a938ba55f3f98faf3a47138d Mon Sep 17 00:00:00 2001 From: Hafitz Setya <71178188+breakdowns@users.noreply.github.com> Date: Mon, 22 Feb 2021 15:27:53 +0700 Subject: [PATCH] Skip unavailable videos when downloading from Playlist --- .../download_utils/youtube_dl_download_helper.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bot/helper/mirror_utils/download_utils/youtube_dl_download_helper.py b/bot/helper/mirror_utils/download_utils/youtube_dl_download_helper.py index ca07ec1..e4e4776 100644 --- a/bot/helper/mirror_utils/download_utils/youtube_dl_download_helper.py +++ b/bot/helper/mirror_utils/download_utils/youtube_dl_download_helper.py @@ -111,7 +111,7 @@ class YoutubeDLHelper(DownloadHelper): if 'entries' in result: video = result['entries'][0] for v in result['entries']: - if v.get('filesize'): + if v and v.get('filesize'): self.size += float(v['filesize']) # For playlists, ydl.prepare-filename returns the following format: -.NA self.name = name.split(f"-{result['id']}")[0] @@ -139,6 +139,9 @@ class YoutubeDLHelper(DownloadHelper): self.onDownloadError("Download Cancelled by User!") def add_download(self, link, path): + pattern = '^.*(youtu\.be\/|youtube.com\/)(playlist?)' + if re.match(pattern, link): + self.opts['ignoreerrors'] = True self.__onDownloadStart() self.extractMetaData(link) LOGGER.info(f"Downloading with YT-DL: {link}")