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


Python match.match1函数代码示例

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


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

示例1: get_vid

        def get_vid():
            html = get_content(self.url)
            video_info = match1(html, ":video-info='(.+?)'")

            if video_info:
                video_info = json.loads(video_info)
                self.vid = str(video_info['tvId']), str(video_info['vid'])
                info.title = video_info['name']

            else:
                tvid = match1(html,
                              'tvId:\s*"([^"]+)',
                              'data-video-tvId="([^"]+)',
                              '''\['tvid'\]\s*=\s*"([^"]+)''',
                              '"tvId":\s*([^,]+)')
                videoid = match1(html,
                                'data-video-vid="([^"]+)',
                                'vid:\s*"([^"]+)',
                                '''\['vid'\]\s*=\s*"([^"]+)''',
                                '"vid":\s*([^,]+)')
                if not (tvid and videoid):
                    url = match1(html, '(www\.iqiyi\.com/v_\w+\.html)')
                    if url:
                        self.url = 'https://' + url
                        return get_vid()
                self.vid = (tvid, videoid)
                info.title = match1(html, '<title>([^<]+)').split('-')[0]
开发者ID:zhangn1985,项目名称:ykdl,代码行数:27,代码来源:video.py

示例2: prepare

    def prepare(self):
        info = VideoInfo(self.name, True)

        if not self.vid:
            html = get_content(self.url)
            room = match1(html, 'var $ROOM = ([^;]+)')
            self.vid = match1(html, '"room_id.?":(\d+)')
            info.title = json.loads("{\"room_name\" : \"" + match1(html, '"room_name.?":"([^"]+)') + "\"}")['room_name']
            info.artist = json.loads("{\"name\" : \"" + match1(html, '"owner_name.?":"([^"]+)') + "\"}")['name']
        api_url = 'https://www.douyu.com/lapi/live/getPlay/{}'.format(self.vid)
        tt = str(int(time.time() / 60))
        rnd_md5 = hashlib.md5(str(random.random()).encode('utf8'))
        did = rnd_md5.hexdigest().upper()
        to_sign = ''.join([self.vid, did, API_KEY, tt])
        sign = stupidMD5(to_sign)
        for stream in self.stream_ids:
            rate = self.stream_id_2_rate[stream]
            params = {"ver" : VER, "sign" : sign, "did" : did, "rate" : rate, "tt" : tt, "cdn" : "ws"}
            form = urlencode(params)
            html_content = get_content(api_url, data=compact_bytes(form, 'utf-8'))
            live_data = json.loads(html_content)
            assert live_data["error"] == 0, "live show is offline"
            live_data = live_data["data"]
            real_url = '/'.join([live_data['rtmp_url'], live_data['rtmp_live']])

            info.stream_types.append(stream)
            info.streams[stream] = {'container': 'flv', 'video_profile': self.id_2_profile[stream], 'src' : [real_url], 'size': float('inf')}

        return info
开发者ID:flfq,项目名称:ykdl,代码行数:29,代码来源:live.py

示例3: prepare

    def prepare(self):
        info = VideoInfo(self.name, True)
        if not self.vid:
            self.vid = match1(self.url, '/(\d+)')
        if not self.vid:
            html = get_content(self.url)
            self.vid = match1(html, '"liveAddr":"([0-9\_]+)"')
        self.pid = self.vid

        # from upstream!!
        serverDataTxt = match1(html, 'serverData = {([\S\ ]+)};')
        serverDataTxt = '{%s}' % (serverDataTxt)
        self.logger.debug("serverDataTxt => %s" % (serverDataTxt))

        serverData = json.loads(serverDataTxt)
        self.logger.debug(serverData)

        assert serverData["liveInfo"]["data"]["profileInfo"]["isLive"] == 1, 'error: live show is not on line!!'

        info.title = serverData["liveInfo"]["data"]["videoInfo"]["title"]
        info.artist = serverData["liveInfo"]["data"]["profileInfo"]["nickName"]

        for data in serverData["liveInfo"]["data"]["videoInfo"]["streamInfos"]:
            info.stream_types.append(self.bitrate_2_type[data["bitrate"]])
            info.streams[self.bitrate_2_type[data["bitrate"]]] = {'container': 'flv', 'video_profile': data["desc"], 'src': ["%s&_t=%s000"%(unescape(data["playUrl"]),int(time.time()))], 'size': float('inf')}

        return info
