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
Auto-set a torrent's parameters based on metadata #20502
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very preliminary comments. I haven't reviewed it completely.
The preliminary comment about the file format concerns the naming style of "predefined" entities, such as parameter names and values. Could you change them so that they use the same style, either snake_case or CamelCase? (I would prefer CamelCase.) |
6b54657
to
9ed0866
Compare
I updated the sample rules config at https://pastebin.com/aMsE5ght to use CamelCase style for JSON keys. |
2241c4a
to
a3b6b96
Compare
Adds a system for configuring a set of rules that modify torrent parameters based on the torrent's metadata. Rules are specified via a JSON file loaded on startup. Closes qbittorrent#5779.
Any further comments @glassez ? |
I need more time to think about it in detail, but right now I have other tasks as a priority. |
but our API is in snake_case, would be better to use same case |
Add a system for configuring a set of rules that modify torrent parameters based on the torrent's metadata. Closes #5779.
Each Rule consists of a Condition and a Modifier. The Condition acts as a predicate applied to the metadata (e.g., trackers or files in the torrent). The Modifer performs some mutation on the torrent, such as setting its category or adding a tag. A given torrent may match multiple Rules, and Modifications are applied in the same order as the Rule definitions.
Rules are specified in a torrent_param_rules.json file placed in the config directory. If you can't access the attached file, a copy is available at https://pastebin.com/aMsE5ght. If this PR is accepted, further documentation can be added to the Wiki.
Rules are only applied to newly added torrents on initially receiving their metadata. Updates to an existing torrent's metadata, such as merging trackers, do not cause the Rules to be re-applied.
The following Conditions are included in this PR:
The following Modifiers are included in this PR:
The system is designed to be modular, so it should be possible to add more Conditions and Modifiers in later PRs without significant effort. I tried to limit this PR to some of the more commonly requested ones to keep it from getting too large.
Implementation notes:
The primary complicating factor for this feature is that some portions of metadata (e.g. file paths) are not guaranteed to be immediately available. For example, when using a magnet link, they are asynchronously downloaded. The download may not complete until after the add torrent GUI has been displayed or after the torrent has been added to the session. This requires handling three scenarios: