def get_current_emission(self): current = StreamInfo(0) two_or_more = unicode(self.document.xpath('//p')[0].text).split('/////')[0].split(' - ') # Consider that if String(' - ') appears it'll be in title rather in the artist name if len(two_or_more) > 2: current.who = two_or_more.pop(0) current.what = ' - '.join(two_or_more) else: current.who, current.what = two_or_more return current
def get_current_emission(self): current = StreamInfo(0) two_or_more = unicode( self.document.xpath('//p')[0].text).split('/////')[0].split(' - ') # Consider that if String(' - ') appears it'll be in title rather in the artist name if len(two_or_more) > 2: current.who = two_or_more.pop(0) current.what = ' - '.join(two_or_more) else: current.who, current.what = two_or_more return current
def get_radio(self, radio): if not isinstance(radio, Radio): if radio == 'nova': # old id radio = '19577' radio = Radio(radio) if radio.id not in self.RADIOS: return None json = self.browser.open('http://www.nova.fr/radio/%s/player' % radio.id).json() radio.title = radio.description = json['radio']['name'] if 'currentTrack' in json: current = StreamInfo(0) current.who = json['currentTrack']['artist'] current.what = json['currentTrack']['title'] radio.current = current stream = BaseAudioStream(0) stream.bitrate = 128 stream.format = 'mp3' stream.title = '128kbits/s' stream.url = json['radio']['high_def_stream_url'] radio.streams = [stream] return radio
def get_stream_info(self, radio, url): stream = BaseAudioStream(0) current = StreamInfo(0) r = self.browser.open(url, stream=True, headers={'Icy-Metadata': 1}) stream.bitrate = int(r.headers['icy-br'].split(',')[0]) r.raw.read(int(r.headers['icy-metaint'])) size = ord(r.raw.read(1)) content = r.raw.read(size * 16) r.close() for s in content.split("\x00")[0].split(";"): a = s.split("=") if a[0] == "StreamTitle": stream.title = to_unicode(a[1].split("'")[1]) res = stream.title.split(" - ") current.who = to_unicode(res[0]) if (len(res) == 1): current.what = "" else: current.what = to_unicode(res[1]) stream.format = u'mp3' stream.url = url return [stream], current
def get_current_emission(self): current = StreamInfo(0) current.who = unicode( self.document.xpath('//playlist/now/entry/artist')[0].text) current.what = unicode( self.document.xpath('//playlist/now/entry/song')[0].text) return current
def get_stream_info(self, radio, url): stream = BaseAudioStream(0) current = StreamInfo(0) r = self.browser.open(url, stream=True, headers={'Icy-Metadata':'1'}) stream.bitrate = int(r.headers['icy-br'].split(',')[0]) r.raw.read(int(r.headers['icy-metaint'])) size = ord(r.raw.read(1)) content = r.raw.read(size*16) r.close() for s in content.split("\x00")[0].split(";"): a = s.split("=") if a[0] == "StreamTitle": stream.title = to_unicode(a[1].split("'")[1]) res = stream.title.split(" - ") current.who = to_unicode(res[0]) if(len(res) == 1): current.what = "" else: current.what = to_unicode(res[1]) stream.format=u'mp3' stream.url = url return [stream], current
def get_radio(self, radio): if not isinstance(radio, Radio): radio = Radio(radio) radioName, network = radio.id.split('.', 1) self._fetch_radio_list(network) if radioName not in self.RADIOS[network]: return None radio_dict = self.RADIOS[network][radioName] radio.title = radio_dict['name'] radio.description = radio_dict['name'] artist, title = self.get_current(network, radioName) current = StreamInfo(0) current.who = artist current.what = title radio.current = current radio.streams = [] defaultname = self._get_stream_name(network, self.config['quality'].get()) stream = BaseAudioStream(0) stream.bitrate = self.NETWORKS[network]['streams'][defaultname]['rate'] stream.format = self.NETWORKS[network]['streams'][defaultname]['fmt'] stream.title = u'%s %skbps' % (stream.format, stream.bitrate) stream.url = 'http://%s/%s/%s.pls' %\ (self.NETWORKS[network]['domain'], defaultname, radioName) radio.streams.append(stream) i = 1 for name in self.NETWORKS[network]['streams'].keys(): if name == defaultname: continue stream = BaseAudioStream(i) stream.bitrate = self.NETWORKS[network]['streams'][name]['rate'] stream.format = self.NETWORKS[network]['streams'][name]['fmt'] stream.title = u'%s %skbps' % (stream.format, stream.bitrate) stream.url = 'http://%s/%s/%s.pls' % \ (self.NETWORKS[network]['domain'], name, radioName) radio.streams.append(stream) i = i + 1 return radio
def get_radio(self, radio): if not isinstance(radio, Radio): radio = Radio(radio) radioName, network = radio.id.split('.', 1) self._fetch_radio_list(network) if not radioName in self.RADIOS[network]: return None radio_dict = self.RADIOS[network][radioName] radio.title = radio_dict['name'] radio.description = radio_dict['description'] artist, title = self.get_current(network, radioName) current = StreamInfo(0) current.who = artist current.what = title radio.current = current radio.streams = [] defaultname = self._get_stream_name(network, self.config['quality'].get()) stream = BaseAudioStream(0) stream.bitrate = self.NETWORKS[network]['streams'][defaultname]['rate'] stream.format = self.NETWORKS[network]['streams'][defaultname]['fmt'] stream.title = u'%s %skbps' % (stream.format, stream.bitrate) stream.url = 'http://listen.%s/%s/%s.pls' %\ (self.NETWORKS[network]['domain'], defaultname, radioName) radio.streams.append(stream) i = 1 for name in self.NETWORKS[network]['streams'].keys(): if name == defaultname: continue stream = BaseAudioStream(i) stream.bitrate = self.NETWORKS[network]['streams'][name]['rate'] stream.format = self.NETWORKS[network]['streams'][name]['fmt'] stream.title = u'%s %skbps' % (stream.format, stream.bitrate) stream.url = 'http://listen.%s/%s/%s.pls'%\ (self.NETWORKS[network]['domain'], name, radioName) radio.streams.append(stream) i = i + 1 return radio
def get_radio(self, radio): if not isinstance(radio, Radio): radio = Radio(radio) if radio.id not in self._RADIOS: return None title, description, url, bitrate = self._RADIOS[radio.id] radio.title = title radio.description = description artist, title = self.get_current(radio.id) current = StreamInfo(0) current.who = artist current.what = title radio.current = current stream = BaseAudioStream(0) stream.bitrate = bitrate stream.format = u"mp3" stream.title = u"%skbits/s" % (stream.bitrate) stream.url = url radio.streams = [stream] return radio
def get_radio(self, radio): if not isinstance(radio, Radio): radio = Radio(radio) if radio.id not in self._RADIOS: return None title, description, url, bitrate = self._RADIOS[radio.id] radio.title = title radio.description = description artist, title = self.get_current(radio.id) current = StreamInfo(0) current.who = artist current.what = title radio.current = current stream = BaseAudioStream(0) stream.bitrate = bitrate stream.format = u'mp3' stream.title = u'%skbits/s' % (stream.bitrate) stream.url = url radio.streams = [stream] return radio
def get_current_emission(self): current = StreamInfo(0) current.who = unicode(self.document.xpath('//playlist/now/entry/artist')[0].text) current.what = unicode(self.document.xpath('//playlist/now/entry/song')[0].text) return current