XBMC SABnzbd+ Python Script

Got a program that plays well with SABnzbd? Share it here!
damien6669
Newbie
Newbie
Posts: 1
Joined: February 11th, 2010, 5:13 pm

Re: XBMC SABnzbd+ Python Script

Post by damien6669 »

I was about to post another request for Attributes to be displayed for the videos from newzbin, but I think that's been done already. Is there a way to customize what information is shown already? instead of the title and size.

Oh, and this has just made an amazing HTPC that much better! Where would one donate to this project?
jamesdew
Newbie
Newbie
Posts: 34
Joined: January 19th, 2010, 9:06 am

Re: XBMC SABnzbd+ Python Script

Post by jamesdew »

I would really appreciate some help here, when selecting an item in a queue the options are move to top and delete, these do not work for me I get the error.

Failed to contact sabnzb

this used to work but doesnt any more. This frustrated me so much that I looked up the sabnzbd API and decided to learn a little python too.

After figuring out the basics of the script I couldnt see a solution so I got wireshark on the case and determined that this is the URL that the script outputs

http://localhost:8080/sabnzbd/queue/del ... 4c1d3c30b2

wireshark tells me that this returns a 401

so I paste the URL into firefox, AND IT WORKS!

This doesnt make any sense to me so I did a comparison of the two requests in wireshark

This is the one from the script

GET /sabnzbd/queue/delete?uid=SABnzbd_nzo_qyANLB&ma_username=xbmcuser&ma_password=xbmcpass&apikey=b8f4229513908cb4968f874c1d3c30b2 HTTP/1.0

Host: localhost:8080

User-agent: Python-urllib/1.16

and I get the HTTP 401 response
HTTP/1.1 401 Unauthorized

Date: Tue, 16 Feb 2010 21:09:22 GMT

Content-Length: 218

Content-Type: text/html;charset=utf-8

Www-Authenticate: Basic realm="SABnzbd"

Server: CherryPy/3.2.0





   
    Access denied
   
   
   
    Error 401 Unauthorized: You need to provide a valid username and password.
   


and then from firefox

GET /sabnzbd/queue/delete?uid=SABnzbd_nzo_qyANLB&ma_username=xbmcuser&ma_password=xbmcpass&apikey=b8f4229513908cb4968f874c1d3c30b2 HTTP/1.1

Host: localhost:8080

User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.1.7) Gecko/20100106 Ubuntu/9.10 (karmic) Firefox/3.5.7

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

Accept-Language: en-gb,en;q=0.5

Accept-Encoding: gzip,deflate

Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7

Keep-Alive: 300

Connection: keep-alive

Cookie: session_id=7c39fd4b610b1f9c2d0f4658596bcc106c6f5929

Authorization: Basic eGJtYzp4Ym1j

and I get a valid response, I wont paste the whole thing as its too long

The worst part is this USED to work and I cant for the life of me think of anything I could have done to prevent it working anymore.

i really am hoping I can get this resolved as I am picking up this python malarky (at least I thought I was) and I would be happy to implement any more features I can figure out how to do.
User avatar
switch
Moderator
Moderator
Posts: 1380
Joined: January 17th, 2008, 3:55 pm
Location: UK

Re: XBMC SABnzbd+ Python Script

Post by switch »

Have you changed your sabnzbd username and password in config>general? Make sure it matches the one in the xbmc plugin settings.
jamesdew
Newbie
Newbie
Posts: 34
Joined: January 19th, 2010, 9:06 am

Re: XBMC SABnzbd+ Python Script

Post by jamesdew »

nope, but thats the point. The URL your script outputs does work if I paste it into firefox so the username and password is ok. Also I am able to load the queue just not delete or move to top.

However I have also noticed that sab does not log the error so I think something else must be rejecting my connection. Its not apache, I shut it down just to be sure.

I notice the 401 comes from "Server: CherryPy/3.2.0" what is that? I have very limited python skills. Is there some kind of python HTTP handler before it gets to sabnzb that could be rejecting the connection? If so any idea where if anywhere this would be logged?

damn this is annoying.
Last edited by jamesdew on February 16th, 2010, 7:02 pm, edited 1 time in total.
User avatar
switch
Moderator
Moderator
Posts: 1380
Joined: January 17th, 2008, 3:55 pm
Location: UK

Re: XBMC SABnzbd+ Python Script

Post by switch »

I see, that part is not compatible with the authorisation changes in 0.5

It should be using the new api commands instead. You could fix it by changing the command to the proper api command http://wiki.sabnzbd.org/api or embeding the url and pass in the call instead of ma_username and ma_password it needs to be http://user:pass@localhost/sabnzbd/queue...
jamesdew
Newbie
Newbie
Posts: 34
Joined: January 19th, 2010, 9:06 am

Re: XBMC SABnzbd+ Python Script

Post by jamesdew »

Thanks a lot for your reply, I will try adding user:pass@, that just might work.

