Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Add option to set 'obsolete'-tag to private torrents that are not needed but kept anyway. #194

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from

Conversation

Dark3clipse
Copy link

Description
This feature introduces an option to tag torrents in qBittorrent that are determined to no longer be needed by the *arrs. This allows third-party tools to remove these torrents at a later stage when seeding requirements are met.

Use case
You have private trackers and want to make sure that you meet the seeding requirements before removing these torrents. Sometimes, torrents are no longer needed by the *arrs. You would like to remove these torrents after the seeding requirements are met. A tool like qbit_manage can do this for you.

However, such tools would need to know which torrents are no longer needed (obsolete) by the *arrs. By making decluttarr tag these torrents, third party tools such as qbit_manage can be used to cleanup these torrents after seeding requirements are met.

Changes

  • Add new option 'OBSOLETE_QBIT_TAG' to the configuration.
  • Create a description for the new option in the readme.
  • Add function to create the tag in qBittorrent if it doesn't exist yet.
  • Add logic in shared.py to set the tag using a post request.

@ManiMatter
Copy link
Owner

hi @Dark3clipse, thanks for your contribution.

The behavior is not entirely clear to me, here are a few thoughts.

  1. Could you please take care of the merge conflicts / rebase to the dev-branch commit
  2. I would expect that a boolean variable enables/disables this behavior, not the tag itself
  3. The tag should only be created if the feature is being used in qbit
  4. Readme is not self explanatory for me, if you maybe could take care of 2) and 3) and the update the readme, that'd be appreciated

@Dark3clipse
Copy link
Author

Thank you for the feedback, I will rework the code.

@Dark3clipse
Copy link
Author

Dark3clipse commented Dec 20, 2024

It is not clear to me what you mean with:
3. The tag should only be created if the feature is being used in qbit

We have no knowledge of what other tools are managing/using qbit (such as qbitmanage). Also, I think decluttarr should not have to know. You just set the feature to True if you want to use it imo. qbit itself is not 'using' the tags.

I do check the existence of the tag in qbittorrent (see loadScripts.py) and create it if the feature is enabled and the tag string is not empty.

@Dark3clipse
Copy link
Author

Except for your 3rd point, the code should be reworked now. Could you have another look to see if your concerns have been addressed? Thank you :)

Copy link
Owner

@ManiMatter ManiMatter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey!

Almost there I think.

Please can you have a look at my comments.
Also, I saw the unit tests failed in the github actions, pls can you check?

logger.info('Downloads with this tag will be skipped: \"%s\"', settingsDict['NO_STALLED_REMOVAL_QBIT_TAG'])
logger.info('Private Trackers will be skipped: %s', settingsDict['IGNORE_PRIVATE_TRACKERS'])
logger.info('Downloads with this tag will be skipped: \"%s\"', settingsDict['NO_STALLED_REMOVAL_QBIT_TAG'])
if settingsDict['SET_OBSOLETE_QBIT_TAG'] and settingsDict['OBSOLETE_QBIT_TAG']:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and settingsDict['OBSOLETE_QBIT_TAG']:

isn't that check redundant? this value will always be true, since you are setting a default in the definitions.py?

@@ -317,6 +328,13 @@ If it you face issues, please first check the closed issues before opening a new
- Type: String
- Is Mandatory: No (Defaults to `Don't Kill`)

**OBSOLETE_QBIT_TAG**
- Downloads in qBittorrent will receive this tag when: (1) `SET_OBSOLETE_QBIT_TAG==True`, (2) `IGNORE_PRIVATE_TRACKERS==True`, (3) torrent is private, (4) torrent is due for removal.
- Note: the tag can be used by third-party tools to remove these torrents after required seeding time has passed.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: the tag can be used by third-party tools (such as qbit_manage)to remove these torrents after required seeding time has passed.

would it make sense to add qbit_manage as example?

**SET_OBSOLETE_QBIT_TAG**
- Set a tag on torrents in qBittorrent that can be removed, but are kept because they are private torrents.
- Note: Has no effect when `IGNORE_PRIVATE_TRACKERS==False`.
- The tag can be used by third-party tools to remove these torrents after required seeding time has passed.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tag can be used by third-party tools (such as qbit_manage) to remove these torrents after required seeding time has passed.

would it make sense to add qbit_manage as example?

@@ -259,6 +261,15 @@ Steers which type of cleaning is applied to the downloads queue
- Permissible Values: True, False
- Is Mandatory: No (Defaults to False)

**SET_OBSOLETE_QBIT_TAG**
- Set a tag on torrents in qBittorrent that can be removed, but are kept because they are private torrents.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • If this feature is turned on, private torrents in qBittorrent are not removed once the conditions for removal are met; instead, they are tagged with the obsolete-tag

I would formulate it like this - if you are OK

@@ -56,6 +56,9 @@ async def main(settingsDict):
# Create qBit protection tag if not existing
await createQbitProtectionTag(settingsDict)

# Create qBit obsolete tag if not existing
await createQbitObsoleteTag(settingsDict)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3. The tag should only be created if the feature is being used in qbit

My point was referring to this line. In my mind you should only create a obsolete tag in qbit if this feature is even used.

if settingsDict['SET_OBSOLETE_QBIT_TAG']
     await createQbitObsoleteTag(settingsDict)

@@ -92,6 +92,7 @@ def showSettings(settingsDict):
logger.info('%s | Removing slow downloads (%s)', str(settingsDict['REMOVE_SLOW']), 'REMOVE_SLOW')
logger.info('%s | Removing stalled downloads (%s)', str(settingsDict['REMOVE_STALLED']), 'REMOVE_STALLED')
logger.info('%s | Removing downloads belonging to unmonitored items (%s)', str(settingsDict['REMOVE_UNMONITORED']), 'REMOVE_UNMONITORED')
logger.info('%s | Setting obsolete tag on private torrents that are due for removal (%s)', str(settingsDict['SET_OBSOLETE_QBIT_TAG']), 'SET_OBSOLETE_QBIT_TAG')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger.info("%s | Keeping private torrents in qBit due for removal and tagging instead (tag: '%s')", str(settingsDict['SET_OBSOLETE_QBIT_TAG']), 'SET_OBSOLETE_QBIT_TAG')

Proposal above.

failType,
affectedItem["title"],
)
if settingsDict['SET_OBSOLETE_QBIT_TAG'] and settingsDict['OBSOLETE_QBIT_TAG']:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

settingsDict['OBSOLETE_QBIT_TAG'] - same as above. isnt this obsolete due to default value?

)
if settingsDict['SET_OBSOLETE_QBIT_TAG'] and settingsDict['OBSOLETE_QBIT_TAG']:
logger.info(
">>> Removing %s download (without removing from torrent client but with setting obsolete tag): %s",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

">>> Removing %s download (keeping it in torrent client and adding tag '%s'

where %s is settingsDict['OBSOLETE_QBIT_TAG']

proposal above.

@@ -326,6 +333,9 @@ async def remove_download(
API_KEY,
{"removeFromClient": removeFromClient, "blocklist": addToBlocklist},
)
if not removeFromClient and settingsDict['QBITTORRENT_URL'] and settingsDict['SET_OBSOLETE_QBIT_TAG'] and settingsDict['OBSOLETE_QBIT_TAG'] and affectedItem["downloadId"]:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

settingsDict['OBSOLETE_QBIT_TAG'] -> redundant?

@Dark3clipse
Copy link
Author

I'll need some time due to Christmas with in laws, I will come back and address the remaining work in a couple of days if that's okay. Again, thank you a lot for the feedback. Let's make this feature solid :) Wish you a nice holiday season as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants