def _decrypt_url(url): """ decrypts the song url where the song stream can be downloaded. the last 48 bytes are encrypted, so we pass those bytes to the c extension and then tack the decrypted value back onto the url """ e = url[-48:] d = _pandora.decrypt(e) url = url.replace(e, d) return url[:-8]
def sync(self): get = {"method": "sync"} body = self.get_template("sync") timestamp = None while timestamp is None: xml = self.send(get.copy(), body) timestamp = xml.find("params/param/value").text timestamp = _pandora.decrypt(timestamp) timestamp_chars = [] for c in timestamp: if c.isdigit(): timestamp_chars.append(c) timestamp = int(time.time() - int("".join(timestamp_chars))) self.timeoffset = timestamp return True
def sync(self): """ synchronizes the times between our clock and pandora's servers by recording the timeoffset value, so that for every call made to Pandora, we can specify the correct time of their servers in our call """ get = {"method": "sync"} body = self.get_template("sync") timestamp = None while timestamp is None: xml = self.send(get.copy(), body) timestamp = xml.find("params/param/value").text timestamp = _pandora.decrypt(timestamp) timestamp_chars = [] for c in timestamp: if c.isdigit(): timestamp_chars.append(c) timestamp = int(time.time() - int("".join(timestamp_chars))) self.timeoffset = timestamp return True
def _decrypt_url(url): e = url[-48:] d = _pandora.decrypt(e) url = url.replace(e, d) return url[:-8]