NZBStats

Display HellaNZB Statistics in channel, written in python, very simple

PYTHON:
__module_name__ = "HellaNZB"
__module_version__ = "1.0"
__module_description__ = "HellaNZB X-Chat Interface"

print "HellaNZB X-Chat Interface Loaded..."

import xchat
import xmlrpclib

server = xmlrpclib.ServerProxy('http://hellanzb:changeme@localhost:8760')

def nzb_cb (word, word_eol, userdata):
    status = server.status()
    channel = xchat.get_info("channel")
    yournick = xchat.get_info("nick")
    uptime = "uptime: " + status['uptime']
    files = str(status['total_dl_files'])
    downloadmb = str(status['total_dl_mb']) + " MB"

    downloading = "None"
    processing = " Processing: None"
       
    nzbfiles = str(status['total_dl_nzbs'])
    dl = "downloaded " + nzbfiles + " nzbs, " + files + " files (" + downloadmb + ")" 
    xchat.command("MSG " + channel + " HellaNZB " + uptime + " " + dl)
    if status['currently_processing']:
        processing = status['currently_processing'][0]
        processing = " Processing: " + processing['nzbName']

    if status['currently_downloading']:
        downloading = status['currently_downloading'][0]
        rate = "%.2f" % (status['rate'])
        eta = str("%.2f" % (status['eta'] / 60))
        xchat.command("MSG " + channel + " Currently Downloading: " + downloading['nzbName'] + processing + ", Rate: [" + rate + " KB/s]" + ", ETA: [" + eta + "]")

    if status['queued']:
            for i, v in enumerate(status['queued']):
                numqueues = str(i + 1)
                if i <5:
                    xchat.command("MSG " + channel + " Queue: " + numqueues + ", " + v['nzbName'] + ", ID: [" + str(v['id']) + "]")
    return xchat.EAT_ALL   

def nzbdl_cb(word, word_eol, userdata):
    if len(word) <2:
        print "Second arg must be the newzbin ID"
    else:
        server.enqueuenewzbin(word_eol[1])
    print "Downloaded " + word_eol[1] + " and added it to the HellaQueue"
    return xchat.EAT_ALL

def nzbup_cb(word, word_eol, userdata):
   if len(word) <2:
    print "Second argument must be a queue id"
   else:
    server.up(word_eol[1])
    print "Moved " + word_eol[1] + " up in the queue"

   return xchat.EAT_ALL

def nzbdown_cb(word, word_eol, userdata):
   if len(word) <2:
    print "Second argument must be a queue id"
   else:
    server.down(word_eol[1])
    print "Moved " + word_eol[1] + " down in the queue"

   return xchat.EAT_ALL

def nzbforce_cb(word, word_eol, userdata):
   if len(word) <2:
    print "Second argument must be a queue id"
   else:
    server.down(word_eol[1])
    print "Forced " + word_eol[1] + " to start downloading"
   return xchat.EAT_ALL

def nzbcancel_cb(word, word_eol, userdata):
   server.cancel()
   print "Cancelled current download - moved to Hellanzb.TEMP_DIR"
   return xchat.EAT_ALL

def nzbpause_cb(word, word_eol, userdata):
   server.pause()
   print "Paused current download"
   return xchat.EAT_ALL

def nzbcontinue_cb(word, word_eol, userdata):
#   server.continue()
   print "Resumed Download"
   return xchat.EAT_ALL

def nzbhelp_cb(word, word_eol, userdata):
   print "/NZBDL <newzbin id> Downloads nzb file from NewzBin.com"
   print "/NZBSTAT Displays HellaNZB Status Information"
   print "/NZBDOWN <queue id> Move nzb down in the queue list"
   print "/NZBUP <queue id> Move nzb up in the queue list"
   print "/NZBCANCEL Cancel the current download and move the current NZB to Hellanzb.TEMP_DIR"
   print "/NZBFORCE <queue id>  Force hellanzb to begin downloading the NZB with the specified ID immediately, interrupting the current download"
   print "/NZBPAUSE Pauses the current download"
   print "/NZBCONTINUE Continues the paused download"
   return xchat.EAT_ALL

xchat.hook_command("NZBHELP", nzbhelp_cb, help="Display NZB Help Information")
xchat.hook_command("NZBDL", nzbdl_cb, help="/NZBDL <newzbin id> Downloads nzb file from NewzBin.com")
xchat.hook_command("NZBSTAT", nzb_cb, help="/NZBSTAT Displays HellaNZB Status Information")
xchat.hook_command("NZBDOWN", nzbdown_cb, help="/NZBOWN <queue id> Move nzb down in the queue list")
xchat.hook_command("NZBUP", nzbup_cb, help="/NZBUP <queue id> Move nzb up in the queue list")
xchat.hook_command("NZBCANCEL", nzbcancel_cb, help="/NZBCANCEL Cancel the current download and move the current NZB to Hellanzb.TEMP_DIR")
xchat.hook_command("NZBFORCE", nzbforce_cb, help="/NZBFORCE <queue id>  Force hellanzb to begin downloading the NZB with the specified ID immediately, interrupting the current download")
xchat.hook_command("NZBPAUSE", nzbpause_cb, help="/NZBPAUSE Pauses the current download")
xchat.hook_command("NZBCONTINUE", nzbcontinue_cb, help="/NZBCONTINUE Continues the paused download")

0 Responses to “NZBStats”


  • No Comments

Leave a Reply

You must login to post a comment.