当前位置: 首页>>代码示例>>Python>>正文


Python util.decode_html函数代码示例

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


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

示例1: init_by_json

    def init_by_json(self,js):
        #name
        self.song_name = util.decode_html(js['name'])

        # artist_name
        self.artist_name = js['artists'][0]['name']
        # album id, name
        self.album_name = util.decode_html(js['album']['name'])
        self.album_id = js['album']['id']

        # download link
        dfsId = ''
        if self.handler.is_hq and js['hMusic']:
            dfsId = js['hMusic']['dfsId']
        elif js['mMusic']:
            dfsId = js['mMusic']['dfsId']
        elif js['lMusic']:
            LOG.warning(u'歌曲(%s) 无法获取128kbps资源,尝试获取低质量资源'%self.song_name)
            dfsId = js['lMusic']['dfsId']
        if dfsId:
            self.dl_link = url_mp3 % (self.handler.encrypt_dfsId(dfsId), dfsId)
        else:
            LOG.warning(u'歌曲(%s) 无法获取下载链接'%self.song_name)

        #used only for album/collection etc. create a dir to group all songs
        #if it is needed, it should be set by the caller
        self.group_dir = None
开发者ID:hhhaiai,项目名称:zhuaxia,代码行数:27,代码来源:netease.py

示例2: init_by_json

    def init_by_json(self, js):
        # song_id
        self.song_id = js["id"]
        # name
        self.song_name = util.decode_html(js["name"])

        # artist_name
        self.artist_name = js["artists"][0]["name"]
        # album id, name
        self.album_name = util.decode_html(js["album"]["name"])
        self.album_id = js["album"]["id"]

        # download link
        dfsId = ""
        if self.handler.is_hq and js["hMusic"]:
            dfsId = js["hMusic"]["dfsId"]
        elif js["mMusic"]:
            dfsId = js["mMusic"]["dfsId"]
        elif js["lMusic"]:
            LOG.warning(msg.head_163 + msg.fmt_quality_fallback % self.song_name)
            dfsId = js["lMusic"]["dfsId"]
        if dfsId:
            self.dl_link = url_mp3 % (self.handler.encrypt_dfsId(dfsId), dfsId)
        else:
            LOG.warning(msg.head_163 + msg.fmt_err_song_parse % self.song_name)

        # used only for album/collection etc. create a dir to group all songs
        # if it is needed, it should be set by the caller
        self.group_dir = None
开发者ID:rokite,项目名称:zhuaxia,代码行数:29,代码来源:netease.py

示例3: init_by_json

    def init_by_json(self, song_json ):
        """ 
        This method will handle HQ option too
        the group dir and abs_path should be set by the caller
        """

        self.song_id = song_json['song_id']
        self.album_id = song_json['album_id']
        title = song_json['artist'] + '_' + self.song_id
        if song_json['songName']:
            title = song_json['songName']
        elif song_json['name']:
            title = song_json['name']
        elif song_json['title']:
            title = song_json['title']

        self.song_name = util.decode_html(title)
        location = song_json['location']
        #decode download link
        self.dl_link = self.handler.decode_xiami_link(location)
        # set lyrics link if dl_lyric flag is true
        self.lyric_link = song_json['lyric_url'] if self.handler.dl_lyric else ''
        # artist_name
        self.artist_name = song_json['artist']
        # album id, name
        self.album_name = util.decode_html(song_json['album_name'])

        #if is_hq, get the hq location to overwrite the dl_link
        if self.handler.is_hq:
            try:
                hq_link = self.handler.get_hq_link(song_json)
                self.dl_link = hq_link if hq_link else self.dl_link
            except:
                #if user was not VIP, don't change the dl_link
                pass
开发者ID:sk1418,项目名称:zhuaxia,代码行数:35,代码来源:xiami.py

示例4: init_by_json

    def init_by_json(self,js):
        #song_id
        self.song_id = js['id']
        #name
        self.song_name = util.decode_html(js['name'])
        

        # artist_name
        self.artist_name = js['artists'][0]['name']
        # album id, name
        self.album_name = util.decode_html(js['album']['name'])
        self.album_id = js['album']['id']
        #track no
        if js['position']:
            self.track_no = js['position']
        elif js['no']:
            self.track_no = js['no']

        # download link
        dfsId = ''
        if self.handler.is_hq and js['hMusic']:
            dfsId = js['hMusic']['dfsId']
        elif js['mMusic']:
            dfsId = js['mMusic']['dfsId']
        elif js['lMusic']:
            LOG.warning(msg.head_163 + msg.fmt_quality_fallback %self.song_name)
            dfsId = js['lMusic']['dfsId']
        if dfsId:
            self.dl_link = url_mp3 % (self.handler.encrypt_dfsId(dfsId), dfsId)
        else:
            LOG.warning(msg.head_163 + msg.fmt_err_song_parse %self.song_name)

        #used only for album/collection etc. create a dir to group all songs
        #if it is needed, it should be set by the caller
        self.group_dir = None
