From cf8704a2aae60d4b8f10a72e661a94531bac1e02 Mon Sep 17 00:00:00 2001 From: arabcoders Date: Wed, 7 Jan 2026 17:42:08 +0300 Subject: [PATCH] feat: add flag to ignore already archived items from being added to download history. --- FAQ.md | 1 + app/library/DownloadQueue.py | 8 ++++---- app/library/config.py | 4 ++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/FAQ.md b/FAQ.md index e8d23c54..c3bed594 100644 --- a/FAQ.md +++ b/FAQ.md @@ -55,6 +55,7 @@ or the `environment:` section in `compose.yaml` file. | YTP_AUTO_CLEAR_HISTORY_DAYS | Number of days after which completed download history is cleared. | `0` | | YTP_DEFAULT_PAGINATION | The default number of items per page for history. | `50` | | YTP_TASK_HANDLER_RANDOM_DELAY | The maximum random delay in seconds before starting a task handler. | `60` | +| YTP_IGNORE_ARCHIVED_ITEMS | Don't report archived items in the download history. | `false` | > [!NOTE] > To raise the maximum workers for specific extractor, you need to add a ENV variable that follows the pattern `YTP_MAX_WORKERS_FOR_`. diff --git a/app/library/DownloadQueue.py b/app/library/DownloadQueue.py index fb9c2a0f..08c6045e 100644 --- a/app/library/DownloadQueue.py +++ b/app/library/DownloadQueue.py @@ -734,7 +734,7 @@ class DownloadQueue(metaclass=Singleton): # This sometimes can be different from the final extracted ID, so we need to verify again after extraction. if archive_id and item.is_archived(): store_type, dlInfo = await self.get_item(archive_id=archive_id) - if not store_type: + if not store_type and not self.config.ignore_archived_items: dlInfo = Download( info=ItemDTO( id=archive_id.split()[1], @@ -763,7 +763,7 @@ class DownloadQueue(metaclass=Singleton): ) return {"status": "ok"} - message: str = f"The URL '{item.url}' is already downloaded and recorded in archive." + message: str = f"The URL '{item.url}':'{archive_id}' is already downloaded and recorded in archive." LOG.warning(message) self._notify.emit( Events.LOG_INFO, data={"preset": item.preset}, title="Already Downloaded", message=message @@ -827,7 +827,7 @@ class DownloadQueue(metaclass=Singleton): if store_type: break - if not store_type: + if not store_type and not self.config.ignore_archived_items: new_archive_id = new_archive_id or extra_ids.pop(0) dlInfo = Download( info=ItemDTO( @@ -855,7 +855,7 @@ class DownloadQueue(metaclass=Singleton): ) return {"status": "ok"} - message: str = f"The URL '{item.url}' is already downloaded and recorded in archive." + message: str = f"The URL '{item.url}':'{archive_ids.pop(0)}' is already downloaded and recorded in archive." LOG.warning(message) self._notify.emit( Events.LOG_INFO, data={"preset": item.preset}, title="Already Downloaded", message=message diff --git a/app/library/config.py b/app/library/config.py index b34aaeb7..c936416c 100644 --- a/app/library/config.py +++ b/app/library/config.py @@ -216,6 +216,9 @@ class Config(metaclass=Singleton): task_handler_random_delay: float = 60.0 """The maximum random delay in seconds before starting a task handler.""" + ignore_archived_items: bool = False + """Dont report archived items in the download history.""" + pictures_backends: list[str] = [ "https://unsplash.it/1920/1080?random", "https://picsum.photos/1920/1080", @@ -280,6 +283,7 @@ class Config(metaclass=Singleton): "temp_disabled", "allow_internal_urls", "simple_mode", + "ignore_archived_items", ) "The variables that are booleans."