RSS feed: queue status

Want something added? Ask for it here.
Post Reply
nol33t
Newbie
Newbie
Posts: 1
Joined: March 19th, 2008, 10:26 pm

RSS feed: queue status

Post by nol33t »

Hi folks,
It's not really a feature request since I developed it, but in case other people are interested:

I wanted a RSS feed to check my queue status, so here's what the feed look like and the code in interface.py:
feed adress is rss?ma_username=[user]&ma_password=[password]&mode=qstatus

thanks to all the developers of sabnzbd, great job guys!

-matt-

Image

interface.py.diff (from rev 751):

Code: Select all

326a327,328
>         elif mode == 'qstatus':
>            return rss_qstatus()
1858a1861,1908
> def rss_qstatus():
>     """ Return a RSS feed with the queue status
>     """
>     qnfo = sabnzbd.queue_info()
>     pnfo_list = qnfo[QNFO_PNFO_LIST_FIELD]
>
>     rss = RSS()
>     rss.channel.title = "SABnzbd Queue"
>     rss.channel.description = "Overview of current downloads"
>     rss.channel.link = "http://%s:%s/sabnzbd/queue" % ( \
>                            sabnzbd.CFG['misc']['host'], sabnzbd.CFG['misc']['port'] )
>     rss.channel.language = "en"
>
>     item = Item()
>     item.title  = "Total ETA: " + calc_timeleft(qnfo[QNFO_BYTES_LEFT_FIELD], sabnzbd.bps()) + " - "
>     item.title += "Queued: %.2f MB - " % (qnfo[QNFO_BYTES_LEFT_FIELD] / MEBI)
>     item.title += "Speed: %.2f kB/s" % (sabnzbd.bps() / KIBI)
>     rss.addItem(item)
>
>     sum_bytesleft = 0
>     for pnfo in pnfo_list:
>     filename, msgid = SplitFileName(pnfo[PNFO_FILENAME_FIELD])
>     bytesleft = pnfo[PNFO_BYTES_LEFT_FIELD] / MEBI
>     bytes = pnfo[PNFO_BYTES_FIELD] / MEBI
>
>     item = Item()
>     item.title = filename
>     if (msgid):
>             item.link    = "https://v3.newzbin.com/browse/post/%s/" % msgid
>         else:
>             item.link    = "http://%s:%s/sabnzbd/history" % ( \
>                             sabnzbd.CFG['misc']['host'], sabnzbd.CFG['misc']['port'] )
>     statusLine  = ""
>     statusLine += '<tr>'
>     #Total MB/MB left
>     statusLine +=  '<dt>Remain/Total: %.2f/%.2f MB</dt>' % (bytesleft, bytes)
>     #ETA
>     sum_bytesleft += pnfo[PNFO_BYTES_LEFT_FIELD]
>     statusLine += "<dt>ETA: %s </dt>" % calc_timeleft(sum_bytesleft, sabnzbd.bps())
>     statusLine += "<dt>Age: %s</dt>" % calc_age(pnfo[PNFO_AVG_DATE_FIELD])
>     statusLine += "</tr>"
>     item.description = statusLine
>     rss.addItem(item)
>
>     rss.channel.lastBuildDate = std_time(time.time())
>     rss.channel.pubDate = rss.channel.lastBuildDate
>     rss.channel.ttl = "1"
>     return rss.write()
Last edited by nol33t on March 19th, 2008, 11:19 pm, edited 1 time in total.
DeXeS
Release Testers
Release Testers
Posts: 206
Joined: January 28th, 2008, 1:04 pm
Location: The Netherlands

Re: RSS feed: queue status

Post by DeXeS »

wow that's awesome! ;D
User avatar
switch
Moderator
Moderator
Posts: 1380
Joined: January 17th, 2008, 3:55 pm
Location: UK

Re: RSS feed: queue status

Post by switch »

Not sure how I missed this topic the first time around, but thanks for your patch.
I have modified it a little, but it has been added for inclusion in 0.5

Thanks for sharing your work nol33t.
Post Reply