Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

use the old sabnzbd module (the new one is far from ready) [#26]

  • Loading branch information...
commit 418983af4c7deb3e08b1462bd1a66ef2b52c2db8 1 parent 4e8abe7
@mrkipling authored
Showing with 27 additions and 200 deletions.
  1. +4 −19 modules.py
  2. +9 −89 sabnzbd.py
  3. +0 −56 static/js/index.js
  4. +14 −36 templates/sabnzbd.html
View
23 modules.py
@@ -97,30 +97,15 @@
{
'name': 'sabnzbd',
'label': 'SABnzbd+',
- 'description': 'Shows you information about your SabNZBd+ downloads.',
+ 'description': 'Shows you information about your SABnzbd+ downloads.',
'static': False,
'poll': 10,
'delay': 0,
'settings': [
{
- 'key': 'sabnzbd_ip',
- 'value': '',
- 'description': 'SabNZBd+ IP',
- },
- {
- 'key': 'sabnzbd_port',
- 'value': '',
- 'description': 'SabNZBd+ Port',
- },
- {
- 'key': 'sabnzbd_api',
- 'value': '',
- 'description': 'SabNZBd+ API Key',
- },
- {
- 'key': 'num_queue_items',
- 'value': 5,
- 'description': 'Number of queue items to show',
+ 'key': 'sabnzbd_url',
+ 'value': 'http://<hostname>:<port>/api?apikey=<apikeygoeshere>',
+ 'description': 'SABnzbd URL',
},
]
},
View
98 sabnzbd.py
@@ -5,115 +5,35 @@
from settings import *
from tools import *
-SABNZBD_IP = get_setting_value('sabnzbd_ip')
-SABNZBD_PORT = get_setting_value('sabnzbd_port')
-SABNZBD_API = get_setting_value('sabnzbd_api')
-
-SABNZBD_URL = 'http://%s:%s/api?apikey=%s' % (SABNZBD_IP, SABNZBD_PORT, SABNZBD_API)
-
-NUM_QUEUE_ITEMS = get_setting_value('num_queue_items')
-
@app.route('/xhr/sabnzbd')
@requires_auth
def xhr_sabnzbd():
+ SABNZBD_URL = get_setting_value('sabnzbd_url')
+
try:
if SABNZBD_URL == None:
raise Exception
- url = '%s&mode=queue&start=START&limit=LIMIT&output=json' % (SABNZBD_URL)
+ url = '%s&mode=qstatus&output=json' % (SABNZBD_URL)
result = urllib.urlopen(url).read()
- sabnzbd_base = json.JSONDecoder().decode(result)
- sabnzbd = sabnzbd_base['queue']
+ sabnzbd = json.JSONDecoder().decode(result)
percentage_total = 0
- download_speed = '%s kB/s' % (int(float(sabnzbd['kbpersec'])))
+ download_speed = '%s kB/s' % (int(sabnzbd['kbpersec']))
- if sabnzbd['slots']:
- percentage_total = int(sabnzbd['slots'][0]['percentage'])
+ if sabnzbd['paused']:
+ download_speed = "PAUSED"
- num_queue_items = int(NUM_QUEUE_ITEMS)
-
- if num_queue_items > len(sabnzbd['slots']) + 1:
- num_queue_items = len(sabnzbd['slots']) - 1
- if num_queue_items < 0:
- num_queue_items = 0
+ if sabnzbd['jobs']:
+ percentage_total = int(100 - (sabnzbd['mbleft'] / sabnzbd['mb'] * 100))
except:
sabnzbd = None
percentage_total = None
download_speed = None
- num_queue_items = None
return render_template('sabnzbd.html',
sabnzbd = sabnzbd,
percentage_total = percentage_total,
download_speed = download_speed,
- num_queue_items = num_queue_items,
- )
-
-@app.route('/sabnzbd/<state>')
-@requires_auth
-def state_change(state):
- try:
- if SABNZBD_URL == None:
- raise Exception
-
- url = '%s&mode=%s' % (SABNZBD_URL, state)
- result = urllib.urlopen(url).read()
-
- except:
- sabnzbd = None
- percentage_total = None
- download_speed = None
-
- return result
-
-@app.route('/sabnzbd/set_speed/<speed>')
-@requires_auth
-def set_speed(speed):
- try:
- if SABNZBD_URL == None:
- raise Exception
-
- url = '%s&mode=config&name=speedlimit&value=%s' % (SABNZBD_URL, speed)
- result = urllib.urlopen(url).read()
-
- except:
- sabnzbd = None
-
- return result
-
-@app.route('/sabnzbd/remove/<sabid>')
-@requires_auth
-def remove_item(sabid):
- try:
- if SABNZBD_URL == None:
- raise Exception
-
- url = '%s&mode=queue&name=delete&value=%s' % (SABNZBD_URL, sabid)
- result = urllib.urlopen(url).read()
- if result.rfind('ok') >= 0:
- result = sabid
-
- except:
- result = False
-
- return result
-
-@app.route('/sabnzbd/history')
-@requires_auth
-def sab_history():
- try:
- if SABNZBD_URL == None:
- raise Exception
-
- url = '%s&mode=history&start=START&limit=LIMIT&output=json' % (SABNZBD_URL)
- result = urllib.urlopen(url).read()
- history = json.JSONDecoder().decode(result)
-
- except:
- history = None
-
- return render_template('sabnzbd-history.html',
- history = history['history']['slots'],
)
View
56 static/js/index.js
@@ -458,62 +458,6 @@ $(document).ready(function() {
});
});
- // SABNZBD
- $('#sabnzbd #extra-queue').live('click', function() {
- $('#sabnzbd_next').toggle('slow');
- $('#sabnzbd #extra-queue').toggleClass('rotate');
- });
-
- //Pause/Resume Sab Queue
- $('#sabnzbd .inner #status').live('click', function(){
- if($('#sabnzbd .inner #status').text().indexOf('Paused') >= 0){
- $.get('/sabnzbd/resume');
- } else {
- $.get('/sabnzbd/pause');
- }
- });
-
- //Speed Box: when enter is pressed, it runs the get request.
- $('#sabnzbd .inner .speed input').live('keydown', function(){
- if(event.keyCode == 13){
- $.get('/sabnzbd/set_speed/'+$(this).val());
- }
- });
-
- $('#sabnzbd .inner #sabnzbd_next img.remove').live('click', function(){
- $.get('/sabnzbd/remove/'+$(this).attr('value')).success(function(data) {
- $('#'+data).hide(1000);
- });
- });
-
- $('#sabnzbd .menu .history').live('click', function(){
- $.get('/sabnzbd/history' , function(data, responseText){
- var content = $(data);
- $('#sabnzbd').html(content.html());
- $("#history").tablesorter({widthFixed: true}).tablesorterPager({container: $("#pager")});
- });
- });
-
- $('#sabnzbd .menu .queue').live('click', function(){
- $.get('/xhr/sabnzbd' , function(data, responseText){
- var content = $(data);
- $('#sabnzbd').html(content.html());
- });
- });
-
- // SAB Menu SHOW
-/*
- $('#sabnzbd .title').live('focusin', function(){
- $('#sabnzbd .menu').show('slow');
- });
- $('#sabnzbd .title').live('focusout', function(){
- $('#sabnzbd .menu').hide();
- });
-*/
- $('#sabnzbd .title').live('click', function(){
- $('#sabnzbd .menu').toggle('slow');
- });
-
/*** SICKBEARD ***/
//Search Episode Functionality on Magnifying Glass png
$('#sickbeard div.options img.search').live('click', function(){
View
50 templates/sabnzbd.html
@@ -1,28 +1,19 @@
-{% if sabnzbd.slots %}
+{% if sabnzbd.jobs %}
+
<div id="sabnzbd" class="module" data-module="sabnzbd">
+
<div class="module_settings"><span>Settings</span></div>
<div class="module_remove"><span>Remove</span></div>
- <h2 class="title">SabNZBd+</h2>
- <div class="menu">
- <p class="queue">Queue</p>
- <p class="history">History</p>
- </div>
+ <h2>SABnzbd+</h2>
+
<div class="inner">
- <div class="status" id="status">
- <a>
- {% if sabnzbd.paused == True %}
- <strong title="Resume SabNZBd+">Paused</strong>
- {% else %}
- <strong title="Pause SabNZBd+">Downloading</strong>
- {% endif %}
- </a>
- </div>
- <div class="speed">
- <input class="sab_speed" type="text" value="{{ download_speed[:-5] }}" title="Adjust Speed" size="6"/>{{ download_speed[-5:] }}
- </div>
+
+ <div class="speed">{{ download_speed }}</div>
+
<p>
- {{ sabnzbd.slots[0].filename|truncate(42,true)}}
+ <strong>Currently downloading:</strong>
+ "{{ sabnzbd.jobs[0].filename }}"
</p>
<div class="bar">
@@ -30,30 +21,17 @@ <h2 class="title">SabNZBd+</h2>
</div>
<div class="clearfix">
- <p class="remaining"><strong>Remaining:</strong> {{ sabnzbd.slots[0].timeleft }} - {{ sabnzbd.slots[0].mbleft|int }}/{{ sabnzbd.slots[0].mb|int }} MB</p>
+ <p class="remaining"><strong>Remaining:</strong> {{ sabnzbd.timeleft }} / {{ sabnzbd.mbleft|int }} MB</p>
<p class="percentage_complete">{{ percentage_total }}% complete</p>
</div>
- {% if sabnzbd.slots|length > 1 %}
- <br>
- <a class="status" id="extra-queue" title="Toggle Queue"><span></span></a>
- <div id="sabnzbd_next" style="display:none;">
- <table style="width: 100%; table-layout:fixed;">
- {% for i in range(1, num_queue_items-1) %}
- <tr id="{{ sabnzbd.slots[i].nzo_id }}">
- <td width="80%" class="extra_name">{{ sabnzbd.slots[i].filename }}<td/>
- <td width="25%" align="right">{{ sabnzbd.slots[i].mb|int }} MB <img class="remove" id="tipsy" value="{{sabnzbd.slots[i].nzo_id}}" title="Remove" src="/static/images/remove_icon.png" width="8" height="8" /></td>
- </tr>
- {% endfor %}
- </table>
- </div>
- {% endif %}
+
</div>
</div>
+
{% else %}
<div class="placeholder" data-module="sabnzbd">
<div class="module_settings"><span>Settings</span></div>
<div class="module_remove"><span>Remove</span></div>
- <h2>SabNZBd+</h2>
+ <h2>SABnzbd+</h2>
</div>
{% endif %}
-
Please sign in to comment.
Something went wrong with that request. Please try again.