NZBMatrix Categories solved!!

Come up with a useful post-processing script? Share it here!
Post Reply
ninocass
Newbie
Newbie
Posts: 4
Joined: September 11th, 2008, 5:28 pm

NZBMatrix Categories solved!!

Post by ninocass »

Hi all

I didnt like how sabnzbd didnt parse out the categories from the bookmarks RSS feed.  ( i totally understand why, its not good to statically code when the use of APIs can be used :) )

I have wrote a python script that will make use of the SABnzbd and NZBMatrix API functions.

The application logic is as follows:

Grab the NZBMatrix RSS feed and parse out the individual nzb link, category and title.

Based on the title it looks in a "downloaded nzb" folder and checks if if it has already downloaded the file.

If not it downloads the file to the nzb folder and uses the SABnzbd API to queue up the download using the location on disk of the NZB file as well as the category.

I ran into a number of issues, originally i wanted it to parse the RSS feed find the http links to the nzbfiles.  To download the nzbfile the nzbmatrix API key is required so adding the files to the queue in SABnzbd required the SABnzbd API key and the NZBMatrix API key.  Both of these parameters use the name "APIkey" so sabnzbd doesnt know which API key to use meaning we cant add items to the queue via http links so we have to download the file and use the location on disk.

This is a really fast and dirty script, if theres enough interest ill get the script to log into the NZBmatrix site and delete the downloaded nzbfiles from the RSS feed, this will keep your nzbmatrix account a lot more tidy

A few parameters need to be set in the python file at the bottom, pretty straight forward.

If you want the script to execute every 1 hour then use crontab -e and the entry

Code: Select all

0 * * * * /usr/bin/sabmatrix.py
Any questions let me know.
maddawg
Newbie
Newbie
Posts: 1
Joined: April 21st, 2010, 7:34 am

Re: NZBMatrix Categories solved!!

Post by maddawg »

This sounds promising...guess as a I N00B, definately need to figure out this scripting stuff.  Hate how sab downloads so many duplicates.  I will try your script.
OneStepAhead
Newbie
Newbie
Posts: 11
Joined: January 31st, 2010, 1:09 pm

Re: NZBMatrix Categories solved!!

Post by OneStepAhead »

maddawg wrote: This sounds promising...guess as a I N00B, definately need to figure out this scripting stuff.  Hate how sab downloads so many duplicates.  I will try your script.
check "Prevent Duplicate Downloads" in sabnzbd > config > switches. problem solved.
n1hilist
Newbie
Newbie
Posts: 1
Joined: June 8th, 2010, 6:08 pm

Re: NZBMatrix Categories solved!!

Post by n1hilist »

so I thought I'd try this out and I'm getting errors when I attempt to execute the script. I think its due to the fact that I'm using python 2.6.5 instead of 2.4.  I tried editing the first line to call my python location but no joy.

Code: Select all


user@Localhost:~/.nzbmatrix$ python -V
Python 2.6.5
user@Localhost:~/.nzbmatrix$ ./sabmatrix.py
Traceback (most recent call last):
  File "./sabmatrix.py", line 50, in <module>
    main()
  File "./sabmatrix.py", line 13, in main
    xmldoc = minidom.parseString(xml)
  File "/usr/lib/python2.6/xml/dom/minidom.py", line 1928, in parseString
    return expatbuilder.parseString(string)
  File "/usr/lib/python2.6/xml/dom/expatbuilder.py", line 940, in parseString
    return builder.parseString(string)
  File "/usr/lib/python2.6/xml/dom/expatbuilder.py", line 223, in parseString
    parser.Parse(string, True)
xml.parsers.expat.ExpatError: syntax error: line 1, column 0
pfox@Despair:~/.nzbmatrix$ which python
/usr/bin/python
user@Localhost:~/.nzbmatrix$
Any ideas?
User avatar
wta306
Newbie
Newbie
Posts: 4
Joined: June 17th, 2010, 8:17 am
Location: AC Ghetto

Re: NZBMatrix Categories solved!!

Post by wta306 »

This has been bugging me for a while but I have been (patiently?) waiting for something a little more refined...but a man can only wait so long.  I'll give it a try over the weekend and see how far I get and what if any workarounds I needed to implement to get it working.

ninocass - nice work bro!
Ubuntu 10.04 LTS 64bit + Boxee Beta 0.9.21.11487
User avatar
wta306
Newbie
Newbie
Posts: 4
Joined: June 17th, 2010, 8:17 am
Location: AC Ghetto

Re: NZBMatrix Categories solved!!

Post by wta306 »

So after confirming that the downloading of the nzbfiles (parsed from the RSS bookmark feed) works flawlessly, I uncommented the line where the nzbfiles are added to the queue...

Code: Select all

urllib.urlopen("http://" +  sabnzbdHost + "api?mode=addlocalfile&apikey=" + sabnzbdAPI + "&name=" + urllib.quote(nzbfile) + "&cat=" + cat)
I then bookmarked a new file on nzbmatrix and...

Code: Select all

