Skip to content

Commit

Permalink
Added more granular logs for remove_slow.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ManiMatter committed Feb 19, 2024
1 parent b675993 commit 7930048
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ Feature overview:
You may run this locally by launching main.py, or by pulling the docker image.
You can find a sample docker-compose.yml in the docker folder.

## Dependencies
## Dependencies & Hints
Use Sonarr v4 & Radarr v5 (currently 'nightly' tag instead of 'latest'), else certain features may not work correctly.
Use latest version of qBittorrent.
qBittorrent is recommended but not required. If you don't use qBittorrent, certain features won't work (such as tag-protection)
If you see strange errors such as "found 10 / 3 times", consider turning on the setting "Reject Blocklisted Torrent Hashes While Grabbing" on indexer-level (available in the nightly versions of sonarr/radarr (Untested: setting by now may also exist in readarr & lidarr))

## Getting started
There's two ways to run this:
Expand Down
40 changes: 22 additions & 18 deletions src/remove_slow.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,26 @@ async def remove_slow(settings_dict, BASE_URL, API_KEY, NAME, deleted_downloads,

from src.utils.rest import (rest_get)
async def getDownloadedSize(settings_dict, queueItem, download_sizes_tracker):
# Determines the speed of download
# Since Sonarr/Radarr do not update the downlodedSize on realtime, if possible, fetch it directly from qBit
if settings_dict['QBITTORRENT_URL']:
qbitInfo = await rest_get(settings_dict['QBITTORRENT_URL']+'/torrents/info',params={'hashes': queueItem['downloadId']}, cookies=settings_dict['QBIT_COOKIE'] )
downloadedSize = qbitInfo[0]['completed']
else:
logger.debug('getDownloadedSize/WARN: Using imprecise method to determine download increments because no direct qBIT query is possible')
downloadedSize = queueItem['size'] - queueItem['sizeleft']
if queueItem['downloadId'] in download_sizes_tracker.dict:
previousSize = download_sizes_tracker.dict.get(queueItem['downloadId'])
increment = downloadedSize - previousSize
speed = round(increment / 1000 / (settings_dict['REMOVE_TIMER'] * 60),1)
else:
previousSize = None
increment = None
speed = None
try:
# Determines the speed of download
# Since Sonarr/Radarr do not update the downlodedSize on realtime, if possible, fetch it directly from qBit
if settings_dict['QBITTORRENT_URL']:
qbitInfo = await rest_get(settings_dict['QBITTORRENT_URL']+'/torrents/info',params={'hashes': queueItem['downloadId']}, cookies=settings_dict['QBIT_COOKIE'] )
downloadedSize = qbitInfo[0]['completed']
else:
logger.debug('getDownloadedSize/WARN: Using imprecise method to determine download increments because no direct qBIT query is possible')
downloadedSize = queueItem['size'] - queueItem['sizeleft']
if queueItem['downloadId'] in download_sizes_tracker.dict:
previousSize = download_sizes_tracker.dict.get(queueItem['downloadId'])
increment = downloadedSize - previousSize
speed = round(increment / 1000 / (settings_dict['REMOVE_TIMER'] * 60),1)
else:
previousSize = None
increment = None
speed = None

download_sizes_tracker.dict[queueItem['downloadId']] = downloadedSize
return downloadedSize, previousSize, increment, speed
download_sizes_tracker.dict[queueItem['downloadId']] = downloadedSize
return downloadedSize, previousSize, increment, speed
except Exception as error:
errorDetails(NAME, error)
return
3 changes: 3 additions & 0 deletions src/utils/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ def permittedAttemptsCheck(settings_dict, affectedItems, failType, BASE_URL, def
# If not exceeding the number of permitted times, remove from being affected
if defective_tracker.dict[BASE_URL][failType][affectedItem['downloadId']]['Attempts'] <= settings_dict['PERMITTED_ATTEMPTS']:
affectedItems.remove(affectedItem)
# else:
# # Will be deleted - reset the counter to 0
# del defective_tracker.dict[BASE_URL][failType][affectedItem['downloadId']]
logger.debug('permittedAttemptsCheck/defective_tracker.dict OUT: %s', str(defective_tracker.dict))
return affectedItems

Expand Down

0 comments on commit 7930048

Please sign in to comment.