Skip to content

Instantly share code, notes, and snippets.

@germs12
Last active June 10, 2024 14:27
Show Gist options
  • Save germs12/5281312 to your computer and use it in GitHub Desktop.
Save germs12/5281312 to your computer and use it in GitHub Desktop.
Transmission Moving Files Brah.
#!/bin/sh
PRE="transmission-remote --auth=brown:sugar"
MOVEDIR=/mnt/media1/downloads
TVSHOWSDIR="$MOVEDIR/tvshows"
MOVIESDIR="$MOVEDIR/movies"
MUSICDIR="$MOVEDIR/music"
TORRENTLIST=`$PRE --list | sed -e '1d;$d;s/^ *//' | cut --only-delimited --delimiter=' ' --fields=1`
echo "$PRE"
echo "$TORRENTLIST"
for TORRENTID in $TORRENTLIST
do
echo "* * * * * Operations on torrent ID $TORRENTID starting. * * * * *"
TORRENT_INFO="--torrent $TORRENTID --info"
DL_INFO=`$PRE --torrent $TORRENTID --info `
DL_MUSIC=`$PRE --torrent $TORRENTID --info | grep "tracker.what.cd"`
DL_MOVED=`$PRE $TORRENT_INFO | grep "Location" | awk '{print match($2, "^/mnt/media1/downloads$")}' | sed -e "/[\d]/"`
echo "$PRE $TORRENT_INFO"
DL_NAME=`$PRE $TORRENT_INFO | grep -i "name" | awk '{
tmp = match($2, ".[sS][0-9]{2}[eE][0-9]{2}")
name = substr($2, 0, tmp-1)
folder_name = gensub(/\./,".", "g", name)
}END{print name}' | sed -e "s/\b\(.\)/\u\1/g"`
DL_MOVIE=`$PRE --torrent $TORRENTID --info | grep "please.passthepopcorn.me"`
DL_TVSHOW=`$PRE --torrent $TORRENTID --info | grep ".tvtorrents.com"`
DL_COMPLETED=`$PRE --torrent $TORRENTID --info | grep "Percent Done: 100%"`
STATE_STOPPED=`$PRE --torrent $TORRENTID --info | grep "State: Stopped\|Finished\|Idle"`
if [ "$DL_COMPLETED" != "" ] && [ "$STATE_STOPPED" != "" ]; then
echo "Torrent #$TORRENTID is completed."
echo ":: $DL_INFO"
#echo ""
if [ "$DL_MUSIC" != "" ]; then
echo "Moving music file(s) to $MUSICDIR."
$PRE --torrent $TORRENTID --move $MUSICDIR
#echo "$PRE --torrent $TORRENTID --move $MUSICDIR"
fi
if [ "$DL_MOVIE" != "" ]; then
echo "Moving movie file(s) to $MOVIESDIR."
$PRE --torrent $TORRENTID --move $MOVIESDIR
echo "$PRE --torrent $TORRENTID --move $MOVIESDIR"
fi
SERIES="$TVSHOWSDIR/$DL_NAME"
if [ "$DL_TVSHOW" != "" ]; then
echo "Moving tv show file(s) to $SERIES"
$PRE --torrent $TORRENTID --move $SERIES
#echo "$PRE --torrent $TORRENTID --move $TVSHOWSDIR"
fi
else
echo "Torrent #$TORRENTID is not completed. Ignoring."
fi
echo "* * * * * Operations on torrent ID $TORRENTID completed. * * * * *"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment