diff --git a/README.md b/README.md index ae88b55..36e0773 100644 --- a/README.md +++ b/README.md @@ -167,6 +167,7 @@ Steers which type of cleaning is applied to the downloads queue - Steers whether downloads that failed importing since they are not a format upgrade are removed from the queue - This occurs when a better version is already present - These downloads are added to the blocklist +- If the setting IGNORE_PRIVATE_TRACKERS is true, and the affected torrent is a private tracker, the queue item will still be removed, but the torrent files will be kept - Type: Boolean - Permissible Values: True, False - Is Mandatory: No (Defaults to False) @@ -228,7 +229,7 @@ Steers which type of cleaning is applied to the downloads queue **IGNORE_PRIVATE_TRACKERS** - Private torrents in qBittorrent will not be removed from the queue if this is set to true - Only works if qBittorrent is used (does not work with transmission etc.) -- Applies to all types of removal (ie. nothing will be removed automatically by decluttarr) +- Applies to all types of removal (ie. nothing will be removed automatically by decluttarr); only exception to this is REMOVE_NO_FORMAT_UPGRADE, where for private trackers the queue item is removed (but the torrent files are kept) - Note: You may want to try "force recheck" to get your stuck torrents manually back up and running - Type: Boolean - Permissible Values: True, False diff --git a/src/jobs/remove_no_format_upgrade.py b/src/jobs/remove_no_format_upgrade.py index cbf831f..abff334 100644 --- a/src/jobs/remove_no_format_upgrade.py +++ b/src/jobs/remove_no_format_upgrade.py @@ -29,9 +29,11 @@ async def remove_no_format_upgrade(settingsDict, BASE_URL, API_KEY, NAME, delete affectedItems = await execute_checks(settingsDict, affectedItems, failType, BASE_URL, API_KEY, NAME, deleted_downloads, defective_tracker, privateDowloadIDs, protectedDownloadIDs, addToBlocklist = True, - doPrivateTrackerCheck = True, + doPrivateTrackerCheck = False, doProtectedDownloadCheck = True, - doPermittedAttemptsCheck = True) + doPermittedAttemptsCheck = False, + extraParameters = ['keepTorrentForPrivateTrackers'] + ) return len(affectedItems) except Exception as error: errorDetails(NAME, error) diff --git a/src/utils/shared.py b/src/utils/shared.py index 4adcd8a..c21f857 100644 --- a/src/utils/shared.py +++ b/src/utils/shared.py @@ -56,7 +56,7 @@ def protectedDownloadCheck(settingsDict, affectedItems, failType, protectedDownl return affectedItems -async def execute_checks(settingsDict, affectedItems, failType, BASE_URL, API_KEY, NAME, deleted_downloads, defective_tracker, privateDowloadIDs, protectedDownloadIDs, addToBlocklist, doPrivateTrackerCheck, doProtectedDownloadCheck, doPermittedAttemptsCheck): +async def execute_checks(settingsDict, affectedItems, failType, BASE_URL, API_KEY, NAME, deleted_downloads, defective_tracker, privateDowloadIDs, protectedDownloadIDs, addToBlocklist, doPrivateTrackerCheck, doProtectedDownloadCheck, doPermittedAttemptsCheck, extraParameters = []): # Goes over the affected items and performs the checks that are parametrized try: # De-duplicates the affected items (one downloadid may be shared by multiple affected items) @@ -74,9 +74,16 @@ async def execute_checks(settingsDict, affectedItems, failType, BASE_URL, API_KE # Checks if failing more often than permitted if doPermittedAttemptsCheck: affectedItems = permittedAttemptsCheck(settingsDict, affectedItems, failType, BASE_URL, defective_tracker) + + # Checks whether when removing the queue item from the *arr app the torrent should be kept + removeFromClient = True + if 'keepTorrentForPrivateTrackers' in extraParameters: + if settingsDict['IGNORE_PRIVATE_TRACKERS'] and affectedItem['downloadId'] in privateDowloadIDs: + removeFromClient = False + # Deletes all downloads that have not survived the checks for affectedItem in affectedItems: - await remove_download(settingsDict, BASE_URL, API_KEY, affectedItem, failType, addToBlocklist, deleted_downloads) + await remove_download(settingsDict, BASE_URL, API_KEY, affectedItem, failType, addToBlocklist, deleted_downloads, removeFromClient) # Exit Logs if settingsDict['LOG_LEVEL'] == 'DEBUG': queue = await get_queue(BASE_URL, API_KEY) @@ -123,19 +130,21 @@ def permittedAttemptsCheck(settingsDict, affectedItems, failType, BASE_URL, defe logger.debug('permittedAttemptsCheck/defective_tracker.dict OUT: %s', str(defective_tracker.dict)) return affectedItems -async def remove_download(settingsDict, BASE_URL, API_KEY, affectedItem, failType, addToBlocklist, deleted_downloads): +async def remove_download(settingsDict, BASE_URL, API_KEY, affectedItem, failType, addToBlocklist, deleted_downloads, removeFromClient): # Removes downloads and creates log entry logger.debug('remove_download/deleted_downloads.dict IN: %s', str(deleted_downloads.dict)) if affectedItem['downloadId'] not in deleted_downloads.dict: - logger.info('>>> Removing %s download: %s', failType, affectedItem['title']) + if removeFromClient: + logger.info('>>> Removing %s download: %s', failType, affectedItem['title']) + else: + logger.info('>>> Removing %s download (without removing torrent): %s', failType, affectedItem['title']) if not settingsDict['TEST_RUN']: - await rest_delete(f'{BASE_URL}/queue/{affectedItem["id"]}', API_KEY, {'removeFromClient': True, 'blocklist': addToBlocklist}) + await rest_delete(f'{BASE_URL}/queue/{affectedItem["id"]}', API_KEY, {'removeFromClient': removeFromClient, 'blocklist': addToBlocklist}) deleted_downloads.dict.append(affectedItem['downloadId']) logger.debug('remove_download/deleted_downloads.dict OUT: %s', str(deleted_downloads.dict)) return - def errorDetails(NAME, error): exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]