开发者ID:wjhssfs,项目名称:zhuaxia,代码行数:35,代码来源:netease.py

示例5: init_by_json

    def init_by_json(self, song_json ):
        """ the group dir and abs_path should be set by the caller"""

        self.song_id = song_json['song_id']
        self.album_id = song_json['album_id']
        self.song_name = util.decode_html(song_json['title'])
        location = song_json['location']
        #decode download link
        self.dl_link = self.handler.decode_xiami_link(location)
        # set lyrics link if dl_lyric flag is true
        self.lyric_link = song_json['lyric_url'] if self.handler.dl_lyric else ''
        # artist_name
        self.artist_name = song_json['artist']
        # album id, name
        self.album_name = util.decode_html(song_json['album_name'])
开发者ID:aniikiki,项目名称:zhuaxia,代码行数:15,代码来源:xiami.py

示例6: resolve

def resolve(url):
    url = util.decode_html(url)
    util.info('Resolving '+url)
    resolver = _get_resolver(url)
    value = None
    if resolver == None:
        return None
    util.debug('Using resolver '+str(resolver.__name__));
    try:
        value = resolver.resolve(url)
    except:
        traceback.print_exc()
    if value == None:
        return []
    default = item()
    # fix  missing but required values 
    def fix_stream(i,url,resolver,default):
        if not 'name' in i.keys():
            i['name'] = resolver.__name__
        if not 'surl' in i.keys():
            i['surl'] = url
        for key in default.keys():
            if not key in i.keys():
                i[key] = default[key]
    [fix_stream(i,url,resolver,default) for i in value]
    return sorted(value,key=lambda i:i['quality'])
开发者ID:vrockai,项目名称:xbmc-doplnky,代码行数:26,代码来源:resolver.py

示例7: init_album

    def init_album(self):
        #album json
        js = self.handler.read_link(url_album % self.album_id).json()['album']
        #name
        self.album_name = util.decode_html(js['name'])
        #album logo
        self.logo = js['picUrl']
        # artist_name
        self.artist_name = js['artists'][0]['name']
        #handle songs
        for jsong in js['songs']:
            song = NeteaseSong(self.handler, song_json=jsong)
            song.group_dir = self.artist_name + u'_' + self.album_name
            song.group_dir = song.group_dir.replace('/', '_')
            song.post_set()
            self.songs.append(song)

        d = path.dirname(self.songs[-1].abs_path)
        #creating the dir
        LOG.debug(msg.head_163 + msg.fmt_create_album_dir % d)
        util.create_dir(d)

        #download album logo images
        LOG.debug(msg.head_163 + msg.fmt_dl_album_cover % self.album_name)
        downloader.download_url(self.logo, path.join(d,'cover.' +self.logo.split('.')[-1]))
开发者ID:sk1418,项目名称:zhuaxia,代码行数:25,代码来源:netease.py

示例8: resolve

def resolve(url):
    """
        resolves given url by asking all resolvers

        returns None if no resolver advised to be able to resolve this url
        returns False if resolver did his job, but did not return any value (thus failed)
        returns Array of resolved objects in positive usecase
    """
    url = util.decode_html(url)
    util.info('Resolving ' + url)
    resolver = _get_resolver(url)
    value = None
    if resolver is None:
        return None
    util.info('Using resolver \'%s\'' % str(resolver.__name__));
    try:
        value = resolver.resolve(url)
    except:
        traceback.print_exc()
    if value is None:
        return False
    default = item()

    def fix_stream(i, url, resolver, default):
        """ fix  missing but required values """
        if 'name' not in i.keys():
            i['name'] = resolver.__name__
        if 'surl' not in i.keys():
            i['surl'] = url
        for key in default.keys():
            if key not in i.keys():
                i[key] = default[key]

    [fix_stream(i, url, resolver, default) for i in value]
    return sorted(value, key=lambda i: i['quality'])
开发者ID:slavkodemeter,项目名称:archivczsk-doplnky,代码行数:35,代码来源:resolver.py