开发者ID:wwqgtxx,项目名称:ykdl,代码行数:27,代码来源:egame.py

示例4: prepare

    def prepare(self):
        info = VideoInfo(self.name, True)
        html = get_content(self.url)
        t_a = match1(html, '"keywords" content="([^"]+)')
        info.title = t_a.split(',')[0]
        info.artist = t_a.split(',')[1]

        replay_url = match1(html, '"m3u8":"([^"]+)')
        if replay_url:
            replay_url = replay_url.replace('\/','/')
            info.live = False
            info.stream_types.append('current')
            info.streams['current'] = {'container': 'm3u8', 'video_profile': 'current', 'src' : [replay_url], 'size': float('inf')}
            return info

        self.vid = match1(html, '"sn":"([^"]+)')
        channel = match1(html, '"channel":"([^"]+)')
        api_url = 'http://g2.live.360.cn/liveplay?stype=flv&channel={}&bid=huajiao&sn={}&sid={}&_rate=xd&ts={}&r={}&_ostype=flash&_delay=0&_sign=null&_ver=13'.format(channel, self.vid, SID, time.time(),random.random())
        encoded_json = get_content(api_url)
        decoded_json = base64.decodestring(compact_bytes(encoded_json[0:3]+ encoded_json[6:], 'utf-8')).decode('utf-8')
        video_data = json.loads(decoded_json)
        live_url = video_data['main']
        info.live = True
        info.stream_types.append('current')
        info.streams['current'] = {'container': 'flv', 'video_profile': 'current', 'src' : [live_url], 'size': float('inf')}
        return info
开发者ID:PureTV,项目名称:ykdl,代码行数:26,代码来源:huajiao.py

示例5: get_vid

 def get_vid(url):
     vid = match1(url, 'http://www.mgtv.com/b/\d+/(\d+).html')
     if vid is None:
         html = get_content(url)
         vid = match1(html, 'vid=(\d+)', 'vid=\"(\d+)') or \
             match1(html, r'vid: (\d+)')
     return vid
开发者ID:PureTV,项目名称:ykdl,代码行数:7,代码来源:mgtv.py

示例6: prepare

    def prepare(self):
        html = get_content(self.url)
        title = match1(html, u'<title>(.+?)丨嘀哩嘀哩</title>')
        source_url = match1(html, r'var sourceUrl\s?=\s?"(.+?)"', r'var Url\s?=\s?"(.+?)"')
        
        # First type, bangumi
        # http://www.dilidili.wang/watch3/72766/ or
        # http://www.dilidili.wang/watch3/52919/
        if source_url:
            ext = source_url.split('?')[0].split('.')[-1]
        
            # Dilidili hosts this video itself
            if ext in ('mp4', 'flv', 'f4v', 'm3u', 'm3u8'):
                self.build_videoinfo(title, ext, source_url)
        
            # It is an embedded video from other websites
            else:
                self.video_info['url'] = source_url
                self.video_info['title'] = title

        # Second type, user-uploaded videos
        # http://www.dilidili.wang/huiyuan/76983/
        else:
            player_url = match1(html, r'<iframe src="(.+?)"')
            html = get_content(player_url)
            video_url = match1(html, r'var main = "(.+?)"')
            video_url_full = '/'.join(player_url.split('/')[0:3]) + video_url
            ext = video_url.split('?')[0].split('.')[-1]
            self.build_videoinfo(title, ext, video_url_full)
开发者ID:wwqgtxx,项目名称:ykdl,代码行数:29,代码来源:dilidili.py

