Issue 3806 - Add ability to work with rTorrent named custom fields#3807
Issue 3806 - Add ability to work with rTorrent named custom fields#3807gazpachoking merged 20 commits intoFlexget:developfrom
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
…flexget into rtorrent_custom_fields
for more information, see https://pre-commit.ci
|
@gazpachoking I ran with your comments on my issue and got this PR all set. This is my first PR for Flexget, so unsure if there is a preferred method of letting you and the team know this is ready for you to review... so this is ready! Let me know if you need anything from me! |
gazpachoking
left a comment
There was a problem hiding this comment.
I made a few mostly superficial suggestions, but it looks pretty good to me! I don't use rTorrent, or have any intimate knowledge about how the API works, so I'm trusting that the actual functionality works as intended.
flexget/plugins/clients/rtorrent.py
Outdated
| # Set custom fields | ||
| for key, val in custom_fields.items(): | ||
| # Values must be escaped if within params | ||
| params.append(f'd.custom.set={re.escape(str(key))},{re.escape(str(val))}') |
There was a problem hiding this comment.
I'm not sure what escaping rules are needed for the rtorrent api, but I doubt it this is the exact right way. re.escape is meant to escape characters that have special meanings in regex. A quick peek at the api guide makes me think maybe just surrounding the key and value with double quotes is enough?
| params.append(f'd.custom.set={re.escape(str(key))},{re.escape(str(val))}') | |
| params.append(f'd.custom.set="{key}","{val}"') |
There was a problem hiding this comment.
I've got the re.escape used in a couple places. I did the escaping that way because that is what was used already for the fields, and thought I would keep it consistent. However, I will test with just quoting on my parts and see how this goes. If everything works out, then I will commit that.
There was a problem hiding this comment.
@gazpachoking I have updated all the of the re.escape calls used for custom fields to be quoted and to escape double quotes with a \" character. I believe this should do the trick. I did leave the re.escape from the fields code that was there before I started my merge since I didn't want to change how things currently work. However, I am happy to make that change if you think it is appropriate.
Thanks for the help!
Co-authored-by: Chase Sterling <chase.sterling@gmail.com>
|
@gazpachoking Thank you very much for the helpful suggestions (and the catch on the entry vs config ordering). I am not very well versed in python, so I will take all the suggestions you are willing to offer! |
|
Looks good to me, thanks! Can you update the wiki with the new options? |
|
@gazpachoking Thank you very much! I have updated the wiki with the documentation and an example for this functionality! |
Motivation for changes:
rTorrent has the ability to work with named custom fields, but flexget only exposes the builtin custom1...custom5 fields. This PR is to expose the functionality of named custom fields to flexget for both the
rtorrentandfrom_rtorrentplugins.Detailed changes:
Addressed issues/feature requests:
Implements #3806
Config usage if relevant (new plugin or updated schema):
from_rtorrentrtorrentLog and/or tests output (preferably both):
config.ymlTest output