Kodi Community Forum
[OBSOLETE] Pandora Radio (Script) Music Addon - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Add-on Support (https://forum.kodi.tv/forumdisplay.php?fid=27)
+---- Forum: Music Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=148)
+---- Thread: [OBSOLETE] Pandora Radio (Script) Music Addon (/showthread.php?tid=70471)



- mrsale - 2011-09-22

Changing from 31 -> 32 worked for me as well.
I tried doing it in notepad first, a couple of times, and it kept showing script failed. I downloaded notepad ++ and edited it, and it worked. So if it doesn't work for you, you may want to try another text editor.


- dallasnights - 2011-09-23

edit in winscp works great thanks


- Randall Lind - 2011-09-23

The plug in is not working they also revamped the site so maybe they redid how you log in. Error Failed to authenticate listener.


- Randall Lind - 2011-09-23

daniel4891 Wrote:WOOOO!!!!

I figured it out!

Turns out all I had to do was change the pandora.py file to PROTOCOL_VERSION=32 instead of 31!

Great addon!Big Grin

for people who are not programers can you explain how to do this? Found and edit it only issue takes longer to log on but once in it works.


Any thoughts - kobyboy - 2011-09-23

First off GREAT ADDY!
As per instructions above edit and so forth,I got the new keys however I'am in Canada with a HotspotShield in towe and still Crashes.Any suggestion
thanks Kobyboy


- Set845 - 2011-09-23

dallasnights Wrote:edit in winscp works great thanks

+1
It seems that the thumbs up, thumbs down, and zzz buttons now work. Awesome!!


- mrsale - 2011-09-23

Randall Lind Wrote:for people who are not programers can you explain how to do this? Found and edit it only issue takes longer to log on but once in it works.

It took a little longer the first couple of times for me also, but it seems to be pretty quick now.
I'm just happy it works again, this script is great!


- tkarns24 - 2011-09-24

hey guys here what i have with the changes an i still can't get it to work. What do i need to fix differently cuz it will not allow me to log on

mport xmlrpclib
import urllib2
import time

import crypt
import keys

PROTOCOL_VERSION=32BASE_URL = "http://www.pandora.com/radio/xmlrpc/v%d?" %PROTOCOL_VERSION
BASE_URL_RID = BASE_URL + "rid=%sP&method=%s"
BASE_URL_LID = BASE_URL + "rid=%sP&lid=%s&method=%s"

def _inttime():
return int( time.time() )

class PandoraError(Exception):
def __init__( self, value ):
self.value = value
def __str__( self ):
return repr( self.value )

class Pandora:
rid = ""
lid = ""
authToken = ""
curStation = ""
curFormat = ""

def __init__( self, dataDir, fmt = "mp3" ):
self.dataDir = dataDir
self.rid = "%07i" %( time.time() % 10000000 )
self.keys = keys.Keys( self.dataDir, PROTOCOL_VERSION )
if not self.keys.loadKeys():
raise PandoraError("Unable to load keys")
self.curFormat = fmt

def setProxy( self, proxy_info ):
if proxy_info["user"] == "" and proxy_info["pass"] == "":
proxy_h = urllib2.ProxyHandler( { "http" : \
"http://%(host)s:%(port)s" %proxy_info } )
else:
proxy_h = urllib2.ProxyHandler( { "http" : \
"http://%(user)s:%(pass)s@%(host)s:%(port)s" %proxy_info } )

proxy_o = urllib2.build_opener( proxy_h, urllib2.HTTPHandler )

urllib2.install_opener( proxy_o )

def sync( self ):
reqUrl = BASE_URL_RID %( self.rid, "sync" )

req = xmlrpclib.dumps( (), "misc.sync" ).replace( "\n", "" )
enc = crypt.encryptString( req, self.keys['out'] )

u = urllib2.urlopen( reqUrl, enc )
resp = u.read()
u.close()

def authListener( self, user, pwd ):
reqUrl = BASE_URL_RID %( self.rid, "authenticateListener" )

req = xmlrpclib.dumps( ( _inttime(), user, pwd ), \
"listener.authenticateListener" )
req = req.replace( "\n", "" )
enc = crypt.encryptString( req, self.keys['out'] )

u = urllib2.urlopen( reqUrl, enc )
resp = u.read()
u.close()

try:
parsed = xmlrpclib.loads( resp )[0][0]
except xmlrpclib.Fault, fault:
print "Error:", fault.faultString
print "Code:", fault.faultCode
return False

self.authToken = parsed["authToken"]
self.lid = parsed["listenerId"]

return True

def getStations( self ):
reqUrl = BASE_URL_LID %( self.rid, self.lid, "getStations" )

req = xmlrpclib.dumps( ( _inttime(), self.authToken ), \
"station.getStations" )
req = req.replace( "\n", "" )
enc = crypt.encryptString( req, self.keys['out'] )

u = urllib2.urlopen( reqUrl, enc )
resp = u.read()
u.close()

parsed = xmlrpclib.loads( resp )[0][0]

return parsed

def getFragment( self, stationId=None, format=None ):
if stationId == None:
stationId = self.curStation
if format == None:
format = self.curFormat
reqUrl = BASE_URL_LID %( self.rid, self.lid, "getFragment" )

args = ( _inttime(), self.authToken, stationId, "0", "", "", \
format, "0", "0" )
req = xmlrpclib.dumps( args, "playlist.getFragment" )
req = req.replace( "\n", "" )
enc = crypt.encryptString( req, self.keys['out'] )

u = urllib2.urlopen( reqUrl, enc )
resp = u.read()
u.close()