示例7: prepare

    def prepare(self):
        self.vid = match1(self.url, 'd=(\d+)', 'live/(\d+)')
        if '/izt/' in self.url:
            vid = self.vid
            if not vid:
                html = get_content(self.url)
                vid = match1(html, 'vid\s*:\s*"(\d+)",', 'vid="(\d+)"')
            return get_playback(vid)
        else:
            if not self.vid:
                html = get_content(self.url)
                self.vid = match1(html, 'liveId\s*:\s*"(\d+)"')

        live_data = json.loads(get_content('http://api.live.letv.com/v1/liveRoom/single/1001?id={}'.format(self.vid)))
        if live_data.get('status') != 2:
            return get_playback(live_data['recordingId'])

        # live video is dead, the followed code will not be used
        live_data = json.loads(get_content('http://player.pc.le.com/player/startup_by_pid/1001/{}?host=live.le.com'.format(self.vid)))

        info = VideoInfo(self.name, True)
        info.title = live_data['title']
        stream_data = live_data['rows']

        for s in stream_data:
            stream_id = self.stream_2_id[s['rateType']]
            stream_profile = self.stream_2_profile[s['rateType']]
            if not stream_id in info.stream_types:
                info.stream_types.append(stream_id)
                streamUrl = s['streamUrl'] + '&format=1&expect=2&termid=1&platid=10&playid=1&sign=live_web&splatid=1001&vkit=20161017&station={}'.format( self.vid)
                data = json.loads(get_content(streamUrl))
                src = data['location']
                info.streams[stream_id] = {'container': 'm3u8', 'video_profile': stream_profile, 'size' : float('inf'), 'src' : [src]}
        info.stream_types = sorted(info.stream_types, key = self.stream_ids.index)
        return info
开发者ID:wwqgtxx,项目名称:ykdl,代码行数:35,代码来源:live.py

示例8: prepare

    def prepare(self):
        info = VideoInfo(self.name, True)
        html = get_content(self.url)
        info.title = match1(html, '<title>([^<]+)').split('_')[0]

        data = json.loads(match1(html, 'channelOneInfo = ({.+?});'))
        tag_from = 'huomaoh5room'
        tn = str(int(time.time()))
        sign_context = data['stream'] + tag_from + tn + SECRETKEY
        token = hashlib.md5(compact_bytes(sign_context, 'utf-8')).hexdigest()

        params = { 'streamtype':'live',
                   'VideoIDS': data['stream'],
                   'time': tn,
                   'cdns' : '1',
                   'from': tag_from,
                   'token': token
                }
        content = get_content(self.live_base, data=compact_bytes(urlencode(params), 'utf-8'), charset='utf-8')
        stream_data = json.loads(content)

        assert stream_data["roomStatus"] == "1", "The live stream is not online! "
        for stream in stream_data["streamList"]:
            if stream['default'] == 1:
                defstream = stream['list']

        for stream in defstream:
            info.stream_types.append(stream['type'])
            info.streams[stream['type']] = {'container': 'flv', 'video_profile': self.stream_2_profile[stream['type']], 'src' : [stream['url']], 'size': float('inf')}

        info.stream_types = sorted(info.stream_types, key = self.supported_stream_types.index)
        return info
开发者ID:wwqgtxx,项目名称:ykdl,代码行数:32,代码来源:huomao.py

示例9: prepare

    def prepare(self):
        info = VideoInfo(self.name)
        if not self.vid:
            html = get_content(self.url)
            self.vid = match1(html, 'video_id:\'([^\']+)') or match1(self.url, '#(\d+)')

        assert self.vid, "can't get vid"

        api_url = 'http://s.video.sina.com.cn/video/h5play?video_id={}'.format(self.vid)
        data = json.loads(get_content(api_url))['data']
        info.title = data['title']
        for t in ['mp4', '3gp', 'flv']:
            if t in data['videos']:
                video_info = data['videos'][t]
                break

        for profile in video_info:
            if not profile in info.stream_types:
                v = video_info[profile]
                tp = v['type']
                url = v['file_api']+'?vid='+v['file_id']
                r_url = get_realurl(url)
                info.stream_types.append(profile)
                info.streams[profile] = {'container': tp, 'video_profile': profile, 'src': [r_url], 'size' : 0}
        return info
开发者ID:PureTV,项目名称:ykdl,代码行数:25,代码来源:video.py

