Sequential download script/plugin

Suggest, post, or discuss plugins for Deluge
New User
New User
Posts: 4
Joined: Tue Apr 21, 2009 2:49 am

Re: [In progress] Sequential download plugin

Postby aXis » Thu Apr 23, 2009 8:00 am

I just added mine as a cron job. Once every hour or so should be fine.

Posts: 21
Joined: Fri Oct 10, 2008 11:51 pm
OS or Distro: XUbuntu
Location: Amsterdam, Netherlands

Re: [In progress] Sequential download plugin

Postby DaVince » Thu Apr 23, 2009 9:42 pm

It's nice to see some improvement. :) I myself haven't worked on the script or plugin at all anymore because I now use the lighter torrent client Transmission (yes, I like Deluge better, but I definitely need as much available resources as possible on my Eee PC :P).

So, it looks like this is indeed a one-shot, unless someone's willing to write a plugin instead (I still might do it myself at some point, but... yeah).

Super Seeder
Super Seeder
Posts: 315
Joined: Sat Aug 18, 2007 2:28 pm
OS or Distro: WHS
Location: Pittsburgh, USA

Re: [In progress] Sequential download plugin

Postby gazpachoking » Wed Jun 17, 2009 12:46 am

I made a couple small modifications to the script:
-It now only acts upon torrents with the label 'inorder' (or something else you specify)
-Respects Do Not Download priority of files

Here it is:

Code: Select all

#-*- coding:utf-8 -*-

# "Alphabetic Downloader" v0.1
# Copyright (C) 2009 Vincent Beers (DaVince) <>

# Some logic and code Copyright (C) mvoncken.

This Deluge script sets the file priorities in a torrent file
so that the first encountered incomplete file will get the highest
priority. Benefits for this are that the first next episode in a
series will be downloaded first, instead of all episodes at the same

from optparse import OptionParser
from deluge.ui.client import sclient



#Definitions for the amount of files that will
#have their priority set to highest/high.
LABEL = "inorder"

