Advertisement
Guest User

Untitled

a guest
Feb 28th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.88 KB | None | 0 0
  1. #!/bin/bash
  2. # =============================================================================
  3. #
  4. # argv[0]: File-path to Script
  5. # argv[1]: Final full path to the episode file
  6. # argv[2]: Original full path of the episode file
  7. # argv[3]: Show indexer ID
  8. # argv[4]: Season number
  9. # argv[5]: Episode number
  10. # argv[6]: Episode Air Date
  11. # =============================================================================
  12. #
  13. #
  14. # Configuration
  15. # -----------------------------------------------------------------------------
  16. cfgUsername=transmission
  17. cfgPassword=transmission
  18. cfgHostname=localhost
  19. cfgPort=9091
  20.  
  21. # Processing.
  22. # ----------------------------------------------------------------------------
  23. CONNOPTS="$cfgHostname:$cfgPort --auth=$cfgUsername:$cfgPassword"
  24. FILETOFIND=`basename $2`
  25. TIDS=`transmission-remote $CONNOPTS --list | awk '{print $1}' | grep '[0-9]'`
  26.  
  27. # Loop over torrents.
  28. for TID in $TIDS; do
  29.         # Get files in this torrent.
  30.         FOUND=0
  31.         TFILES=`transmission-remote $CONNOPTS -t $TID -f  | awk 'NR > 2 {print $7}'`
  32.         for TFILE in $TFILES; do
  33.                 # If the this file matches the one from argv[2], then mark this torrent
  34.                 # as needing processing and break out of files loop.
  35.                 THISFILE=`basename $TFILE`
  36.                 if [ "$THISFILE" == "$FILETOFIND" ]; then
  37.                         FOUND=1
  38.                         break
  39.                 fi
  40.         done
  41.  
  42.         # Torrent found based on supplied file name. Check if it's complete and remove.
  43.         if [ $FOUND -eq 1 ]; then
  44.                 DL_COMPLETED=`transmission-remote $CONNOPTS -t $TID --info | grep "Percent Done: 100%"`
  45.                 if [ "$DL_COMPLETED" != "" ]; then
  46.                         echo "Torrent $TID finished. Removing."
  47.                         transmission-remote $CONNOPTS -t $TID --remove-and-delete
  48.                 fi
  49.         fi
  50. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement