ManiMatter / decluttarr

Watches radarr, sonarr, lidarr, readarr and whisparr download queues and removes downloads if they become stalled or no longer needed.
GNU General Public License v3.0
99 stars 15 forks source link

Update remove_slow.py. Fixes #36 #37

Closed TheNetworkGuy closed 4 months ago

TheNetworkGuy commented 4 months ago

Slow downloads check will only run with torrent type entries. Usenet entries will be skipped.

TheNetworkGuy commented 4 months ago

Just a quick thought: you could also fix this globally by implementing the check in the get_queue() function under shared.py. However i will leave it up to you on which level you would want to skip usenet based downloads.

ManiMatter commented 4 months ago

Thought: Can this be instead changed? From 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']

To if settings_dict['QBITTORRENT_URL'] and queueItem['downloadClient'] == ' qbittorrent '

Then the slow check would still work for all doenload types but only torrents would be checked against qbit (snd only if thats the torrent client) else vs arr-queue status directly (which is less frequently updated)

(Untested- just pseudocode written from my phone 😄)

TheNetworkGuy commented 4 months ago

Yes this seems to work as well! I'll modify my request.

[DEBUG]: getDownloadedSize/WARN: Using imprecise method to determine download increments because no direct qBIT query is possible

TheNetworkGuy commented 4 months ago

Just updated the code, validated on my own setup, moved the check to the getDownloadedSize() function and seems to work!

ManiMatter commented 4 months ago

hi, I changed the target branch to "dev", so we can build it there first. Above says there are conflicts, and I don't seem able to resolve it (guess cause the branch is in your git profile) -> can you please have a look? once resolved, will merge to dev and then you can pull & test

TheNetworkGuy commented 4 months ago

The conflict is because you previously placed the content of the function getDownloadedSize inside of a try / except block. I forked main which does not have this change. You can either approve the merge and get rid of the try / except block (like it is in main as well) or i can add the try / except block to my code.

My preference would be to go for the first option since we eventually want to merge this to main which does not have a try / except block (was placed there for troubleshooting.)

ManiMatter commented 4 months ago

Pls add it as in dev so in case of future probs it works and we can try the dev image

TheNetworkGuy commented 4 months ago

Seems good to me now. No idea why the return statement is acting funny but its the exact same.

ManiMatter commented 4 months ago

Mh. Still can’t merge…Do you want to simply quickly fork from dev; copy the new code snd create another pr back to dev snd close this one?