diff --git a/app/library/Download.py b/app/library/Download.py index f7b3b8f9..fff8db9f 100644 --- a/app/library/Download.py +++ b/app/library/Download.py @@ -107,6 +107,7 @@ class Download: self.temp_dir = info.temp_dir self.template = info.template self.template_chapter = info.template_chapter + self.download_info_expires = int(config.download_info_expires) self.preset = info.preset self.info = info self.id = info._id @@ -226,7 +227,15 @@ class Download: self.logger.error(err_msg) raise ValueError(err_msg) from e - if not self.info_dict: + # Safe-guard incase downloading take too long and the info expires. + if self.info_dict and isinstance(self.info_dict, dict) and self.download_info_expires > 0: + _ts: int | None = self.info_dict.get("timestamp") + _ts = datetime.fromtimestamp(_ts, tz=UTC) if _ts else None + if not _ts or (datetime.now(tz=UTC) - _ts).total_seconds() > self.download_info_expires: + self.info_dict = None + self.logger.warning(f"Info for '{self.info.url}' has expired, re-extracting info.") + + if not self.info_dict or not isinstance(self.info_dict, dict): self.logger.info(f"Extracting info for '{self.info.url}'.") self.logs = [] ie_params = params.copy() diff --git a/app/library/config.py b/app/library/config.py index 92cd489e..adf26c72 100644 --- a/app/library/config.py +++ b/app/library/config.py @@ -28,6 +28,9 @@ class Config: download_path_depth: int = 2 """How many subdirectories to show in auto complete.""" + download_info_expires: int = 10800 + """How long (in seconds) the download info is valid before it needs to be re-extracted.""" + temp_path: str = "/tmp" """The path to the temporary directory.""" @@ -226,6 +229,7 @@ class Config: "debugpy_port", "playlist_items_concurrency", "download_path_depth", + "download_info_expires", ) "The variables that are integers." diff --git a/ui/app/components/History.vue b/ui/app/components/History.vue index 73e056fb..02601d8f 100644 --- a/ui/app/components/History.vue +++ b/ui/app/components/History.vue @@ -351,7 +351,7 @@ -
+