Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # =============================================================================
- #
- # argv[0]: File-path to Script
- # argv[1]: Final full path to the episode file
- # argv[2]: Original full path of the episode file
- # argv[3]: Show indexer ID
- # argv[4]: Season number
- # argv[5]: Episode number
- # argv[6]: Episode Air Date
- # =============================================================================
- #
- #
- # Configuration
- # -----------------------------------------------------------------------------
- cfgUsername=transmission
- cfgPassword=transmission
- cfgHostname=localhost
- cfgPort=9091
- # Processing.
- # ----------------------------------------------------------------------------
- CONNOPTS="$cfgHostname:$cfgPort --auth=$cfgUsername:$cfgPassword"
- FILETOFIND=`basename $2`
- TIDS=`transmission-remote $CONNOPTS --list | awk '{print $1}' | grep '[0-9]'`
- # Loop over torrents.
- for TID in $TIDS; do
- # Get files in this torrent.
- FOUND=0
- TFILES=`transmission-remote $CONNOPTS -t $TID -f | awk 'NR > 2 {print $7}'`
- for TFILE in $TFILES; do
- # If the this file matches the one from argv[2], then mark this torrent
- # as needing processing and break out of files loop.
- THISFILE=`basename $TFILE`
- if [ "$THISFILE" == "$FILETOFIND" ]; then
- FOUND=1
- break
- fi
- done
- # Torrent found based on supplied file name. Check if it's complete and remove.
- if [ $FOUND -eq 1 ]; then
- DL_COMPLETED=`transmission-remote $CONNOPTS -t $TID --info | grep "Percent Done: 100%"`
- if [ "$DL_COMPLETED" != "" ]; then
- echo "Torrent $TID finished. Removing."
- transmission-remote $CONNOPTS -t $TID --remove-and-delete
- fi
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement