Opened 2 years ago
Last modified 6 months ago
#3549 new bug
deluge-console add not adding torrent filenames with embedded spaces
Reported by: | Paulo Marcel Coelho Aragão | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | needs verified |
Component: | Unknown | Version: | 2.1.0 |
Keywords: | console add torrent | Cc: |
Description
Have just installed deluge 2.1.1 on Xubuntu 22.04 from the deluge-team/stable PPA. Running deluged and would like to run deluge-console from a .desktop file to add torrent files and magnet URLs. It works for magnet URLs, for instance:
paulo@monk:~$ deluge-console add 'magnet:?xt=urn:btih:EC72BF82AB9381D0D6DEE0C3A88984AD7B62896A&tr=http%3A%2F%2Fbt4.t-ru.org%2Fann%3Fmagnet&dn=%5BTR24%5D%5BOF%5D%20Alfredo%20Rodriguez%20-%20The%20Invasion%20Parade%20-%202014%20(Jazz)' Attempting to add torrent from magnet URI: magnet:?xt=urn:btih:EC72BF82AB9381D0D6DEE0C3A88984AD7B62896A&tr=http%3A%2F%2Fbt4.t-ru.org%2Fann%3Fmagnet&dn=%5BTR24%5D%5BOF%5D%20Alfredo%20Rodriguez%20-%20The%20Invasion%20Parade%20-%202014%20(Jazz) Torrent added! <Deferred at 0x7f4388d8dea0 current result: None>
but it fails for torrent files with embedded spaces in the name, even if properly quoted, for instance:
paulo@monk:~/Downloads$ deluge-console add Goodbye\ Solo\ \(2008\)\ \[720p\]\ \[BluRay\]\ \[YTS.MX\].torrent usage: deluge-console [-h] [-V] [-c <config>] [-l <logfile>] [-L <level>] [--logrotate [<max-size>]] [-q] [--profile [<profile-file>]] [-d <ip_addr>] [-p <port>] [-U <user>] [-P <pass>] Command ... deluge-console: error: argument Command: invalid choice: 'Goodbye' (choose from 'add', 'cache', 'config', 'connect', 'debug', 'del', 'exit', 'gui', 'halt', 'help', 'info', 'manage', 'move', 'pause', 'plugin', 'quit', 'reannounce', 'recheck', 'resume', 'rm', 'status', 'update_tracker')
In this case, bash passes 2 arguments to deluge-console: 'add' and the torrent filename. But deluge-console seems too be further word splitting the filename on blanks.
Change History (2)
comment:1 by , 2 years ago
comment:2 by , 2 years ago
Didn't have my email address configured, so didn't see your reply earlier.
Playing with quoting, I stumbled across a workaround that works for any torrent file, with or without embedded spaces:
deluge-console "add 'torrent-file'"
but it breaks for magnet links:
Traceback (most recent call last): File "/usr/bin/deluge-console", line 33, in <module> sys.exit(load_entry_point('deluge==2.1.1', 'console_scripts', 'deluge-console')()) File "/usr/lib/python3/dist-packages/deluge/ui/console/__init__.py", line 16, in start return Console().start() File "/usr/lib/python3/dist-packages/deluge/ui/console/console.py", line 148, in start super().start(self.console_parser) File "/usr/lib/python3/dist-packages/deluge/ui/ui.py", line 64, in start self.__options = self.parse_args(parser, args) File "/usr/lib/python3/dist-packages/deluge/ui/ui.py", line 43, in parse_args options = parser.parse_args(args) File "/usr/lib/python3/dist-packages/deluge/ui/console/parser.py", line 73, in parse_args multi_command = self._split_args(args) File "/usr/lib/python3/dist-packages/deluge/ui/console/parser.py", line 50, in _split_args cmds = shlex.split(cmd_line) File "/usr/lib/python3.10/shlex.py", line 315, in split return list(lex) File "/usr/lib/python3.10/shlex.py", line 300, in __next__ token = self.get_token() File "/usr/lib/python3.10/shlex.py", line 109, in get_token raw = self.read_token() File "/usr/lib/python3.10/shlex.py", line 191, in read_token raise ValueError("No closing quotation") ValueError: No closing quotation
So, for magnet links, this works:
deluge-console add "magnet-link"
bash-scripting it:
if [[ $resource =~ ^magnet: ]]; then deluge-console add "$resource" elif [[ $(file --brief "$resource") == 'BitTorrent file' ]]; then deluge-console "add '$resource'" else die "Can't add $resource" fi
I managed to find the code that causes this issue:
https://git.deluge-torrent.org/deluge/tree/deluge/ui/console/parser.py?h=develop#n44
It appears as it searches for spaces and tries to parse the split string.
Therefor, currently, there is no way to use paths with spaces in them, including paths to torrent files.