Sequential download script/plugin

Suggest, post, or discuss plugins for Deluge
aXis
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.

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

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

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

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

#!/usr/bin/python
#-*- coding:utf-8 -*-

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

# Some logic and code Copyright (C) mvoncken.
# http://forum.deluge-torrent.org/memberlist.php?mode=viewprofile&u=407

'''
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
time.
'''

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

sclient.set_core_uri()

PRIO_NORMAL = 1
PRIO_HIGH = 2
PRIO_MAX = 5
PRIO_DND = 0

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


####################
def main():
  global AMOUNT_HIGH, AMOUNT_HIGHEST
 
  parser = OptionParser()
  parser.add_option("--high", dest="high", type="int", default=2,
         help="Set the amount of files that will get a high priority.",
         metavar="AMOUNT")
  parser.add_option("--highest", dest="highest", type="int", default=1,
         help="Set the amount of files that will get the highest priority.",
         metavar="AMOUNT")
  parser.add_option("--label", dest="label", type="string", default="inorder",
         help="Only set the priorities for torrents with this label.",
         metavar="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."""
  global AMOUNT_HIGH, AMOUNT_HIGHEST
 
  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.next() == PRIO_DND:
      priorities.append(PRIO_DND)
    else:
      priorities.append(PRIO_NORMAL)
  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
    counter+=1
 
  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:
      files.append(index)
 
  return files


####################
if __name__ == "__main__":
  main()


alexrayne
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?

terror_macbeth_I
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: http://dev.deluge-torrent.org/wiki/Plugins/AutoPriority
It behaves almost the same as the different scripts do, with some minor tweaks.
Tested against deluge 1.2.1

terror_macbeth_I
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: http://dev.deluge-torrent.org/ticket/1474

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.

http://dev.deluge-torrent.org/attachment/wiki/Plugins/AutoPriority/AutoPriority-0.5.1-py2.6.egg

GutenYe

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.

terror_macbeth_I
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.

AutoPriority-0.5.1-py2.7.egg
(14.98 KiB) Downloaded 288 times


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

amb07

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?

Cas
Top Bloke
Top Bloke
Posts: 3381
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 core.py the priority mapping needs altered due to priority changes made in 1.3.3

So:

Code: Select all

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

becomes:

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.
Attachments
AutoPriority-0.5.1a-py2.7.egg
(14.95 KiB) Downloaded 382 times


Return to “Plugins”

Who is online

Users browsing this forum: Google [Bot] and 24 guests