optimus@mediabox:~/Scripts$ python nzbmatrix_bookmark_rdr.py
Traceback (most recent call last):
  File "nzbmatrix_bookmark_rdr.py", line 51, in <module>
    main()
  File "nzbmatrix_bookmark_rdr.py", line 35, in main
    urllib.urlopen("http://" +  sabnzbdHost + "api?mode=addlocalfile&apikey=" + sabnzbdAPI + "&name=" + urllib.quote(nzbfile) + "&cat=" + cat)
  File "/usr/lib/python2.6/urllib.py", line 86, in urlopen
    return opener.open(url)
  File "/usr/lib/python2.6/urllib.py", line 205, in open
    return getattr(self, name)(url)
  File "/usr/lib/python2.6/urllib.py", line 333, in open_http
    h = httplib.HTTP(host)
  File "/usr/lib/python2.6/httplib.py", line 1020, in __init__
    self._setup(self._connection_class(host, port, strict))
  File "/usr/lib/python2.6/httplib.py", line 657, in __init__
    self._set_hostport(host, port)
  File "/usr/lib/python2.6/httplib.py", line 682, in _set_hostport
    raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
httplib.InvalidURL: nonnumeric port: '8080api'
optimus@mediabox:~/Scripts$

some errors right off the bat...only modification was changing the first line to 2.6 from 2.4.  

don't plan on downgrading to 2.4...sooooo let's dig
Last edited by wta306 on June 17th, 2010, 2:49 pm, edited 1 time in total.
Ubuntu 10.04 LTS 64bit + Boxee Beta 0.9.21.11487
User avatar
wta306
Newbie
Newbie
Posts: 4
Joined: June 17th, 2010, 8:17 am
Location: AC Ghetto

Re: NZBMatrix Categories solved!!

Post by wta306 »

n1hilist wrote: so I thought I'd try this out and I'm getting errors when I attempt to execute the script. I think its due to the fact that I'm using python 2.6.5 instead of 2.4.  I tried editing the first line to call my python location but no joy.

Code: Select all


user@Localhost:~/.nzbmatrix$ python -V
Python 2.6.5
user@Localhost:~/.nzbmatrix$ ./sabmatrix.py
Traceback (most recent call last):
  File "./sabmatrix.py", line 50, in <module>
    main()
  File "./sabmatrix.py", line 13, in main
    xmldoc = minidom.parseString(xml)
  File "/usr/lib/python2.6/xml/dom/minidom.py", line 1928, in parseString
    return expatbuilder.parseString(string)
  File "/usr/lib/python2.6/xml/dom/expatbuilder.py", line 940, in parseString
    return builder.parseString(string)
  File "/usr/lib/python2.6/xml/dom/expatbuilder.py", line 223, in parseString
    parser.Parse(string, True)
xml.parsers.expat.ExpatError: syntax error: line 1, column 0
pfox@Despair:~/.nzbmatrix$ which python
/usr/bin/python
user@Localhost:~/.nzbmatrix$
Any ideas?

looks like your having trouble parsing the feed.  For the "nzbmatrixID" variable at the bottom...did you enter the userid you use to log into NZBMatrix or did you use uid value in the bookmark RSS address?

When I changed my script to use the username I use to log into the nzbmatrix site, I get very similar errors to you immediately upon executing the script...

Code: Select all

optimus@mediabox:~/Scripts$ python nzbmatrix_bookmark_rdr.py
Traceback (most recent call last):
  File "nzbmatrix_bookmark_rdr.py", line 51, in <module>
    main()
  File "nzbmatrix_bookmark_rdr.py", line 13, in main
    xmldoc = minidom.parseString(xml)
  File "/usr/lib/python2.6/xml/dom/minidom.py", line 1928, in parseString
    return expatbuilder.parseString(string)
  File "/usr/lib/python2.6/xml/dom/expatbuilder.py", line 940, in parseString
    return builder.parseString(string)
  File "/usr/lib/python2.6/xml/dom/expatbuilder.py", line 223, in parseString
    parser.Parse(string, True)
xml.parsers.expat.ExpatError: syntax error: line 1, column 0
optimus@mediabox:~/Scripts$

when you log into nzbmatrix, go to your bookmarks page and you should see a link towards the top of the body section of the page that contains the numeric uid you should be using with this script along with the API Key... good luck...hope this helps.
Last edited by wta306 on June 17th, 2010, 3:04 pm, edited 1 time in total.
Ubuntu 10.04 LTS 64bit + Boxee Beta 0.9.21.11487
User avatar
wta306
Newbie
Newbie
Posts: 4
Joined: June 17th, 2010, 8:17 am
Location: AC Ghetto

Re: NZBMatrix Categories solved!!

Post by wta306 »

Something changed and I had to update the script to wait 10 seconds between each NZB download.

just import the time library at the top

Code: Select all

import xml.dom.minidom
import urllib2
import urllib
import os
import time
then add the following line...

Code: Select all

time.sleep 10
...just before the following line

Code: Select all

#download the nzb file
otherwise, the first NZB file gets downloaded just fine, while the rest are just files containing the single line...

Code: Select all

error:please_wait_10
Ubuntu 10.04 LTS 64bit + Boxee Beta 0.9.21.11487
Post Reply