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

		args = ( self._timestamp(), 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 addSeed( self, stationId=None, musicId=None):
                if stationId == None:
                        stationId = self.curStation
                if musicId == None:
                        return

                reqUrl = self.base_url_lid %( self.rid, self.lid, "addSeed" )

                args = ( self._timestamp(), self.authToken, stationId, musicId )

                req = xmlrpclib.dumps( args, "station.addSeed" )

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

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

                try:
                        parsed = xmlrpclib.loads( resp )[0][0]
                except xmlrpclib.Fault, fault:
                        parsed = resp
                        print "Error:", fault.faultString
                        print "Code:", fault.faultCode
Пример #3
0
    def doRequest(self, reqUrl, method, *args):
        args = (int(time.time()) - self.timedelta, ) + args
        #print args
        req = xmlrpclib.dumps(args, method).replace("\n", "")
        #print req
        enc = crypt.encryptString(req)
        #print enc

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

        try:
            xmlString = xml.dom.minidom.parseString(resp)
            #print xmlString.toprettyxml()
            parsed = xmlrpclib.loads(resp)
        except xmlrpclib.Fault, fault:
            print "Error:", fault.faultString
            print "Code:", fault.faultCode

            parts = fault.faultString.split("|")
            if len(parts) > 2:
                code = parts[-2]
                if code == "AUTH_INVALID_TOKEN":
                    raise AuthenticationError()
                else:
                    raise ValueError(code)
            else:
                raise ValueError(fault.faultString)
Пример #4
0
    def sync(self):
        reqUrl = self.BASE_URL_RID % (self.rid, "sync")

        req = xmlrpclib.dumps((), "misc.sync").replace("\n", "")
        enc = crypt.encryptString(req)

        u = urllib2.urlopen(reqUrl, enc)
        resp = u.read()
        u.close()
	def addTiredSong( self, musicId ):
		reqUrl = BASE_URL_LID %( self.rid, self.lid, "addTiredSong" )

		req = xmlrpclib.dumps( ( self._timestamp(), 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()
	def getStations( self ):
		reqUrl = BASE_URL_LID %( self.rid, self.lid, "getStations" )

		req = xmlrpclib.dumps( ( self._timestamp(), 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 addFeedback( self, stationId, musicId, likeFlag ):

		reqUrl = BASE_URL_LID %( self.rid, self.lid, "addFeedback" )

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

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

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

		u = urllib2.urlopen( reqUrl, enc )
		resp = u.read()
		u.close()
Пример #8
0
    def sync(self):
        reqUrl = self.BASE_URL_RID_SECURE % (self.rid, "sync")

        req = xmlrpclib.dumps((), "misc.sync").replace("\n", "")
        enc = crypt.encryptString(req)

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

        try:
                parsed = xmlrpclib.loads(resp)
                cryptedTimestamp = parsed[0][0]
                decryptedTimestamp = crypt.decryptString(cryptedTimestamp)
                self.timedelta = int(time.time()) - int(decryptedTimestamp[4:-2])
        except xmlrpclib.Fault, fault:
                raise ValueError(str(fault))
	def authListener( self, user, pwd ):
		reqUrl = BASE_URL_RID %( self.rid, "authenticateListener" )

		req = xmlrpclib.dumps( ( self._timestamp(), "00000000000000000000000000000000", user, pwd, "html5tuner", "", "", "HTML5", True ), \
								"listener.authenticateListener" )
		#req = '<?xml version=\"1.0\"?><methodCall><methodName>listener.authenticateListener</methodName><params><param><value><int>%lu</int></value></param><param><value><string>%s</string></value></param><param><value><string>%s</string></value></param><param><value><string>html5tuner</string></value></param><param><value><string/></value></param><param><value><string/></value></param><param><value><string>HTML5</string></value></param><param><value><boolean>1</boolean></value></param></params></methodCall>' % (self._timestamp(), user, pwd)

		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
Пример #10
0
    def doRequest(self, reqUrl, method, *args):
        args = (int(time.time()),) + args
        req = xmlrpclib.dumps(args, method).replace("\n", "")
        enc = crypt.encryptString(req)

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

        try:
            parsed = xmlrpclib.loads(resp)
        except xmlrpclib.Fault, fault:
            # print "Error:", fault.faultString
            # print "Code:", fault.faultCode

            code = fault.faultString.split("|")[-2]
            if code == "AUTH_INVALID_TOKEN":
                raise AuthenticationError()
            else:
                raise ValueError(code)
        def searchPandora( self, search=None ):
                if search==None:
                        return

                reqUrl = self.base_url_lid %( self.rid, self.lid, "search" )

                args = ( self._timestamp(), self.authToken, search )

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

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

                try:
                        parsed = xmlrpclib.loads( resp )[0][0]
                except xmlrpclib.Fault, fault:
                        parsed = resp
                        print "Error:", fault.faultString
                        print "Code:", fault.faultCode
        def getFragment( self, stationId=None, format=None ):
                if stationId == None:
                        stationId = self.curStation
                if format == None:
                        format = self.curFormat
                reqUrl = self.base_url_lid %( self.rid, self.lid, "getFragment" )

                args = ( self._timestamp(), 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 = urlopen( reqUrl, enc )
                resp = u.read()
                u.close()

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