• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python radio.Radio类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中weboob.capabilities.radio.Radio的典型用法代码示例。如果您正苦于以下问题:Python Radio类的具体用法?Python Radio怎么用?Python Radio使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Radio类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _fetch_radio_list

    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
开发者ID:hugues,项目名称:weboob,代码行数:27,代码来源:backend.py


示例2: get_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 = 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
开发者ID:blckshrk,项目名称:Weboob,代码行数:31,代码来源:backend.py


示例3: get_radio

    def get_radio(self, radio):

        def create_stream(url, hd=True):
            stream = BaseAudioStream(0)
            if hd:
                stream.bitrate = 128
            else:
                stream.bitrate = 32
                url = url.replace('midfi', 'lofi')

            stream.format = u'mp3'
            stream.title = u'%s kbits/s' % (stream.bitrate)
            stream.url = url
            return stream

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

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

        title = self._RADIOS[radio.id]['title']
        player_url = self._RADIOS[radio.id]['player']
        radio.title = title
        radio.description = title
        radio_name = radio.id if not radio.id.startswith('fb') else 'francebleu'
        url = self.browser.get_radio_url(radio_name, player_url)

        self.fillobj(radio, ('current', ))
        radio.streams = [create_stream(url), create_stream(url, False)]
        return radio
开发者ID:laurentb,项目名称:weboob,代码行数:31,代码来源:module.py


示例4: iter_radios

    def iter_radios(self):
        document = self.infos.go().doc
        for channel in document.iter('channel'):
            id = channel.get('id')
            radio = Radio(id)
            radio.title = channel.findtext('title')
            radio.description = channel.findtext('description')

            current_data = channel.findtext('lastPlaying')
            current = StreamInfo(0)
            current.what, current.who = self._parse_current(current_data)
            radio.current = current

            radio.streams = []
            stream_id = 0
            for subtag in channel:
                if subtag.tag.endswith('pls'):
                    stream = BaseAudioStream(stream_id)
                    bitrate = subtag.text.replace('http://somafm.com/'+id, '').replace('.pls','')
                    if bitrate != '':
                        stream.bitrate = int(bitrate)
                        bitrate += 'Kbps'
                    else:
                        stream.bitrate = 0
                        bitrate = subtag.tag.replace('pls', '')
                    stream.format = subtag.get('format')
                    stream.title = '%s/%s' % (bitrate, stream.format)
                    stream.url = subtag.text
                    radio.streams.append(stream)
                    stream_id += 1

            yield radio
开发者ID:laurentb,项目名称:weboob,代码行数:32,代码来源:browser.py


示例5: get_radio

    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
开发者ID:hugues,项目名称:weboob,代码行数:26,代码来源:backend.py


示例6: get_radio

    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 = BaseAudioStream(0)
        if hd:
            stream.bitrate=128
        else:
            stream.bitrate=32
        stream.format=u'mp3'
        stream.title = u'%s kbits/s' % (stream.bitrate)
        stream.url = url
        radio.streams = [stream]
        return radio
开发者ID:Boussadia,项目名称:weboob,代码行数:30,代码来源:backend.py


示例7: _fetch_radio_list

    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
开发者ID:blckshrk,项目名称:Weboob,代码行数:27,代码来源:backend.py


示例8: get_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

        radio.streams, radio.current = self.get_stream_info(radio.id, url)
        return radio
开发者ID:P4ncake,项目名称:weboob,代码行数:14,代码来源:module.py


示例9: iter_radios_list

    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
开发者ID:blckshrk,项目名称:Weboob,代码行数:18,代码来源:pages.py


示例10: get_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
开发者ID:juliaL03,项目名称:weboob,代码行数:44,代码来源:module.py


示例11: iter_radios_list

    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.doc.xpath('//stream'):
            index += 1
            stream_url = el.findtext('url')
            bitrate = el.findtext('bitrate')
            encode = el.findtext('type')
            country = el.findtext('country').upper()
            stream = BaseAudioStream(index)
            stream.bitrate = int(bitrate)
            stream.format = encode
            stream.title = ' '.join([radio.title, country, encode, str(bitrate), 'kbps'])
            stream.url = stream_url
            radio.streams.append(stream)

        yield radio
开发者ID:P4ncake,项目名称:weboob,代码行数:22,代码来源:pages.py


示例12: get_radio

    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
开发者ID:eirmag,项目名称:weboob,代码行数:22,代码来源:backend.py


示例13: iter_radios_list

    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 = BaseAudioStream(index)
            stream.bitrate = 128
            if mime_type == u"audio/mpeg":
                stream.format = u"mp3"
            elif mime_type == u"audio/ogg":
                stream.format = u"vorbis"
            stream.title = radio.title + " " + mime_type
            stream.url = stream_url
            radio.streams.append(stream)

        yield radio
开发者ID:kyrre,项目名称:weboob,代码行数:23,代码来源:pages.py


示例14: iter_radios_list

    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 = BaseAudioStream(index)
            stream.bitrate = 128
            if (mime_type == u'audio/mpeg'):
                stream.format = u'mp3'
            elif (mime_type == u'audio/ogg'):
                stream.format = u'vorbis'
            stream.title = radio.title + ' ' + mime_type
            stream.url = stream_url
            radio.streams.append(stream)

        yield radio
开发者ID:Boussadia,项目名称:weboob,代码行数:23,代码来源:pages.py


示例15: get_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
开发者ID:kyrre,项目名称:weboob,代码行数:24,代码来源:module.py



注:本文中的weboob.capabilities.radio.Radio类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python video.BaseVideo类代码示例发布时间:2022-05-26
下一篇:
Python messages.Thread类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap