{{{
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.
--
Ticket URL: <https://dev.deluge-torrent.org/ticket/3549>
Deluge <https://deluge-torrent.org/>
Deluge Project
Comment (by DjLegolas):
I managed to find the code that causes this issue:[[BR]]
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.[[BR]]
Therefor, currently, there is no way to use paths with spaces in them,
including paths to torrent files.
--
Ticket URL: <https://dev.deluge-torrent.org/ticket/3549#comment:1>
Comment (by marcelpaulo):
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"
}}}
--
Ticket URL: <https://dev.deluge-torrent.org/ticket/3549#comment:2>