Transmission - Script to move completed downloads to directories, or how to create script?

  • I'm sure a script is already out there, but have no luck with Googling. I just want the script to monitor the folder, and once it completes, move it to to correct path, either Movies or TV. I do not want Transmission to download to the Movie/TV Folder, I want it to complete, and then move it.


    At the very least, what type of script is used. Is it Python? I have no idea, but wouldn't mind learning a thing or 2 and writing it myself or adjusting an existing script.

    • Offizieller Beitrag

    When transmission finishes a torrent it passes the following environmental variables to the done script


    TR_TORRENT_DIR (example /media/7f2d80ba-2a7c-4708-b601-673b304243fa/downloads)
    TR_TORRENT_NAME (example Arrow.S04E16.HDTV.x264-LOL)
    TR_TORRENT_ID (this is the numeric id that gets displayed at transmission-remote -l), is a number example 15)


    With those vars you can do whatever you want either by bash shell, php, or using the transmission api using transmission-remote binary.
    You can get the id by executing transmission-remote localhost:9091 -n admin:password -l
    Example (this is dirty, i'll move the file when is finished an i'll probably report an error in the webUI that data went missing)


    Bash
    #!/bin/bash 
    
    
    destinationPath="/media/7f2d80ba-2a7c-4708-b601-673b304243fa/MySeries/"
    mv "${TR_TORRENT_DIR}"/"${TR_TORRENT_NAME}" "${destinationPath}"


    this other for example will use the transmission-remote binary using API, the torrent will be kept in transmission seeding but at a different destination


    Bash
    #!/bin/bash 
    
    
    destinationPath="/media/7f2d80ba-2a7c-4708-b601-673b304243fa/MySeries/"
    transmission-remote localhost:9091 -n admin:password -t "${TR_TORRENT_ID}" --move "${destinationPath}"


    Now testing this is a PITA for a person that doesn't know scripting would be waiting every time for the torrent to finish to watch the script doing the job. So your script would have to look like this


    Bash
    #!/bin/bash 
    
    
    TR_TORRENT_DIR=${TR_TORRENT_DIR:-$1}
    TR_TORRENT_NAME=${TR_TORRENT_NAME:-$2}
    TR_TORRENT_ID=${TR_TORRENT_ID:-$3}
    destinationPath="/media/7f2d80ba-2a7c-4708-b601-673b304243fa/MySeries/"
    
    
    transmission-remote localhost:9091 -n admin:password -t "${TR_TORRENT_ID}" --move "${destinationPath}"


    So now you can test your script without waiting for transmission to finish a job, you go to the folder where the script is then you executed like this


    ./myscript "/media/7f2d80ba-2a7c-4708-b601-673b304243fa/downloads" "Arrow.S04E16.HDTV.x264-LOL" "14"


    The script will pass the positional arguments (path [1], folder name [2] and id [3]) to the expected transmission variables.

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!