Can I execute some script when torrent finished

Suggestions and discussion of future versions
Post Reply
ibear

Can I execute some script when torrent finished

Post by ibear »

Something like rtorrent, when torrent is finished, exec some script: move/copy/delete some file that downloaded, etc.
johnnyg
Top Bloke
Top Bloke
Posts: 1522
Joined: Sun Oct 28, 2007 4:00 am
Location: Sydney, Australia

Re: Can I execute some script when torrent finished

Post by johnnyg »

there's a plugin in trunk which does this, it should be available in 1.2
jazd
Member
Member
Posts: 17
Joined: Wed May 13, 2009 8:16 am

Re: Can I execute some script when torrent finished

Post by jazd »

Any ETA on 1.2?
jazd
Member
Member
Posts: 17
Joined: Wed May 13, 2009 8:16 am

Re: Can I execute some script when torrent finished

Post by jazd »

jazd wrote:Any ETA on 1.2?
Yes? No?
johnnyg
Top Bloke
Top Bloke
Posts: 1522
Joined: Sun Oct 28, 2007 4:00 am
Location: Sydney, Australia

Re: Can I execute some script when torrent finished

Post by johnnyg »

There's no official release date for 1.2; it'll be released when it's ready :)
jazd
Member
Member
Posts: 17
Joined: Wed May 13, 2009 8:16 am

Re: Can I execute some script when torrent finished

Post 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?
johnnyg
Top Bloke
Top Bloke
Posts: 1522
Joined: Sun Oct 28, 2007 4:00 am
Location: Sydney, Australia

Re: Can I execute some script when torrent finished

Post 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.
kevinwatt
New User
New User
Posts: 4
Joined: Mon Jun 22, 2009 9:05 am

Re: Can I execute some script when torrent finished

Post 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')
Post Reply