tunein.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:AlexaPi 作者: alexa-pi 项目源码 文件源码
def parse_stream_url(self, url):
        logger.debug('Extracting URIs from %s', url)
        extension = urlparse(url).path[-4:]
        if extension in ['.mp3', '.wma']:
            logger.debug('Got %s', url)
            return [url]  # Catch these easy ones
        results = []
        playlist, content_type = self._get_playlist(url)
        if playlist:
            parser = find_playlist_parser(extension, content_type)
            if parser:
                playlist_data = StringIO.StringIO(playlist)
                try:
                    results = [u for u in parser(playlist_data)
                               if u and u != url]
                except Exception as exp:   # pylint: disable=broad-except
                    logger.error('TuneIn playlist parsing failed %s', exp)
                if not results:
                    logger.debug('Parsing failure, '
                                 'malformed playlist: %s', playlist)
        elif content_type:
            results = [url]
        logger.debug('Got %s', results)
        return list(OrderedDict.fromkeys(results))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号