[BUGFIX] Fix extract info with retry issue with deleting download archive (#208)
This commit is contained in:
parent
ffb45f6eb5
commit
2f4a2a4726
1 changed files with 8 additions and 7 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
import abc
|
import abc
|
||||||
import contextlib
|
import contextlib
|
||||||
|
import copy
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
|
@ -60,7 +61,7 @@ class Downloader(DownloadArchiver, Generic[DownloaderOptionsT, DownloaderEntryT]
|
||||||
supports_chapters: bool = True
|
supports_chapters: bool = True
|
||||||
|
|
||||||
_extract_entry_num_retries: int = 5
|
_extract_entry_num_retries: int = 5
|
||||||
_extract_entry_retry_wait_sec: int = 3
|
_extract_entry_retry_wait_sec: int = 5
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def ytdl_option_defaults(cls) -> Dict:
|
def ytdl_option_defaults(cls) -> Dict:
|
||||||
|
|
@ -173,9 +174,12 @@ class Downloader(DownloadArchiver, Generic[DownloaderOptionsT, DownloaderEntryT]
|
||||||
"""
|
"""
|
||||||
num_tries = 0
|
num_tries = 0
|
||||||
entry_files_exist = False
|
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:
|
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():
|
if is_downloaded_fn is None or is_downloaded_fn():
|
||||||
return entry_dict
|
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,
|
# Remove the download archive so it can retry without thinking its already downloaded,
|
||||||
# even though it is not
|
# even though it is not
|
||||||
ytdl_options_overrides = (
|
if "download_archive" in copied_ytdl_options_overrides:
|
||||||
YTDLOptionsBuilder()
|
del copied_ytdl_options_overrides["download_archive"]
|
||||||
.add(ytdl_options_overrides, {"download_archive": None})
|
|
||||||
.to_dict()
|
|
||||||
)
|
|
||||||
|
|
||||||
if num_tries < self._extract_entry_retry_wait_sec:
|
if num_tries < self._extract_entry_retry_wait_sec:
|
||||||
download_logger.debug(
|
download_logger.debug(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue