From 2f4a2a4726e67ee5f877ab591c2b0c3c5262eee2 Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Fri, 2 Sep 2022 00:10:37 -0700 Subject: [PATCH] [BUGFIX] Fix extract info with retry issue with deleting download archive (#208) --- src/ytdl_sub/downloaders/downloader.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/ytdl_sub/downloaders/downloader.py b/src/ytdl_sub/downloaders/downloader.py index 074fe867..cdb85691 100644 --- a/src/ytdl_sub/downloaders/downloader.py +++ b/src/ytdl_sub/downloaders/downloader.py @@ -1,5 +1,6 @@ import abc import contextlib +import copy import json import os import time @@ -60,7 +61,7 @@ class Downloader(DownloadArchiver, Generic[DownloaderOptionsT, DownloaderEntryT] supports_chapters: bool = True _extract_entry_num_retries: int = 5 - _extract_entry_retry_wait_sec: int = 3 + _extract_entry_retry_wait_sec: int = 5 @classmethod def ytdl_option_defaults(cls) -> Dict: @@ -173,9 +174,12 @@ class Downloader(DownloadArchiver, Generic[DownloaderOptionsT, DownloaderEntryT] """ num_tries = 0 entry_files_exist = False + copied_ytdl_options_overrides = copy.deepcopy(ytdl_options_overrides) while not entry_files_exist and num_tries < self._extract_entry_num_retries: - entry_dict = self.extract_info(ytdl_options_overrides=ytdl_options_overrides, **kwargs) + entry_dict = self.extract_info( + ytdl_options_overrides=copied_ytdl_options_overrides, **kwargs + ) if is_downloaded_fn is None or is_downloaded_fn(): return entry_dict @@ -184,11 +188,8 @@ class Downloader(DownloadArchiver, Generic[DownloaderOptionsT, DownloaderEntryT] # Remove the download archive so it can retry without thinking its already downloaded, # even though it is not - ytdl_options_overrides = ( - YTDLOptionsBuilder() - .add(ytdl_options_overrides, {"download_archive": None}) - .to_dict() - ) + if "download_archive" in copied_ytdl_options_overrides: + del copied_ytdl_options_overrides["download_archive"] if num_tries < self._extract_entry_retry_wait_sec: download_logger.debug(