示例#1
2
文件: backend.py 项目: hugues/weboob
    def _fetch_radio_list(self):
        radios = []

        document = self.browser.location(self.ALLINFO)
        for channel in document.iter("div"):
            if "shadow" != channel.get("class"):
                continue
            url = u"" + channel.find("a").get("href")
            radio = Radio(url[(url.rfind("/") + 1) :].replace(".pls", ""))
            radio.title = u"" + channel.getprevious().text
            radio.description = u""

            current_data = u""
            current = Emission(0)
            current.artist, current.title = self._parse_current(current_data)
            radio.current = current

            radio.streams = []
            stream_id = 0
            stream = Stream(stream_id)
            stream.title = radio.title
            stream.url = url
            radio.streams.append(stream)

            radios.append(radio)

        return radios
示例#2
1
    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 = Emission(0)
        current.artist = artist
        current.title = title
        radio.current = current

        radio.streams = []
        name=self._get_stream_name(network,self.config['quality'].get())
        stream = Stream(name)
        stream.title = u'%s %skbps' %\
                (self.NETWORKS[network]['streams'][name]['fmt'],
                 self.NETWORKS[network]['streams'][name]['rate'])
        stream.url = 'http://listen.%s/%s/%s.pls'%\
                (self.NETWORKS[network]['domain'],name,radioName)
        radio.streams.append(stream)
        return radio
示例#3
0
    def get_radio(self, radio):
        if not isinstance(radio, Radio):
            radio = Radio(radio)

        if not radio.id in self._RADIOS:
            return None

        title, hd = self._RADIOS[radio.id]
        radio.title = title
        radio.description = title

        if hd:
            url = self._MP3_HD_URL % (radio.id, radio.id)
        else:
            url = self._MP3_URL % (radio.id, radio.id)

        # This should be asked demand, but is required for now as Radioob
        # does not require it.
        self.fillobj(radio, ('current', ))

        stream = Stream(0)
        stream.title = u'128kbits/s' if hd else u'32kbits/s'
        stream.url = url
        radio.streams = [stream]
        return radio
示例#4
0
    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 = Emission(0)
        current.artist = artist
        current.title = title
        radio.current = current

        radio.streams = []
        name = self._get_stream_name(network, self.config['quality'].get())
        stream = Stream(name)
        stream.title = u'%s %skbps' %\
                (self.NETWORKS[network]['streams'][name]['fmt'],
                 self.NETWORKS[network]['streams'][name]['rate'])
        stream.url = 'http://listen.%s/%s/%s.pls'%\
                (self.NETWORKS[network]['domain'],name,radioName)
        radio.streams.append(stream)
        return radio
示例#5
0
文件: backend.py 项目: hugues/weboob
    def get_radio(self, radio):
        self._fetch_radio_list()

        if not isinstance(radio, Radio):
            radio = Radio(radio)

        if not radio.id in self.RADIOS:
            return None

        radio_dict = self.RADIOS[radio.id]
        radio.title = radio_dict["name"]
        radio.description = radio_dict["description"]

        artist, title = self.get_current(radio.id)
        current = Emission(0)
        current.artist = artist
        current.title = title
        radio.current = current

        radio.streams = []
        for stream_id, format in enumerate(self.FORMATS):
            stream = Stream(stream_id)
            stream.title = u"%s %skbps" % format
            stream.url = self._get_playlist_url(radio.id, format)
            radio.streams.append(stream)
        return radio
示例#6
0
文件: backend.py 项目: hugues/weboob
    def _fetch_radio_list(self):
        radios = []

        document = self.browser.location(self.ALLINFO)
        for channel in document.iter('div'):
            if ("shadow" != channel.get('class')):
                continue
            url = u'' + channel.find('a').get('href')
            radio = Radio(url[(url.rfind('/') + 1):].replace('.pls', ''))
            radio.title = u'' + channel.getprevious().text
            radio.description = u""

            current_data = u""
            current = Emission(0)
            current.artist, current.title = self._parse_current(current_data)
            radio.current = current

            radio.streams = []
            stream_id = 0
            stream = Stream(stream_id)
            stream.title = radio.title
            stream.url = url
            radio.streams.append(stream)

            radios.append(radio)

        return radios
示例#7
0
    def get_radio(self, radio):
        if not isinstance(radio, Radio):
            radio = Radio(radio)

        if not radio.id in self._RADIOS:
            return None

        title, hd = self._RADIOS[radio.id]
        radio.title = title
        radio.description = title

        if hd:
            url = self._MP3_HD_URL % (radio.id, radio.id)
        else:
            url = self._MP3_URL % (radio.id, radio.id)

        # This should be asked demand, but is required for now as Radioob
        # does not require it.
        self.fillobj(radio, ('current', ))

        stream = Stream(0)
        stream.title = u'128kbits/s' if hd else u'32kbits/s'
        stream.url = url
        radio.streams = [stream]
        return radio