parsed = xmlrpclib.loads( resp )[0][0]

#last 48 chars of URL encrypted, padded w/ 8 * '\x08'
for i in range( len( parsed ) ):
url = parsed[i]["audioURL"]
url = url[:-48] + crypt.decryptString( url[-48:],\
self.keys['in'] )[:-8]
parsed[i]["audioURL"] = url

self.curStation = stationId
self.curFormat = format

return parsed

def addFeedback( self, stationId, musicId, likeFlag ):

print "addFeedback - stationId: ", stationId
print "addFeedback - musicId: ", musicId
print "addFeedback - likeFlag: ", likeFlag
reqUrl = BASE_URL_LID %( self.rid, self.lid, "addFeedback" )

matchingSeed = ""
userSeed = ""
focusTraitId = ""

args = ( _inttime(), self.authToken, stationId, musicId, matchingSeed, userSeed, focusTraitId, "", likeFlag, False )

req = xmlrpclib.dumps( args, "station.addFeedback" )
print "addFeedback - req: ", req
req = req.replace( "\n", "" )
enc = crypt.encryptString( req, self.keys['out'] )

u = urllib2.urlopen( reqUrl, enc )
resp = u.read()
u.close()

print "addFeedback resp:", resp

#parsed = xmlrpclib.loads( resp )[0][0]
#print "addFeedback return:", parsed

#return parsed

def addTiredSong( self, musicId ):
reqUrl = BASE_URL_LID %( self.rid, self.lid, "addTiredSong" )

req = xmlrpclib.dumps( ( _inttime(), self.authToken, musicId ), \
"listener.addTiredSong" )
req = req.replace( "\n", "" )
enc = crypt.encryptString( req, self.keys['out'] )

u = urllib2.urlopen( reqUrl, enc )
resp = u.read()
u.close()

print "addTiredSong resp:", resp


- tkarns24 - 2011-09-24

hey guys any help here would be greatly appreciated


- sonic30101 - 2011-09-25

i have had this script working for about a month now. and as stated by Randall Lind pandora has changed their website. now i just get a Error Failed to authenticate listener.


- chrisjs - 2011-09-25

Bumping the protocol version worked fine for me, Pandora's playing on my aTV2 as I type this.

Just SSH in and edit the file with vim.

tkarns24 it looks like you ate the line break from that paste. BASE_URL should be the start of the next line.


- rcrh - 2011-09-25

I've been successfully running 1.2.1 until the recent release of the html5 version of Pandora. At that point I started getting errors about not being able to log in. So, I followed the thread here and decided that I'd update to version 1.2.5. Now I get an error saying the script failed. Below is what is written to my xbmc.log

11:33:13 T:3078965120 M:624648192 WARNING: GetLabel - Unknown nodetype requested 0
11:33:16 T:2915040112 M:624254976 NOTICE: -->Python Interpreter Initialized<--
11:33:16 T:2915040112 M:624254976 NOTICE: PANDORA: Initializing v1.2.5
11:33:16 T:2915040112 M:624254976 NOTICE: PANDORA: sys.platform = linux2
11:33:19 T:2915040112 M:621084672 NOTICE: PANDORA: Loading key from file "/home/xbmc/.xbmc/userdata/addon_data/script.xbmc.pandora/key_in"
11:33:20 T:2915040112 M:621084672 NOTICE: PANDORA: Unexpected error:exceptions.KeyError:'proto'
11:33:20 T:2915040112 M:621084672 ERROR: Error Type: exceptions.KeyError
11:33:20 T:2915040112 M:621084672 ERROR: Error Contents: 'proto'
11:33:20 T:2915040112 M:621084672 ERROR: Traceback (most recent call last):
File "/home/xbmc/.xbmc/addons/script.xbmc.pandora/default.py", line 235, in ?
panda = Panda()
File "/home/xbmc/.xbmc/addons/script.xbmc.pandora/default.py", line 60, in __init__
self.pandora = Pandora( dataDir, fmt )
File "/home/xbmc/.xbmc/addons/script.xbmc.pandora/libpandora/pandora.py", line 33, in __init__
if not self.keys.loadKeys():
File "/home/xbmc/.xbmc/addons/script.xbmc.pandora/libpandora/keys.py", line 39, in loadKeys
"key_in" ) )
File "/home/xbmc/.xbmc/addons/script.xbmc.pandora/libpandora/keys.py", line 104, in _loadKeyFromFile
key = Key( tmp['proto'], tmp['key'] )
File "/home/xbmc/.xbmc/addons/script.xbmc.pandora/libpandora/keys.py", line 19, in __getitem__
return self._key[key]
KeyError: 'proto'


I have updated the protocol version to 32.

Any help would be GREATLY appreciated.

Thanks.
Richard


- rcrh - 2011-09-25

Follow up on my own question:

I just went back and changed the protocol number on my 1.2.1 script and it worked!

So, since Pandora is working I guess my question is "is there much difference between version 1.2.1 & 1.2.5?".

Thanks again. This script rocks!


- htpc guy - 2011-09-25

rcrh Wrote:Follow up on my own question:

I just went back and changed the protocol number on my 1.2.1 script and it worked!

So, since Pandora is working I guess my question is "is there much difference between version 1.2.1 & 1.2.5?".

Thanks again. This script rocks!


I know the most recent version allows for the use of the "Back" button to exit the addon which is a huge win!


- Chadalu - 2011-09-26

Cant get login work on my ipad....i tried the last version and the protocol32
logins fail everytime
anyone give a help?