def main():
  parser = OptionParser()
  parser.add_option("--high", dest="high", type="int", default=2,
         help="Set the amount of files that will get a high priority.",
  parser.add_option("--highest", dest="highest", type="int", default=1,
         help="Set the amount of files that will get the highest priority.",
  parser.add_option("--label", dest="label", type="string", default="inorder",
         help="Only set the priorities for torrents with this label.",
  (options, args) = parser.parse_args()
  AMOUNT_HIGHEST = options.highest
  AMOUNT_HIGH = options.high
  LABEL = options.label
  torrents = sclient.get_torrents_status({"state":"Downloading", "label":LABEL}, ["name", "file_progress", "files", "file_priorities"]).items()
  for torrent_id, torrent in torrents:
    set_priorities(torrent_id, torrent)

def set_priorities(torrent_id, torrent):
  """Set the priorities for not completely downloaded files in the passed torrent."""
  incomplete_files = get_incomplete_files(torrent)
  files = [f["path"] for f in torrent["files"]]
  #priorities = [PRIO_NORMAL for f in torrent["files"]] #Reset priorites first.
  priorities = []
  counter = 0
  prio = iter(torrent["file_priorities"])
  for f in torrent["files"]:
    if == PRIO_DND:
  counter = 0
  print "File:", torrent["name"]
  #Do the magic of priority setting.
  for file in incomplete_files:
    if counter < AMOUNT_HIGHEST:
      priorities[file] = PRIO_MAX
      print (" " + files[file] + " gets highest priority.")
    elif counter < (AMOUNT_HIGH + AMOUNT_HIGHEST):
      priorities[file] = PRIO_HIGH
      print (" " + files[file] + " gets high priority.")
    else: break
  sclient.set_torrent_file_priorities(torrent_id, priorities)

def get_incomplete_files(torrent):
  """Find incomplete files in a torrent and return them in an array."""
  files = []
  filenames = [f["path"].lower() for f in torrent["files"]]
  for filename in sorted(filenames):
    index = filenames.index(filename)
    progress = torrent["file_progress"][index]
    dnd = torrent["file_priorities"][index]
    if progress < 1 and not dnd == PRIO_DND:
  return files

if __name__ == "__main__":

New User
New User
Posts: 9
Joined: Sun Mar 07, 2010 3:38 pm

Re: Sequential download script/plugin

Postby alexrayne » Sun Mar 07, 2010 4:04 pm

is there anywhen this pluginn will be completed for usable stage? or work on this has stopped?
imho, it would be much more sugestions and strategies implemented for sequential downloading,( the most need for me is to faster complete downloading files that have alredy most downloaded, and some anothers...) is there anybody who works on it still?
as i understand torrent comunity was convict and resist on sequental downloading technique, maybe this trend was frighten developers from here?

New User
New User
Posts: 4
Joined: Wed Mar 24, 2010 3:41 am
OS or Distro: Debian testing

Re: Sequential download script/plugin

Postby terror_macbeth_I » Wed Mar 24, 2010 5:33 pm

I have added a plugin AutoPriority to the wiki:
It behaves almost the same as the different scripts do, with some minor tweaks.
Tested against deluge 1.2.1

New User
New User
Posts: 4
Joined: Wed Mar 24, 2010 3:41 am
OS or Distro: Debian testing

Re: Sequential download script/plugin

Postby terror_macbeth_I » Thu Jan 06, 2011 2:25 pm

I fixed some problems with the plugin. There was an issue with the default values right after enabling it. I worked around it, but also opened a ticket:

Another one was that it would set the priorities on all downloading torrents, instead of just the ones with the appropriate label. This issue arose with some newer deluge version, as asking deluge for torrents which are downloading and have a specific label (via "core.get_torrents_status") would always return all downloading torrents. I am not sure if I shall open a ticket for that.

In any case it is working now as intended. Tested with deluge 1.2.3 & 1.3.1.
Have fun.


Re: Sequential download script/plugin

Postby GutenYe » Sun Aug 21, 2011 7:02 am

Have a py2.7 version for AutoPriority?

besides, I think it's good to put source code in github. easy to discussion an issue, submit a patch, and so on.

New User
New User
Posts: 4
Joined: Wed Mar 24, 2010 3:41 am
OS or Distro: Debian testing

Re: Sequential download script/plugin

Postby terror_macbeth_I » Sun Aug 21, 2011 8:59 am

Attached is an egg build with 2.7, not tested.
The trac wiki seems broken at the moment, atleast I can not modify the wiki page and I get a "Warning: <acct_mgr.web_ui.MessageWrapper object at 0xb8c37d2c>". I had to recreate my account too, propably due to inactivity, so hard to tell what the issue is there.
Currently I am short on time, I will clean up the plugin and put it on Github or Bitbucket when this changes.

(14.98 KiB) Downloaded 306 times

EDIT: I was too hasty and forgot to verify my email when recreating my account. The wiki page is now updated.


Re: Sequential download script/plugin

Postby amb07 » Wed Oct 26, 2011 6:26 pm

AutoPriority-0.5.1-py2.7.egg doesn't set highest priority in Deluge 1.3.3. It sets high priority to files which should be set to highest. Any idea how to fix this?

Top Bloke
Top Bloke
Posts: 3426
Joined: Mon Dec 07, 2009 6:04 am
OS or Distro: Ubuntu 16.04
Location: Scotland

Re: Sequential download script/plugin

Postby Cas » Wed Oct 26, 2011 10:10 pm

I would assume because in the priority mapping needs altered due to priority changes made in 1.3.3


Code: Select all

    "priorities_mapping": {"highest": 5,
                           "high": 2,
                           "norm": 1,
                           "dnd": 0},


Code: Select all

    "priorities_mapping": {"highest": 7,
                           "high": 5,
                           "norm": 1,
                           "dnd": 0},

I have attached an updated egg to see if that works for you.
(14.95 KiB) Downloaded 409 times

Return to “Plugins”

Who is online

Users browsing this forum: No registered users and 3 guests