Page 1 of 1

Bandwidth Control At The Priority / Category Level

Posted: September 23rd, 2014, 7:14 pm
by bzowk
Hey Guys -

I use SABnzbd for a number of things and am a frequent user or categories and priorities per download made. The vast majority of my downloads are automated and come in via feeds, I want to be able to have specific items download as fast as possible while other low-priority items can come in slowly while I use my bandwidth for other things (in other apps / devices) such as FTP or whatever else.

Is there any way (I haven't found one yet) to set the download speed per category and/or priority via app settings, scripts, or other? If not, I would give it my vote as the #1 (and only) additional feature needed!

I've searched online where I've only found requests for similar features way back in 2011, but no solutions. Assuming it isn't a feature, anyone have suggestions for scripts or plug-ins to assist? I've already got download and upload QOS set up via my router which runs Gargoyle, but still it's based off ports and my true want is to have it based off priority inside of the app, itself.

Thanks Guys

Re: Bandwidth Control At The Priority / Category Level

Posted: September 24th, 2014, 1:00 am
by sander
bzowk wrote: Is there any way (I haven't found one yet) to set the download speed per category and/or priority via app settings, scripts, or other?
Not within SABnzbd itself. However, I think you can do it yourself via the SABnzbd API (http://wiki.sabnzbd.org/api), as the API offers info about the queue, and you can set the SABnzbd max speed. So something like:

Code: Select all

repeat:
    get info about current item being dowloaded
    determine speed based on Priority / Category
    set speed via API
    wait 1 minute
bzowk wrote: If not, I would give it my vote as the #1 (and only) additional feature needed!
Of course! ;)

Re: Bandwidth Control At The Priority / Category Level

Posted: September 24th, 2014, 9:00 pm
by bzowk
Not quite sure how to apply the code, but will look though the documentation. Thanks for the suggestion!

Re: Bandwidth Control At The Priority / Category Level

Posted: September 24th, 2014, 9:21 pm
by bzowk
OK, been trying a few things via Wiki. Still don't see how to integrate code you suggested, though. It's multi-line so wouldn't be via address line. How would I start playing with it? Thanks!

Re: Bandwidth Control At The Priority / Category Level

Posted: September 25th, 2014, 12:04 am
by sander
It's not code; it's pseudo code to give an idea of what you could do in a real language like Python.

Do you know any programming language?

EDIT:

Below is real, working python code that sets the SAB download speed based on category of the current active download.

Code: Select all

# made by the JSON King
#
import json
import urllib

apikey = 'b463b755ad289e4fd2e2e7319ab6eacf'
baseurl = 'http://localhost:8080/'
importcategory = 'superman2'

def setSpeed(speedkBps):
	# Example: Set download speed to 400 kB/s:	
	# 'http://localhost:8080/api?mode=config&name=speedlimit&value=400'
	url = '%sapi?mode=config&name=speedlimit&value=%s&apikey=%s' % (baseurl, speedkBps, apikey)
	urlresult = urllib.urlopen(url)
	return urlresult.read()
	
def getCatActiveDownload():
	# Return Category of item currently being downloaded (if any)
	url = '%sapi?mode=queue&start=START&limit=LIMIT&output=json&apikey=%s' % (baseurl, apikey)
	urlresult = urllib.urlopen(url)
	parsed = json.loads(urlresult.read())
	for thisslot in parsed['queue']['slots'] :
		if thisslot['status'] == 'Downloading':
			# Active download
			return thisslot['cat']
	return None

if getCatActiveDownload() == importcategory :
	print setSpeed(2000000)
else :
	print setSpeed(100)