示例10: prepare

    def prepare(self):
        info = VideoInfo(self.name, True)
        html = get_content(self.url)
        info.title = match1(html, '<title>([^<]+)').split('_')[0]

        video_name = match1(html, 'getFlash\("[0-9]+","([^"]+)')
        params = { 'streamtype':'live',
                   'VideoIDS': video_name,
                   'cdns' : '1'
                }
        form = urlencode(params)
        content = get_content(self.live_base,data=compact_bytes(form, 'utf-8'),charset = 'utf-8')
        stream_data = json.loads(content)

        assert stream_data["roomStatus"] == "1", "The live stream is not online! "
        for stream in stream_data["streamList"]:
            if stream['default'] == 1:
                defstream = stream['list']

        for stream in defstream:
            info.stream_types.append(stream['type'])
            info.streams[stream['type']] = {'container': 'flv', 'video_profile': self.stream_2_profile[stream['type']], 'src' : [stream['url']], 'size': float('inf')}

        info.stream_types = sorted(info.stream_types, key = self.supported_stream_types.index)
        return info
开发者ID:gitter-badger,项目名称:ykdl,代码行数:25,代码来源:huomao.py

示例11: l_assert

    def l_assert(self):
        # Mobile ver.
        self.title_patterns = '"content2": "(.+?)",', '"status_title": "(.+?)",'
        self.url_patterns = '"stream_url_hd": "([^"]+)', '"stream_url": "([^"]+)'
        if 'm.weibo.cn' in self.url:
            return
        if 'weibo.com' in self.url and '/tv/v/' not in self.url and 'fid=' not in self.url:
            self.url = self.url.replace('weibo.com', 'm.weibo.cn', 1)
            return

        self.url_patterns = r'(?:data-url|controls src)\s*=\s*[\"\']([^\"\']+)',
        self.title_patterns = '<title>([^<]+)</',
        self.url = self.url.replace('%3A', ':')
        fid = match1(self.url, r'\?fid=(\d{4}:\w+)')
        if fid is not None:
            self.url = 'http://p.weibo.com/show/channerWbH5/{}'.format(fid)
        elif '/p/230444' in self.url:
            fid = match1(url, r'/p/230444(\w+)')
            self.url = 'http://p.weibo.com/show/channerWbH5/1034:{}'.format(fid)
        else:
            html = get_content(self.url)
            url = match1(html, '"page_url": "([^"]+)')
            assert url, 'No url match'
            self.url = url
            self.l_assert()
开发者ID:wwqgtxx,项目名称:ykdl,代码行数:25,代码来源:weibo.py

示例12: prepare

    def prepare(self):
        info = VideoInfo(self.name, True)
        if not self.vid:
            self.vid = match1(self.url, '/(\d+)')
        if not self.vid:
            html = get_content(self.url)
            self.vid = match1(html, '"room_id":(\d+)')

        #from upstream!!
        api_url = 'http://www.qie.tv/api/v1/room/{}'.format(self.vid)

        metadata = json.loads(get_content(api_url))
        assert metadata['error'] == 0, 'error {}: {}'.format(metadata['error'], metadata['data'])

        livedata = metadata['data']
        assert livedata['show_status'] == '1', 'error: live show is not on line!!'

        info.title = livedata['room_name']
        info.artist = livedata['nickname']

        base_url = livedata['rtmp_url']

        if 'hls_url' in livedata:
            info.stream_types.append('BD')
            info.streams['BD'] = {'container': 'm3u8', 'video_profile': u'原画', 'src' : [livedata['hls_url']], 'size': float('inf')}

        mutli_stream = livedata['rtmp_multi_bitrate']
        for i in self.mutli_bitrate:
            if i in mutli_stream:
                info.stream_types.append(self.bitrate_2_type[i])
                info.streams[self.bitrate_2_type[i]] = {'container': 'flv', 'video_profile': self.bitrate_2_profile[i], 'src' : [base_url + '/' + mutli_stream[i]], 'size': float('inf')}
        return info
开发者ID:PureTV,项目名称:ykdl,代码行数:32,代码来源:live.py

