From 06874200bd04bceb01ef32a1642984c2c21bb193 Mon Sep 17 00:00:00 2001 From: Jack <5182053+phyzical@users.noreply.github.com> Date: Sat, 11 May 2024 13:18:11 +0800 Subject: [PATCH] Update remove_missing_files.py Support "no files found for import" auto removal --- src/jobs/remove_missing_files.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/jobs/remove_missing_files.py b/src/jobs/remove_missing_files.py index 2444848..68efb11 100644 --- a/src/jobs/remove_missing_files.py +++ b/src/jobs/remove_missing_files.py @@ -13,11 +13,19 @@ async def remove_missing_files(settingsDict, BASE_URL, API_KEY, NAME, deleted_do # Find items affected affectedItems = [] for queueItem in queue['records']: - if 'errorMessage' in queueItem and 'status' in queueItem: - if (queueItem['status'] == 'warning' and - (queueItem['errorMessage'] == 'DownloadClientQbittorrentTorrentStateMissingFiles' or + if 'status' in queueItem: + # case to check for failed torrents + if (queueItem['status'] == 'warning' and 'errorMessage' in queueItem and + (queueItem['errorMessage'] == 'DownloadClientQbittorrentTorrentStateMissingFiles' or queueItem['errorMessage'] == 'The download is missing files')): affectedItems.append(queueItem) + # case to check for failed nzb's/bad files/empty directory + if queueItem['status'] == 'completed' and 'statusMessages' in queueItem: + for statusMessage in queueItem['statusMessages']: + if 'messages' in statusMessage: + for message in statusMessage['messages']: + if message.startswith("No files found are eligible for import in"): + affectedItems.append(queueItem) affectedItems = await execute_checks(settingsDict, affectedItems, failType, BASE_URL, API_KEY, NAME, deleted_downloads, defective_tracker, privateDowloadIDs, protectedDownloadIDs, addToBlocklist = False, doPrivateTrackerCheck = True, @@ -26,4 +34,4 @@ async def remove_missing_files(settingsDict, BASE_URL, API_KEY, NAME, deleted_do return len(affectedItems) except Exception as error: errorDetails(NAME, error) - return 0 \ No newline at end of file + return 0