Opened 20 months ago

Last modified 20 months ago

#3549 new bug

deluge-console add not adding torrent filenames with embedded spaces

Reported by: marcelpaulo Owned by:
Priority: minor Milestone: needs verified
Component: Unknown Version: 2.1.0
Keywords: console add torrent Cc:


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&'
Attempting to add torrent from magnet URI: magnet:?xt=urn:btih:EC72BF82AB9381D0D6DEE0C3A88984AD7B62896A&
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 Changed 20 months ago by DjLegolas

I managed to find the code that causes this issue:

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.

comment:2 Changed 20 months ago 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/", line 16, in start
    return Console().start()
  File "/usr/lib/python3/dist-packages/deluge/ui/console/", line 148, in start
  File "/usr/lib/python3/dist-packages/deluge/ui/", line 64, in start
    self.__options = self.parse_args(parser, args)
  File "/usr/lib/python3/dist-packages/deluge/ui/", line 43, in parse_args
    options = parser.parse_args(args)
  File "/usr/lib/python3/dist-packages/deluge/ui/console/", line 73, in parse_args
    multi_command = self._split_args(args)
  File "/usr/lib/python3/dist-packages/deluge/ui/console/", line 50, in _split_args
    cmds = shlex.split(cmd_line)
  File "/usr/lib/python3.10/", line 315, in split
    return list(lex)
  File "/usr/lib/python3.10/", line 300, in __next__
    token = self.get_token()
  File "/usr/lib/python3.10/", line 109, in get_token
    raw = self.read_token()
  File "/usr/lib/python3.10/", 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'"
    die "Can't add $resource"
Last edited 20 months ago by marcelpaulo (previous) (diff)
Note: See TracTickets for help on using tickets.