示例13: prepare

    def prepare(self):
        info = VideoInfo(self.name)
        add_header("Referer", "http://www.bilibili.com")
        info.extra["referer"] = "http://www.bilibili.com"
        info.extra["ua"] = fake_headers['User-Agent']
        if not self.vid:
            html = get_content(self.url)
            self.vid = match1(html, 'cid=(\d+)', 'cid=\"(\d+)')
            info.title = match1(html, '<title>([^<]+)').split("_")[0].strip(u" 番剧 bilibili 哔哩哔哩弹幕视频网")
            if not self.vid:
                eid = match1(self.url, 'anime/v/(\d+)', 'play#(\d+)') or match1(html, 'anime/v/(\d+)')
                if eid:
                    Episode_info = json.loads(get_content('http://bangumi.bilibili.com/web_api/episode/{}.json'.format(eid)))['result']['currentEpisode']
                    self.vid = Episode_info['danmaku']
                    info.title = info.title + ' ' + Episode_info['indexTitle'] + '.  ' + Episode_info['longTitle']

        assert self.vid, "can't play this video: {}".format(self.url)
        for q in self.supported_stream_profile:
            sign_this = hashlib.md5(compact_bytes('cid={}&from=miniplay&player=1&quality={}{}'.format(self.vid, 3-self.supported_stream_profile.index(q), SECRETKEY_MINILOADER), 'utf-8')).hexdigest()
            api_url = 'http://interface.bilibili.com/playurl?cid={}&player=1&quality={}&from=miniplay&sign={}'.format(self.vid, 3-self.supported_stream_profile.index(q), sign_this)
            html = get_content(api_url)
            self.logger.debug("HTML> {}".format(html))
            urls, size, ext = parse_cid_playurl(html)
            if ext == 'hdmp4':
                ext = 'mp4'

            info.stream_types.append(self.profile_2_type[q])
            info.streams[self.profile_2_type[q]] = {'container': ext, 'video_profile': q, 'src' : urls, 'size': size}
        return info
开发者ID:flfq,项目名称:ykdl,代码行数:29,代码来源:video.py

示例14: prepare

    def prepare(self):
        info = VideoInfo(self.name)
        if not self.vid:
            self.vid = match1(self.url, '/show(?:/channel)?/([^\./]+)',
                                        '/media/([^\./]+)')
        if not self.vid:
            html = get_content(self.url)
            self.vid = match1(html, 's[cm]id ?= ?[\'"]([^\'"]+)[\'"]')
        assert self.vid, "No VID match!"

        data = json.loads(get_content('https://n.miaopai.com/api/aj_media/info.json?smid={}'.format(self.vid)))
        if 'status' in data:
            if data['status'] != 200:
                data = json.loads(get_content('http://api.miaopai.com/m/v2_channel.json?fillType=259&scid={}&vend=miaopai'.format(self.vid)))

            assert data['status'] == 200, data['msg']

            data = data['result']
            info.title = data['ext']['t'] or self.name + '_' + self.vid
            url = data['stream']['base']
            ext = data['stream']['and']
        else:
            assert data['code'] == 200, data['msg']

            data = data['data']
            info.title = data['description'] or self.name + '_' + self.vid
            url = data['meta_data'][0]['play_urls']['m']
            _, ext, _ = url_info(url)

        info.stream_types.append('current')
        info.streams['current'] = {'container': ext or 'mp4', 'src': [url], 'size' : 0}
        return info
开发者ID:wwqgtxx,项目名称:ykdl,代码行数:32,代码来源:miaopai.py

示例15: prepare

    def prepare(self):
        info = VideoInfo(self.name)
        if self.url and not self.vid:
            self.vid = match1(self.url, 'http://www.mgtv.com/b/\d+/(\d+).html')
            if self.vid is None:
                html = get_content(self.url)
                self.vid = match1(html, 'vid=(\d+)', 'vid=\"(\d+)', 'vid: (\d+)')

        api_url = 'http://pcweb.api.mgtv.com/player/video?video_id={}'.format(self.vid)
        meta = json.loads(get_content(api_url))

        assert meta['code'] == 200, '[failed] status: {}, msg: {}'.format(meta['status'],meta['msg'])
        assert meta['data'], '[Failed] Video not found.'

        data = meta['data']

        info.title = data['info']['title']
        domain = data['stream_domain'][0]
        for lstream in data['stream']:
            if lstream['url']:
                url = json.loads(get_content(domain + lstream['url']))['info']
                info.streams[self.profile_2_types[lstream['name']]] = {'container': 'm3u8', 'video_profile': lstream['name'], 'src' : [url]}
                info.stream_types.append(self.profile_2_types[lstream['name']])
        info.stream_types= sorted(info.stream_types, key = self.supported_stream_types.index)
        return info
开发者ID:flfq,项目名称:ykdl,代码行数:25,代码来源:mgtv.py


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