I think there are only two ways to do it:
Use --list
before and after, and see what's new. Doable in a script, but sounds painful. And of course prone to races.
Use -t TORRENT -i
and look at the Id:
field. At first glance this looks circular, but it turns out TORRENT doesn't have to be an Id. It can be a hash.
So, with method 2:
hash="$( transmission-show FILE.TORRENT | perl -n -E 'say $1 if /^\s*Hash: (.+)$/' )"
id="$(transmission-remote -t "$hash" -i | perl -n -E 'say $1 if /^\s*Id: ([0-9]+)$/' )"
You can combine those all in one line, of course. And you'll have to add your server/authentication options to that tramission-remote
line. (Personally, I have a t-r
script which does that and also adds even-odd row highlighting to -l
output). It looks like this:
#!/bin/bash
if ! [ -r ~/.transmission-netrc ]; then
echo Expected to find a ~/.transmission-netrc file with the username
echo and password.
exit 1
fi
if [ "xterm" == "$TERM" ]; then
export TERM=xterm-256color
fi
transmission-remote «HOSTNAME» -N ~/.transmission-netrc "$@" | (
if [ "-l" == "$1" ]; then
sed -e "1~2 s|^|`tput setab 149``tput el`|" -e "2~2 s|^|`tput setab 221``tput el`|"
tput setab 7
tput el
else
cat
fi
)
Note the «HOSTNAME» you'd need to fill in.
-t
)? – derobert May 5 '17 at 16:08