However I still don't understand why the same URL works in firefox but not from python.
User avatar
switch
Moderator
Moderator
Posts: 1380
Joined: January 17th, 2008, 3:55 pm
Location: UK

Re: XBMC SABnzbd+ Python Script

Post by switch »

Because you have already logged into SABnzbd with your browser. Your browser is then authenticated so does not need to pass any authentication details along inside the URL.
jamesdew
Newbie
Newbie
Posts: 34
Joined: January 19th, 2010, 9:06 am

Re: XBMC SABnzbd+ Python Script

Post by jamesdew »

of course why didn't I think of that!

Anyway I fixed it, I also added the ability to resume and pause individual downloads as well as a global download/resume.

I did take out a little error handling though

#if resp:

        #  reload the queue

        #xbmc.executebuiltin('Container.Refresh')           

        #else:

        #  self.dialog('Failed to contact SABnzbd')

For some reason this still generated an error response so I commented it out. I was going to fix it but I figure if SAB isn't working they wouldn't have been able to load the queue in the first place. Besides the refresh queue has never worked since it takes a few seconds to delete the download.

I guess I could stick a wait in there or it might even be better to back out of the queue, which I may add as soon as I figure out how to do that.

You can package this into a new release if you like, if anyone wants to add this functionality to the script they have now just replace /nzb/sabnzbd_actions.py with the file I have attached.

In case you are not sure what this does, once in the sab queue select an item and hit return, this gives you a list of options. Select pause/resume from the queue.

Thanks for creating this script I hope my small contribution can help
jamesdew
Newbie
Newbie
Posts: 34
Joined: January 19th, 2010, 9:06 am

Re: XBMC SABnzbd+ Python Script

Post by jamesdew »

I made some more changes, I didn't like the lack of user feedback.

It now confirms the action with a message, however it doesn't do this based on a confirmation from SAB, it just assumes the action worked.

I would like to have it actually verify the response but I only started learning python on Tuesday so thats a bit beyond me right now.

I would also note that in fact xbmc.executebuiltin('Container.Refresh') doesnt actually seem to refresh the window, anyone any idea why?
atholm
Newbie
Newbie
Posts: 2
Joined: February 21st, 2010, 6:50 am

Re: XBMC SABnzbd+ Python Script

Post by atholm »

Hi
Thanks for great plugin. I do however have a problem :(
I can fine fetch records from newzbin but can not queue them in sabnzbd.
It works fine with other sources than newzbin, which is kind of strange.

The log says ERROR: Unable to find host: video

Please help
wally007
Release Testers
Release Testers
Posts: 155
Joined: August 28th, 2009, 5:24 pm

Re: XBMC SABnzbd+ Python Script

Post by wally007 »

atholm wrote: Hi
Thanks for great plugin. I do however have a problem :(
I can fine fetch records from newzbin but can not queue them in sabnzbd.
It works fine with other sources than newzbin, which is kind of strange.

The log says ERROR: Unable to find host: video

Please help
If it works with other sources it means your plug in can communicate with sab fine. You either dont have your newzbin RSS URL right or your log in info is incorrect. Newzbin works fine here.

By the way, are there any plans to implement HISTORY section , now that .5 version is practically out :-) ?
atholm
Newbie
Newbie
Posts: 2
Joined: February 21st, 2010, 6:50 am

Re: XBMC SABnzbd+ Python Script

Post by atholm »

Hmm I just have version 1.54 installed and I'm sure that my login to newzbin is correct.
Also when I search for a file on newzbin I'm not able to queue it.
jamesdew
Newbie
Newbie
Posts: 34
Joined: January 19th, 2010, 9:06 am

Re: XBMC SABnzbd+ Python Script

Post by jamesdew »

jamesdew wrote: I made some more changes, I didn't like the lack of user feedback.

It now confirms the action with a message, however it doesn't do this based on a confirmation from SAB, it just assumes the action worked.

I would like to have it actually verify the response but I only started learning python on Tuesday so thats a bit beyond me right now.

I would also note that in fact xbmc.executebuiltin('Container.Refresh') doesnt actually seem to refresh the window, anyone any idea why?
I realised I should point out that this only works on sab 5.x
bbking
Newbie
Newbie
Posts: 5
Joined: March 8th, 2010, 6:16 am

Re: XBMC SABnzbd+ Python Script

Post by bbking »

Hi

Well looks worth trying to run this on my XBMC Live HTPC
Gonna give it a go.

Would be cool if anyone could hook me up with a newzbin account. I'm surely willing to share a few bucks for that

Thx
BB
Neil
Newbie
Newbie
Posts: 19
Joined: April 3rd, 2009, 5:47 pm

Re: XBMC SABnzbd+ Python Script

Post by Neil »

Switch, would you mind adding a way to view my history of recent sabnzb downloads?  Every time I turn on my TV, I have to quit Plex and use a mouse to see what shows have downloaded since last time.  It would be great to see what new shows I have with just a few clicks of the remote control.  Thanks for all your work.
Post Reply