示例9: download

def download(addon, filename, url, local, notifyFinishDialog=True, headers={}):
    try:
        util.info('Downloading %s to %s' % (url, local))
    except:
        util.info('Downloading ' + url)
    local = xbmc.makeLegalFilename(local)
    try:
        filename = util.replace_diacritic(util.decode_html(filename))
    except:
        filename = 'Video soubor'
    icon = os.path.join(addon.getAddonInfo('path'), 'icon.png')
    notifyEnabled = addon.getSetting('download-notify') == 'true'
    notifyEvery = addon.getSetting('download-notify-every')
    notifyPercent = 1
    if int(notifyEvery) == 0:
        notifyPercent = 10
    if int(notifyEvery) == 1:
        notifyPercent = 5

    def encode(string):
        return u' '.join(string).encode('utf-8')

    def notify(title, message, time=3000):
        try:
            xbmcgui.Dialog().notification(encode(title), encode(message), time=time, icon=icon,
                                          sound=False)
        except:
            traceback.print_exc()
            error('unable to show notification')

    def callback(percent, speed, est, filename):
        if percent == 0 and speed == 0:
            notify(xbmc.getLocalizedString(13413), filename)
            return
        if notifyEnabled:
            if percent > 0 and percent % notifyPercent == 0:
                esTime = '%ss' % est
                if est > 60:
                    esTime = '%sm' % int(est / 60)
                message = xbmc.getLocalizedString(
                    24042) % percent + ' - %s KB/s %s' % (speed, esTime)
                notify(message, filename)

    downloader = Downloader(callback)
    result = downloader.download(url, local, filename, headers)
    try:
        if result == True:
            if xbmc.Player().isPlaying():
                notify(xbmc.getLocalizedString(20177), filename)
            else:
                if notifyFinishDialog:
                    xbmcgui.Dialog().ok(xbmc.getLocalizedString(20177), filename)
                else:
                    notify(xbmc.getLocalizedString(20177), filename)
        else:
            notify(xbmc.getLocalizedString(257), filename)
            xbmcgui.Dialog().ok(filename, xbmc.getLocalizedString(257) + ' : ' + result)
    except:
        traceback.print_exc()
开发者ID:bbaronSVK,项目名称:script.module.stream.resolver,代码行数:59,代码来源:xbmcutil.py

示例10: _extract_infolabels

 def _extract_infolabels(self, item):
     infoLabels = {}
     for label in ['title', 'plot', 'year', 'genre', 'rating', 'director',
                   'votes', 'cast', 'trailer', 'tvshowtitle', 'season',
                   'episode', 'duration']:
         if label in item.keys():
             infoLabels[label] = util.decode_html(item[label])
     return infoLabels
开发者ID:bbaronSVK,项目名称:script.module.stream.resolver,代码行数:8,代码来源:xbmcprovider.py

示例11: init_by_url

    def init_by_url(self,url):
        self.song_id = re.search(r'(?<=/song/)\d+', url).group(0)
        j = self.xm.read_link(url_song % self.song_id).json()
        #name
        #self.song_name = j['song']['song_name'].replace('&#039;',"'")
        self.song_name = util.decode_html(j['song']['song_name'])
        # download link
        self.dl_link = j['song']['song_location']
        # lyrics link
        self.lyrics_link = j['song']['song_lrc']
        # artist_name
        self.artist_name = j['song']['artist_name']
        # album id, name
        self.album_name = util.decode_html(j['song']['album_name'])
        self.album_id = j['song']['album_id']

        #used only for album/collection etc. create a dir to group all songs
        self.group_dir = None
开发者ID:Alexander-kim,项目名称:zhuaxia,代码行数:18,代码来源:xiami.py

示例12: add_plugin_call

def add_plugin_call(name, plugin, params, logo="", infoLabels={}):
    name = util.decode_html(name)
    infoLabels["Title"] = name
    liz = xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=logo)
    try:
        liz.setInfo(type="Video", infoLabels=infoLabels)
    except:
        traceback.print_exc()
    plugurl = util._create_plugin_url(params, plugin)
    return xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=plugurl, listitem=liz, isFolder=True)
开发者ID:lzoubek,项目名称:xbmc-doplnky-old,代码行数:10,代码来源:default.py

