Background: script to create torrents and add them to deluged via deluge-
console.
Create a torrent with transmission-cli:
{{{
Creating torrent "/library/torrent/Last1, First1; Last2, First2 -- Title,
3_e (1989, 2016).torrent"
2 files, 84.84 MB
1,295 pieces, 65.54 kB each
done!
torrentfile=/library/torrent/Last1, First1; Last2, First2 -- Title, 3_e
(1989, 2016).torrent
}}}
The next step is to add the torrent to deluge via deluge-console:
{{{
deluge-console "connect $delugehost:$delugeport $delugeuser $delugepass;
add -p ${linked@Q} ${torrentfile@Q}"
}}}
{{{
Traceback (most recent call last):
File "/home/user/.local/bin/deluge-console", line 8, in <module>
sys.exit(start())
^^^^^^^
File "/home/user/.local/share/pipx/venvs/deluge/lib/python3.12/site-
packages/deluge/ui/console/__init__.py", line 16, in start
return Console().start()
^^^^^^^^^^^^^^^^^
File "/home/user/.local/share/pipx/venvs/deluge/lib/python3.12/site-
packages/deluge/ui/console/console.py", line 148, in start
super().start(self.console_parser)
File "/home/user/.local/share/pipx/venvs/deluge/lib/python3.12/site-
packages/deluge/ui/ui.py", line 64, in start
self.__options = self.parse_args(parser, args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/share/pipx/venvs/deluge/lib/python3.12/site-
packages/deluge/ui/ui.py", line 43, in parse_args
options = parser.parse_args(args)
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/share/pipx/venvs/deluge/lib/python3.12/site-
packages/deluge/ui/console/parser.py", line 73, in parse_args
multi_command = self._split_args(args)
^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/share/pipx/venvs/deluge/lib/python3.12/site-
packages/deluge/ui/console/parser.py", line 50, in _split_args
cmds = shlex.split(cmd_line)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/shlex.py", line 313, in split
return list(lex)
^^^^^^^^^
File "/usr/lib/python3.12/shlex.py", line 300, in __next__
token = self.get_token()
^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/shlex.py", line 109, in get_token
raw = self.read_token()
^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/shlex.py", line 191, in read_token
raise ValueError("No closing quotation")
ValueError: No closing quotation
}}}
changing torrentfile to specifically escape the semicolon does not help:
{{{
torrentfile=/library/torrent/Last1, First1\; Last2, First2 -- Title, 3_e
(1989, 2016).torrent
}}}
--
Ticket URL: <http://dev.deluge-torrent.org/ticket/3647>
Deluge <https://deluge-torrent.org/>
Deluge Project
* summary: deluge console errors on addition of torrent with `;` in name
=>
deluge console errors on addition of torrent with semicolon (`;`) in
name
--
Ticket URL: <http://dev.deluge-torrent.org/ticket/3647#comment:1>
NB:
the @Q wraps the semicolon-containing string in single quotes which I
thought should be enough:
{{{
echo "${torrentfile@Q}"
'/library/torrent/Last1, First1; Last2, First2 -- Title, 3_e (1989,
2016).torrent'
}}}
--
Ticket URL: <http://dev.deluge-torrent.org/ticket/3647#comment:2>
Also this fails...
{{{
$ deluge-console "connect $delugehost:$delugeport $delugeuser $delugepass;
add -p ${linked@Q} \"${torrentfile//\;/\\\;}\""
File "/usr/lib/python3.12/shlex.py", line 210, in read_token
raise ValueError("No escaped character")
ValueError: No escaped character
}}}
defining "$torrentfile" as also does not work:
{{{
torrentfile=/library/torrent/Last1\,\ First1\;\ Last2\,\ First2\ --\
Title\,\ 3_e\ \(1989\,\ 2016\).torrent
}}}
--
Ticket URL: <http://dev.deluge-torrent.org/ticket/3647#comment:3>
Huh, I just found this error again, though I came here for a different
reason, I decided to circumvent the problem with this:
{{{
if command -v btcheck >/dev/null; then
hash=$( btcheck -in "$torrentfile" |grep -oP 'Torrent Hash : \K.*' )
elif command -v transmission-show >/dev/null; then
printf 'The btcheck command not found; consider installing for faster
torrent file reads\n.'
printf 'Defaulting to transmission-show for hash lookup.\n'
hash=$( transmission-show "$torrentfile" |grep -oP 'Hash v1: \K.*' )
else
printf 'Neither btcheck nor transmission-show are installed. The former
is faster but one must be installed.\n'
printf '(exit 1)'
exit 1
fi
tmptorrent="/tmp/$hash.torrent"
cp "$torrentfile" "$tmptorrent"
⋮
rm "$tmptorrent"
exit
}}}
--
Ticket URL: <http://dev.deluge-torrent.org/ticket/3647#comment:4>