Ejemplo n.º 1
0
def output():
    
    # Build the API request
    request_param = {"mode": "history", "output": "json", "apikey": str(appSettings.sa_api_key)}
    
    r = {}
    r = appData.getJSON(request_param, str(appSettings.sabnzbd_url))
    
    if r['error']:
        print r['error_description']
    
    response = appFunctions.Struct(**r['result']['history'])
    
    # has the API Call worked? Is there an error?
    if hasattr(response, "result") and response.result != "success":
        print "<span class=\"error\">Error! " + response.message + "</span>"
        return

    if len(response.slots) == 0:
        print "<span class='error'>No items in history</span>"

    for item in response.slots[:5]:
        
        if str(item['status']) == "Completed":
            print "<div class='sab_history_item_completed'>"
            print "<div class='sab_history_item_details'><span class='sab_history_item_filename'>" + item['name'] + "</span><br />"
            print "<span class='sab_history_item_status'>(" + str(item['status']) + ")</span><br />"
            print "</div></div>"
        else:
            print "<div class='sab_history_item_failed'>"
            print "<div class='sab_history_item_details'><span class='sab_history_item_filename'>" + item['name'] + "</span><br />"
            print "<span class='sab_history_item_status'>(" + str(item['status']) + ": " + str(item['fail_message']) + ")</span><br />"
            print "</div></div>"
Ejemplo n.º 2
0
def output():
    # Build the API request
    request_param = {"mode": "queue", "output": "json", "apikey": str(appSettings.sa_api_key)}
    
    r = {}
    r = appData.getJSON(request_param, str(appSettings.sabnzbd_url))
    
    if r['error']:
        print r['error_description']
    
    response = appFunctions.Struct(**r['result']['queue'])
    
    # has the API Call worked? Is there an error?
    if hasattr(response, "result") and response.result != "success":
        print "<span class=\"error\">Error! " + response.message + "</span>"
        return
    
    if len(response.slots) == 0:
        print "<span class='error'>No items in queue</span>"

    # write the DIV for each download
    for item in response.slots[:5]:
        
        if str(item['status']) == "Paused":
            print "<div id='sab_queue_" + str(item['index']) + "' class='sab_queue_item_paused'>"
            print "<div class='sab_queue_item_details'><span class='sab_queue_item_filename'>" + item['filename'] + "</span><br />"
            print str(item['percentage']) + "% of " + str(item['mb']) + " downloaded<br />"
            print "<span class='sab_queue_item_filename'>(" + str(item['status']) + ")</span><br />"
        else:
            print "<div id='sab_queue_" + str(item['index']) + "' class='sab_queue_item'>"
            print "<div class='sab_queue_item_details'><span class='sab_queue_item_filename'>" + item['filename'] + "</span><br />"
            print str(item['percentage']) + "% of " + str(item['mb']) + " downloaded<br />"
            print str(item['timeleft']) + " til complete<br />"

        print "<div id='progress_" + str(item['index']) + "' class='graph'><div id='bar_" + str(item['index']) + "' style='width:" + str(item['percentage']) + "%'><p>" + str(item['percentage']) + "% complete</p></div></div>"
        print "</div>"
        print "<div class='sab_queue_item_commands'>"
        print "<a href=\"javascript:sa_queue_item_modify('" + str(item['nzo_id']) + "', 'up', '" + appSettings.sabnzbd_url + "?apikey=" + appSettings.sa_api_key + "', " + str(item['index']) + ");\"><img class='button_up' id='sab_queue_item_up_" + str(item['index']) + "' src='assets/up_button.png'></a>"
        print "<a href=\"javascript:sa_queue_item_modify('" + str(item['nzo_id']) + "', 'down', '" + appSettings.sabnzbd_url + "?apikey=" + appSettings.sa_api_key + "', " + str(item['index']) + ");\"><img class='button_down' id='sab_queue_item_down_" + str(item['index']) + "' src='assets/down_button.png'></a>"
        print "<a href=\"javascript:sa_queue_item_modify('" + str(item['nzo_id']) + "', 'pause', '" + appSettings.sabnzbd_url + "?apikey=" + appSettings.sa_api_key + "', " + str(item['index']) + ");\"><img class='button_pause' id='sab_queue_item_pause_" + str(item['index']) + "' src='/assets/pause_button.png'></a>"
        print "<a href=\"javascript:sa_queue_item_modify('" + str(item['nzo_id']) + "', 'play', '" + appSettings.sabnzbd_url + "?apikey=" + appSettings.sa_api_key + "', " + str(item['index']) + ");\"><img class='button_play' id='sab_queue_item_play_" + str(item['index']) + "' src='/assets/play_button.png'></a>"
        print "</div></div>"
