Auto tidyup

Discussion of Transmission that doesn't fit in the other categories
Post Reply
maldax
Posts: 4
Joined: Tue Jan 18, 2011 7:47 pm

Auto tidyup

Post by maldax »

Hello all,

I have installed freeNAS and using Transmission & Sick Beard together. As Sick Beard moves completed downloads to new file structure I was always cleaning up completed downloads so knocked up a little script that I cron every 30 mins. Works a treat so thought I would share

Code: Select all

#!/bin/bash

#delete seeds

USER=xxxxxxxx
PASSWD=xxxxxxxxxx

torrent_ids=$(/usr/local/bin/transmission-remote -n $USER:$PASSWD -l |  grep "100%" | cut -b 1-4 )        

for index in $torrent_ids; do
       
                /usr/local/bin/transmission-remote -n $USER:$PASSWD -t $index --remove
        
        
done
Last edited by maldax on Tue Jan 18, 2011 8:13 pm, edited 1 time in total.
ijuxda

Re: Auto tidyup

Post by ijuxda »

In case the torrent ids exceed 4 digits, instead of

Code: Select all

cut -b 1-4
perhaps

Code: Select all

awk '{print $1}'
would be better.
Last edited by ijuxda on Mon Feb 14, 2011 4:01 am, edited 1 time in total.
maldax
Posts: 4
Joined: Tue Jan 18, 2011 7:47 pm

Re: Auto tidyup

Post by maldax »

Hi

Yea I went with that to start but sometimes had an * at the end of the torrent id.
ijuxda

Re: Auto tidyup

Post by ijuxda »

Then perhaps

Code: Select all

awk '{ if ($2 == "100%") print $1 }' | sed 's/*$//'
would be best. It also handles the case when the string "100%" happens to be part of the file name.
Last edited by ijuxda on Mon Feb 14, 2011 4:02 am, edited 1 time in total.
ijuxda

Re: Auto tidyup

Post by ijuxda »

I.e.

Code: Select all

torrent_ids=$(/usr/local/bin/transmission-remote -n $USER:$PASSWD -l | awk '{ if ($2 == "100%") print $1 }' | sed 's/*$//')
Last edited by ijuxda on Mon Feb 14, 2011 4:02 am, edited 1 time in total.
maldax
Posts: 4
Joined: Tue Jan 18, 2011 7:47 pm

Re: Auto tidyup

Post by maldax »

Thanks for that! Had not thought of the "100%" in the filename thing. That was what I had first but didnt think of piping in through sed :)
maldax
Posts: 4
Joined: Tue Jan 18, 2011 7:47 pm

Re: Auto tidyup

Post by maldax »

Version 2 ;-)

Code: Select all

#!/bin/bash

#delete seeds

USER=xxxxxxxx
PASSWD=xxxxxxxxxx

torrent_ids=$(/usr/local/bin/transmission-remote -n $USER:$PASSWD -l | awk '{ if ($2 == "100%") print $1 }' | sed 's/*$//')      

for index in $torrent_ids; do
       
                /usr/local/bin/transmission-remote -n $USER:$PASSWD -t $index --remove
        
        
done

killemov
Posts: 573
Joined: Sat Jul 31, 2010 5:04 pm

Re: Auto tidyup

Post by killemov »

How would Sick Beard know when a torrent is finished? Does it interface with transmission? If so, then that would probably be the proper channel for cleanup.

This construction would only work with a 1-file torrent. I suggest implementing some file-move-and-cleanup functionality in a torrent-done script.
Post Reply