示例#8
0
文件: backend.py 项目: hugues/weboob
    def get_radio(self, radio):
        self._fetch_radio_list()

        if not isinstance(radio, Radio):
            radio = Radio(radio)

        if not radio.id in self.RADIOS:
            return None

        radio_dict = self.RADIOS[radio.id]
        radio.title = radio_dict['name']
        radio.description = radio_dict['description']

        artist, title = self.get_current(radio.id)
        current = Emission(0)
        current.artist = artist
        current.title = title
        radio.current = current

        radio.streams = []
        for stream_id, format in enumerate(self.FORMATS):
            stream = Stream(stream_id)
            stream.title = u'%s %skbps' % format
            stream.url = self._get_playlist_url(radio.id, format)
            radio.streams.append(stream)
        return radio
示例#9
0
    def _fetch_radio_list(self):
        radios = []

        document = self.browser.location(self.ALLINFO)
        for channel in document.iter('channel'):
            radio = Radio(channel.get('id'))
            radio.title = channel.findtext('title')
            radio.description = channel.findtext('description')

            current_data = channel.findtext('lastPlaying')
            current = Emission(0)
            current.artist, current.title = self._parse_current(current_data)
            radio.current = current

            radio.streams = []
            stream_id = 0
            for subtag in channel:
                if subtag.tag.endswith('pls'):
                    stream = Stream(stream_id)
                    stream.title = '%s/%s' % (subtag.tag.replace('pls', ''), subtag.get('format'))
                    stream.url = subtag.text
                    radio.streams.append(stream)
                    stream_id += 1

            radios.append(radio)

        return radios
示例#10
0
文件: pages.py 项目: lissyx/weboob
    def iter_radios_list(self):
        radio = Radio('nihon')
        radio.title = 'Nihon no Oto'
        radio.description = u'Nihon no Oto: le son du Japon'
        radio.streams = []

        index = -1

        for el in self.document.xpath('//source'):
            index += 1
            mime_type = el.attrib['type']
            stream_url = el.attrib['src']
            stream = Stream(index)
            stream.title = radio.title + ' ' + mime_type
            stream.url = stream_url
            radio.streams.append(stream)

        yield radio
示例#11
0
文件: pages.py 项目: blckshrk/Weboob
    def iter_radios_list(self):
        radio = Radio('nihon')
        radio.title = u'Nihon no Oto'
        radio.description = u'Nihon no Oto: le son du Japon'
        radio.streams = []

        index = -1

        for el in self.document.xpath('//source'):
            index += 1
            mime_type  = unicode(el.attrib['type'])
            stream_url = unicode(el.attrib['src'])
            stream = Stream(index)
            stream.title = radio.title + ' ' + mime_type
            stream.url = stream_url
            radio.streams.append(stream)

        yield radio
示例#12
0
文件: pages.py 项目: blckshrk/Weboob
    def iter_radios_list(self):
        radio = Radio('necta')
        radio.title = u'Nectarine'
        radio.description = u'Nectarine Demoscene Radio'
        radio.streams = []

        index = -1

        for el in self.document.xpath('//stream'):
            index += 1
            stream_url = unicode(el.findtext('url'))
            bitrate = unicode(el.findtext('bitrate'))
            encode = unicode(el.findtext('type'))
            country = unicode(el.findtext('country')).upper()
            stream = Stream(index)
            stream.title = ' '.join([radio.title, country, encode, bitrate, 'kbps'])
            stream.url = stream_url
            radio.streams.append(stream)

        yield radio
示例#13
0
文件: pages.py 项目: hugues/weboob
    def iter_radios_list(self):
        radio = Radio('necta')
        radio.title = u'Nectarine'
        radio.description = u'Nectarine Demoscene Radio'
        radio.streams = []

        index = -1

        for el in self.document.xpath('//stream'):
            index += 1
            stream_url = unicode(el.findtext('url'))
            bitrate = unicode(el.findtext('bitrate'))
            encode = unicode(el.findtext('type'))
            country = unicode(el.findtext('country')).upper()
            stream = Stream(index)
            stream.title = ' '.join(
                [radio.title, country, encode, bitrate, 'kbps'])
            stream.url = stream_url
            radio.streams.append(stream)

        yield radio
示例#14
0
文件: backend.py 项目: eirmag/weboob
    def get_radio(self, radio):
        if not isinstance(radio, Radio):
            radio = Radio(radio)

        if not radio.id in self._RADIOS:
            return None

        title, description, url = self._RADIOS[radio.id]
        radio.title = title
        radio.description = description

        artist, title = self.get_current()
        current = Emission(0)
        current.artist = artist
        current.title = title
        radio.current = current

        stream = Stream(0)
        stream.title = u'128kbits/s'
        stream.url = url
        radio.streams = [stream]
        return radio