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

    • OMV 2.x

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • 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.
    • 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)


      1. #!/bin/bash
      2. destinationPath="/media/7f2d80ba-2a7c-4708-b601-673b304243fa/MySeries/"
      3. 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


      1. #!/bin/bash
      2. destinationPath="/media/7f2d80ba-2a7c-4708-b601-673b304243fa/MySeries/"
      3. 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


      1. #!/bin/bash
      5. destinationPath="/media/7f2d80ba-2a7c-4708-b601-673b304243fa/MySeries/"
      6. 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.
      New wiki
      chat support at #openmediavault@freenode IRC | Spanish & English | GMT+10 broadcast channel
      openmediavault discord server

      The post was edited 1 time, last by subzero79 ().