示例13: list

    def list(self,url):
        if url.find('#fm#') == 0:
            return self.list_folder(url[5:])
        url = self._url(url)
        page = util.request(url,headers={'X-Requested-With':'XMLHttpRequest','Referer':url,'Cookie':'uloz-to-id=1561277170;'}).decode('string-escape')
        script = util.substr(page,'var kn','</script>')
        keymap = None
        key = None
        k = re.search(r'({.+?})',script)
        if k:
            keymap = util.json.loads(k.group(1))
        j = re.search(r'ad.push\(\[kn, kn\["([^"]+)', script)
        if j:
            key = j.group(1)
        if not (j and k):
            self.error('error parsing page - unable to locate keys')
            return []
        burl = b64decode('I2h0dHA6Ly9kZWNyLWNlY2gucmhjbG91ZC5jb20vZGVjcnlwdC8/a2V5PSVzJnZhbHVlPSVz')
        murl = b64decode('aHR0cDovL2RlY3ItY2VjaC5yaGNsb3VkLmNvbS9kZWNyeXB0Lw==')
        result = []
        req = {'seed':keymap[key],'values':keymap}
        decr = json.loads(util.post_json(murl,req))
        for li in re.finditer('<div data-icon=\"(?P<key>[^\"]+)',page, re.IGNORECASE |  re.DOTALL):
            body = urllib.unquote(b64decode(decr[li.group('key')]))
            div_name = util.substr(body, '<div class="name"', '</div>')
            title_url_match = re.search(r'<a href="(?P<url>[^"]+)" title="(?P<title>[^"]+)', div_name)

            if not title_url_match:
                continue
            item = self.video_item()
            item['title'] = title_url_match.group('title')
            item['url'] = title_url_match.group('url')

            div_media = util.substr(body, 'div class="media"', '<div class="tools">')
            img_match = re.search(r'img src="([^"]+)', div_media)
            if img_match:
                item['img'] = "http:" + img_match.group(1)
            time_match = re.search(r'<span>Čas</span>(.+)', div_media)
            if time_match:
                item['length'] = time_match.group(1).strip()
            size_match = re.search(r'<span>Velikost</span>([^<]+)', div_media)
            if size_match:
                item['size'] = size_match.group(1).strip()
            self._filter(result,item)
        # page navigation
        data = util.substr(page,'<div class=\"paginator','</div')
        mnext = re.search('<a href=\"(?P<url>[^\"]+)\" class="next',data)
        if mnext:
            item = self.dir_item()
            item['type'] = 'next'
            item['url'] = util.decode_html(mnext.group('url'))
            result.append(item)
        return result
开发者ID:mx3L,项目名称:archivczsk-doplnky,代码行数:53,代码来源:ulozto.py

示例14: init_by_json

    def init_by_json(self,js):
        #name
        self.song_name = util.decode_html(js['name'])

        # artist_name
        self.artist_name = js['artists'][0]['name']
        # album id, name
        self.album_name = util.decode_html(js['album']['name'])
        self.album_id = js['album']['id']

        # download link
        dfsId = ''
        if self.handler.is_hq and js['hMusic']:
            dfsId = js['hMusic']['dfsId']
        else:
            dfsId = js['mMusic']['dfsId']
        self.dl_link = url_mp3 % (self.handler.encrypt_dfsId(dfsId), dfsId)

        #used only for album/collection etc. create a dir to group all songs
        #if it is needed, it should be set by the caller
        self.group_dir = None
开发者ID:CreateChen,项目名称:zhuaxia,代码行数:21,代码来源:netease.py

示例15: init_by_url

    def init_by_url(self,url):
        self.song_id = re.search(r'(?<=/song/)\d+', url).group(0)
        j = self.xm.read_link(url_song % self.song_id).json()
        #name
        #self.song_name = j['song']['song_name'].replace('&#039;',"'")
        self.song_name = util.decode_html(j['song']['song_name'])
        # download link
        self.dl_link = j['song']['song_location']
        # lyrics link
        self.lyrics_link = j['song']['song_lrc']
        # artist_name
        self.artist_name = j['song']['artist_name']
        # album id, name
        self.album_name = util.decode_html(j['song']['album_name'])
        self.album_id = j['song']['album_id']

        #used only for album/collection etc. create a dir to group all songs
        self.group_dir = None
        #filename  artistName_songName.mp3
        self.filename = (self.artist_name + u"_" if self.artist_name  else "" ) + self.song_name + u'.mp3'
        self.abs_path = path.join(config.DOWNLOAD_DIR,self.filename)
开发者ID:amath0312,项目名称:zhuaxia,代码行数:21,代码来源:xiami.py


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