Looking for a command to detect pause state
Posted: January 12th, 2010, 3:00 pm
I use SABnzbd on the same Karmic box that I use for a media center with XBMC. I have written a small python script that will run via crontab every 5 minutes to detect whether or not XBMC is in video playback mode and if so will pause SABnbzd (I do this to avoid choppy video during SABnzbd post-processing.) If XBMC is not in video playback mode it will then unpause SABnzbd. Right now I have the script simply sending a pause or resume command depending on the XBMC playback state but I would like to only send a command to SABnzbd if necessary. For example if a video is playing and SABnzbd is already paused there is no need to send a pause command. The same is true if no video is playing and SABnzbd is already unpaused.
Does anyone know a web command I can use to verify the current SABnzbd pause state. I can use a url request in python and then evaluate the html returned. I am currently using similar code to determine XBMC's video playback state. Here is a bit of code I am using to do that.
This code searches the results of the XBMC url request and then resumes SABnzbd downloading if XBMC reports that nothing is playing.
Thanks,
Rob
Does anyone know a web command I can use to verify the current SABnzbd pause state. I can use a url request in python and then evaluate the html returned. I am currently using similar code to determine XBMC's video playback state. Here is a bit of code I am using to do that.
Code: Select all
req = urllib2.Request('http://' + xbmcAddress + '/xbmcCmds/xbmcHttp?command=getcurrentlyplaying')
try: handle = urllib2.urlopen(req)
except IOError, e:
print "XBMC Connection Error\n"
exit
else:
page = handle.read()
if page.find('Filename:[Nothing Playing]') >= 0:
req = urllib2.Request('http://' + sabnzbdAddress + '/sabnzbd/api?mode=resume&apikey=' + sabnzbdAPIKey + '&ma_username=' + sabnzbdUser + '&ma_password=' + sabnzbdPass)
try: handle = urllib2.urlopen(req)
except IOError, e:
print "SABnzbd Connection Error\n"
exit
else:
page = handle.read()
print "Nothing Playing, SABnzbd unpaused\n"
Thanks,
Rob