def _resolve_rtmp_playback_url_via_flash(self, key): self._addon.log_notice("Resolving rtmp playback url for %s using flash" % key) user_agent = getUserAgent() self._addon.log_notice("Using user agent '%s'" % user_agent) svc = RemotingService(self._AMF_ENDPOINT, amf_version = 0, user_agent = user_agent) svc.addHTTPHeader('Cookie', 'r=' + self._state['rdio_cookie']) svc.addHTTPHeader('Host', 'www.rdio.com') rdio_svc = svc.getService('rdio') playback_token = self._state['playback_token'] secret_string = key + playback_token + self._RDIO_PLAYBACK_SECRET secret = self._RDIO_PLAYBACK_SECRET_SEED for c in secret_string: secret = ((secret << 5) + secret + ord(c)) % 65536; playerName = 'api_%s' % str(int(math.floor(random.random() * 1000000))) pi = rdio_svc.getPlaybackInfo({ 'domain': self._RDIO_DOMAIN, 'playbackToken': playback_token, 'manualPlay': False, 'requiresUnlimited': False, 'playerName': playerName, 'type': 'flash', 'secret': secret, 'key': key}) if not pi: raise Exception, 'Failed to get playback info' return self._extract_rtmp_url_from_playback_info(pi)
def _resolve_rtmp_playback_url_via_flash(self, key): self._addon.log_notice( "Resolving rtmp playback url for %s using flash" % key) user_agent = getUserAgent() self._addon.log_notice("Using user agent '%s'" % user_agent) svc = RemotingService(self._AMF_ENDPOINT, amf_version=0, user_agent=user_agent) svc.addHTTPHeader('Cookie', 'r=' + self._state['rdio_cookie']) svc.addHTTPHeader('Host', 'www.rdio.com') rdio_svc = svc.getService('rdio') playback_token = self._state['playback_token'] secret_string = key + playback_token + self._RDIO_PLAYBACK_SECRET secret = self._RDIO_PLAYBACK_SECRET_SEED for c in secret_string: secret = ((secret << 5) + secret + ord(c)) % 65536 playerName = 'api_%s' % str(int(math.floor(random.random() * 1000000))) pi = rdio_svc.getPlaybackInfo({ 'domain': self._RDIO_DOMAIN, 'playbackToken': playback_token, 'manualPlay': False, 'requiresUnlimited': False, 'playerName': playerName, 'type': 'flash', 'secret': secret, 'key': key }) if not pi: raise Exception, 'Failed to get playback info' return self._extract_rtmp_url_from_playback_info(pi)
def __init__(self, addon): self._addon = addon self._cookie_file = os.path.join(self._addon.get_profile(), 'rdio_cookies.txt') self._net = Net(user_agent = getUserAgent(), cookie_file = self._cookie_file) self._state = addon.load_data(self._STATE_FILE_NAME) if not self._state: addon.log_debug("Persistent auth state not loaded - initialising new state") self._state = self._INITIAL_STATE else: # Check for keys added to state that might not be in the saved copy if 'authorization_key' not in self._state: self._state['authorization_key'] = None addon.log_debug("Loaded persistent auth state") self._init_rdio()
def __init__(self): self._cookie_file = os.path.join('rdio_cookies.txt') self._net = Net(user_agent = getUserAgent(), cookie_file = self._cookie_file) self.debug('Persistent auth state not loaded') self._state = self._INITIAL_STATE self._init_rdio() self.authenticate() radio = RdioRadio(self) radio.start_radio("r139688", None) track = radio.next_track() if track: print "Play" print track['key'] stream_url = self.resolve_playback_url(track['key']) if stream_url: print "Play this" print stream_url
def resolve_playback_url(self, key): user_agent = getUserAgent() self._addon.log_notice("Using user agent '%s'" % user_agent) svc = RemotingService(self._AMF_ENDPOINT, amf_version = 0, user_agent = user_agent) svc.addHTTPHeader('Cookie', 'r=' + self._state['rdio_cookie']) svc.addHTTPHeader('Host', 'www.rdio.com') rdio_svc = svc.getService('rdio') playback_token = self._state['playback_token'] secret_string = key + playback_token + self._RDIO_PLAYBACK_SECRET secret = self._RDIO_PLAYBACK_SECRET_SEED for c in secret_string: secret = ((secret << 5) + secret + ord(c)) % 65536; playerName = 'api_%s' % str(int(math.floor(random.random() * 1000000))) pi = rdio_svc.getPlaybackInfo({ 'domain': self._RDIO_DOMAIN, 'playbackToken': playback_token, 'manualPlay': False, 'requiresUnlimited': False, 'playerName': playerName, 'type': 'flash', 'secret': secret, 'key': key}) if not pi: raise Exception, 'Failed to get playback info' if not pi['canStream']: self._addon.log_notice('Streaming key %s is not allowed' % key) return None rtmp_info = { 'rtmp': 'rtmpe://%s:1935%s' % (pi['streamHost'], pi['streamApp']), 'app': pi['streamApp'][1:], 'playpath': 'mp3:%s' % pi['surl'] } stream_url = rtmp_info['rtmp'] for key, value in rtmp_info.items(): stream_url += '' if key == 'rtmp' else ' %s=%s' % (key, value) self._addon.log_debug("Resolved playback URL for key '%s' to %s" % (key, stream_url)) return stream_url
def __init__(self, addon): self._addon = addon self._cookie_file = os.path.join(self._addon.get_profile(), 'rdio_cookies.txt') self._net = Net(user_agent=getUserAgent(), cookie_file=self._cookie_file) self._state = addon.load_data(self._STATE_FILE_NAME) if not self._state: addon.log_debug( "Persistent auth state not loaded - initialising new state") self._state = self._INITIAL_STATE else: # Check for keys added to state that might not be in the saved copy if 'authorization_key' not in self._state: self._state['authorization_key'] = None addon.log_debug("Loaded persistent auth state") self._init_rdio()