Ejemplo n.º 3
0
def output():

    # Build the API request
    request_param = {"mode": "queue", "output": "json", "apikey": str(appSettings.sa_api_key)}

    r = {}
    r = appData.getJSON(request_param, str(appSettings.sabnzbd_url))

    if r["error"]:
        print r["error_description"]

    response = appFunctions.Struct(**r["result"]["queue"])

    # has the API Call worked? Is there an error?
    if hasattr(response, "result") and response.result != "success":
        print '<span class="error">Error! ' + response.message + "</span>"
        return

    if response.status == "Downloading":
        print "Queue state: " + response.status + " (" + str(response.noofslots) + " items)<br />"
        print str(response.timeleft) + " @ " + str(response.kbpersec)
    else:
        print "Queue state: " + response.status + "<br />"
Ejemplo n.º 4
0
def output(day_to_show):

    # Build the API request
    request_param = {"cmd": "future", "sort": "date", "type": "today|soon", "paused": "0"}

    r = {}
    r = appData.getJSON(request_param, str(appSettings.sickbeard_url))

    if r['error']:
        print r['error_description']

    response = appFunctions.Struct(**r['result'])

    # has the API Call worked? Is there an error?
    if hasattr(response, "result") and response.result != "success":
        print "<span class=\"error\">Error! " + response.message + "</span>"
        return

    show_list = []
    x = 0

    if day_to_show == "all":

        # add the TODAY shows
        for item in response.data['today']:
            item['class'] = "today" # used to style the resultant DIV
            item['sequence'] = x    # used for the rotating banner
            item['due'] = "Today"
            show_list.append(item)
            x += 1

        # add the SOON shows
        for item in response.data['soon']:
            item['class'] = "soon" # used to style the resultant DIV
            item['sequence'] = x   # used for the rotating banner
            item['due'] = appFunctions.relative_date(item['airdate'])
            show_list.append(item)
            x += 1

    else:
    
        # add the TODAY shows
        for item in response.data['today']:
            if appFunctions.day_number(item['airdate']) == appFunctions.day_number(day_to_show):
                item['class'] = "today" # used to style the resultant DIV
                item['sequence'] = x    # used for the rotating banner
                item['due'] = "Today"
                show_list.append(item)
                x += 1
        
        # add the SOON shows
        for item in response.data['soon']:
            if appFunctions.day_number(item['airdate']) == appFunctions.day_number(day_to_show):
                item['class'] = "soon" # used to style the resultant DIV
                item['sequence'] = x   # used for the rotating banner
                item['due'] = appFunctions.relative_date(item['airdate'])
                show_list.append(item)
                x += 1

    # write the DIV for each show
    for item in show_list:
        print "<div class='sb_banner " + item['class'] + "' id='content-" + str(item['sequence']) + "'>"
        print "<div class='namespace'><span class='show_name'>" + item['show_name'] + "</span><br /><span class='show_title'>" + item['ep_name'] + "</span></div>"   # output the show name
        print "<div class='detailspace'><span class='show_detail'>S " + str(item['season']).zfill(2) + " E " + str(item['episode']).zfill(2) + "<br />" + item['due'] + "</span></div>"     # output episode number and name
        print "<div class='image'><img class='banner_img' src='" + appSettings.sickbeard_url + "?cmd=show.getbanner&tvdbid=" + str(item['tvdbid']) + "' /></div></div>\n"  # output the show banner

    # Rotating DIV banner script
    # Requires JQuery 1.7.1 (above)
    # from http://jsfiddle.net/eFjnU/833/
    print """