Page 1 of 1

Can I execute some script when torrent finished

Posted: Wed May 13, 2009 1:15 am
by ibear
Something like rtorrent, when torrent is finished, exec some script: move/copy/delete some file that downloaded, etc.

Re: Can I execute some script when torrent finished

Posted: Wed May 13, 2009 8:38 am
by johnnyg
there's a plugin in trunk which does this, it should be available in 1.2

Re: Can I execute some script when torrent finished

Posted: Wed May 13, 2009 1:05 pm
by jazd
Any ETA on 1.2?

Re: Can I execute some script when torrent finished

Posted: Thu Jun 18, 2009 8:48 am
by jazd
jazd wrote:Any ETA on 1.2?
Yes? No?

Re: Can I execute some script when torrent finished

Posted: Thu Jun 18, 2009 9:04 am
by johnnyg
There's no official release date for 1.2; it'll be released when it's ready :)

Re: Can I execute some script when torrent finished

Posted: Mon Jun 29, 2009 12:18 am
by jazd
johnnyg wrote:There's no official release date for 1.2; it'll be released when it's ready :)
Fair enough, is there any way to run a script when a torrent finishes in 1.1.9 then? I think there is a plugin in the repository or something right? Will it work on 1.1.9?

Re: Can I execute some script when torrent finished

Posted: Mon Jun 29, 2009 12:52 am
by johnnyg
the plugin is in trunk (future 1.2) which has rather significant changes to 1.1.9 so no it will unfortunately not work.
I'd suggest either writing a ui client script or using the "move completed to" functionality to run a script.

Re: Can I execute some script when torrent finished

Posted: Mon Jun 29, 2009 3:11 am
by kevinwatt
jazd wrote: Fair enough, is there any way to run a script when a torrent finishes in 1.1.9 then? I think there is a plugin in the repository or something right? Will it work on 1.1.9?
Here is an ui client example may helpful.

Code: Select all

#!/usr/bin/env python
from deluge.ui.client import sclient
sclient.set_core_uri()
torrent_ids = sclient.get_session_state()

TORRENT_KEYS = ['name', 'total_size', 'num_files', 'num_pieces', 'piece_length',
    'eta', 'ratio', 'file_progress', 'distributed_copies', 'total_done',
    'total_uploaded', 'state', 'paused', 'progress', 'next_announce',
    'total_payload_download', 'total_payload_upload', 'download_payload_rate',
    'upload_payload_rate', 'num_peers', 'num_seeds', 'total_peers', 'total_seeds',
    'total_wanted', 'tracker', 'trackers', 'tracker_status', 'save_path',
    'files', 'file_priorities', 'compact', 'max_connections',
    'max_upload_slots', 'max_download_speed', 'prioritize_first_last',
    'private','max_upload_speed','queue','peers',
    "active_time", "seeding_time", "seed_rank", "is_auto_managed", #stats
    "stop_at_ratio","stop_ratio","remove_at_ratio" #ratio
    ]

cmp=([],[])

for id in torrent_ids:
    idstatus=sclient.get_torrent_status(id,TORRENT_KEYS)
    if idstatus['progress']==100:
        #for x in idstatus.keys():
        #    print x,idstatus[x]
        cmp[0].append(id)
        cmp[1].append(idstatus['name'])

sclient.remove_torrent(cmp[0],None)
import shutil,os
for x in cmp[1]:
   #shutil.move('/home/kevin/Downloads/'+x.encode("utf-8"),'/home/kevin/cmp/')
   print 'move ',x,'to','/home/kevin/cmp/'
   # http://docs.python.org/library/os.html#os-process
   # os.execl('/bin/ls','-al')