Ejemplo n.º 1
0
Archivo: video.py Proyecto: PureTV/ykdl
def get_realurl(url):
    location = get_location(url)
    if location != url:
        return location
    else:
       html = get_content(url)
       return matchall(html, ['CDATA\[([^\]]+)'])[1]
Ejemplo n.º 2
0
def get_realurl(url):
    location = get_location(url)
    if location != url:
        return location
    else:
        html = get_content(url)
        return matchall(html, ['CDATA\[([^\]]+)'])[1]
Ejemplo n.º 3
0
def get_extractor(url):
    if 'live.bilibili' in url:
        from . import live as s
        return s.site, url
    elif 'vc.bilibili' in url:
        from . import vc as s
        return s.site, url
    elif '/bangumi/' in url:
        from . import bangumi as s
        return s.site, url

    av_id = match1(url, '(?:/av|aid=)(\d+)')
    page_index = match1(url, '(?:page|\?p)=(\d+)', 'index_(\d+)\.') or '1'
    if page_index == '1':
        url = 'https://www.bilibili.com/av{}/'.format(av_id)
    else:
        url = 'https://www.bilibili.com/av{}/?p={}'.format(av_id, page_index)
    add_header('Referer', 'https://www.bilibili.com/')
    url = get_location(url)

    if '/bangumi/' in url:
        from . import bangumi as s
    else:
        from . import video as s

    return s.site, url
Ejemplo n.º 4
0
    def l_assert(self):
        if self.url.startswith('http://'):
            self.url = self.url.replace('http://', 'https://', 1)
        self.url = get_location(self.url)

        if 'passport.weibo.com' in self.url:
            query = urlsplit(self.url).query
            self.url = parse_qs(query)['url'][0]
            return self.l_assert()

        # Mobile ver.
        if 'm.weibo.cn' in self.url:
            self.title_patterns = '"content2": "(.+?)",', '"status_title": "(.+?)",'
            self.url_patterns = '"stream_url_hd": "([^"]+)', '"stream_url": "([^"]+)'
            return

        if '/tv/v/' in self.url or 'fid=' not in self.url:
            self.title_patterns = 'class="info_txt \w+">([^<]+)</', 'class="WB_text \w+"[^>]+>\s*(?:<a[^<]+</a>)?\s*([^<]+)'
            self.url_patterns = 'video-sources\s*=\s*".+?(?:&\d+=http.+?)*&\d+=(http.+?[^=])(?:&\d+=)*&qType=\w+"',
            return

        self.title_patterns = '<title>([^<]+)</',
        self.url_patterns = r'(?:data-url|controls src)\s*=\s*[\"\']([^\"\']+)',
        html = get_content(self.url)
        url = match1(html, '"page_url": "([^"]+)')
        assert url, 'No url match'
        self.url = url
        self.l_assert()
Ejemplo n.º 5
0
    def prepare(self):
        info = VideoInfo(self.name)

        vid = match1(self.url, '/(\d+)\.mp4')
        if vid:
            r_url = get_location(
                'https://ask.ivideo.sina.com.cn/v_play_ipad.php?vid=' + vid)
        elif 'vid=' in self.url:
            r_url = get_location(self.url)

        info.stream_types.append('current')
        info.streams['current'] = {
            'container': 'mp4',
            'video_profile': 'current',
            'src': [r_url],
            'size': 0
        }
        return info
Ejemplo n.º 6
0
def get_extractor(url):
    if 'gamelive' in url:
        url = get_location(url)
    if 'pps.' in url:
        from ykdl.extractors import pps as s
    elif 'live.iqiyi' in url:
        from . import live as s
    else:
        from . import video as s

    return s.site, url
Ejemplo n.º 7
0
def get_extractor(url):
    url = get_location(url)
    if re.search("live.bili", url):
        from . import live as s
    elif re.search("vc.bili", url):
        from . import vc as s
    elif re.search("bangumi", url):
        from . import bangumi as s
    else:
        from . import video as s
    return s.site
Ejemplo n.º 8
0
def get_extractor(url):
    if not 'bangumi' in url:
        url = get_location(url)
    if re.search("live.bili", url):
        from . import live as s
    elif re.search("vc.bili", url):
        from . import vc as s
    elif re.search("bangumi", url):
        from . import bangumi as s
    else:
        from . import video as s
    return s.site
Ejemplo n.º 9
0
def get_extractor(url):
    if '/v.' in url:
        add_header(
            'User-Agent',
            'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) '
            'AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 '
            'Mobile/15E148 Safari/604.1')
        url = get_location(url)
    if '/live.' in url or 'amemv.com' in url:
        from . import live as s
    else:
        from . import video as s

    return s.site, url
Ejemplo n.º 10
0
def get_extractor(url):
    if 'live.bilibili' in url:
        from . import live as s
        return s.site, url
    elif 'vc.bilibili' in url:
        from . import vc as s
        return s.site, url
    elif '/bangumi/' in url:
        from . import bangumi as s
        return s.site, url

    page_index = match1(url, '(?:page|\?p)=(\d+)', 'index_(\d+)\.') or '1'

    av_id = match1(url, '(?:/av|aid=)(\d+)')
    if av_id:
        bv_id = av2bv(av_id)
    else:
        bv_id = match1(url, '((?:BV|bv)[0-9A-Za-z]{10})')

    if bv_id:
        try:
            data = json.loads(get_content(API_view + bv_id))
            assert data['code'] == 0, "can't play this video!!"
            url = data['data']['redirect_url']
        except AssertionError:
            raise
        except:
            url = 'https://www.bilibili.com/video/' + bv_id
    else:
        url = get_location(url)

    if '/bangumi/' in url:
        from . import bangumi as s
    else:
        if page_index > '1':
            url = '{}?p={}'.format(url, page_index)
        from . import video as s

    return s.site, url
Ejemplo n.º 11
0
    def get_vid_title(self):
        self.url = get_location(self.url)
        html = get_content(self.url)
        title = match1(html, '<h1 title="([^"]+)', '<title>([^<]+)').strip()

        if "movie" in self.url:
            aid = match1(html, 'aid=(\d+)', 'aid=\"(\d+)')
            form = {"movie_aid": aid}
            vid = json.loads(
                get_content("https://bangumi.bilibili.com/web_api/get_source",
                            data=compact_bytes(urlencode(form),
                                               'utf-8')))["result"]["cid"]
        else:
            eid = match1(self.url, 'anime/v/(\d+)', 'play#(\d+)',
                         'ep(\d+)') or match1(html, 'anime/v/(\d+)')
            Episode_info = json.loads(
                get_content(
                    'http://bangumi.bilibili.com/web_api/episode/{}.json'.
                    format(eid)))['result']['currentEpisode']
            vid = Episode_info['danmaku']
            title = title + ' ' + Episode_info[
                'indexTitle'] + '.  ' + Episode_info['longTitle']

        return vid, title
Ejemplo n.º 12
0
 def prepare(self):
     if not re.search('video.tuodou.com', self.url):
         self.url = get_location(self.url)
     return Youku.prepare(self)
Ejemplo n.º 13
0
 def prepare(self):
     if match1(self.url, '(new-play|video)\.tudou\.com/') is None:
         self.url = get_location(self.url)
     return Youku.prepare(self)
Ejemplo n.º 14
0
Archivo: tudou.py Proyecto: flfq/ykdl
 def prepare(self):
     if not re.search('video.tuodou.com', self.url):
         self.url = get_location(self.url)
     return Youku.prepare(self)
Ejemplo n.º 15
0
 def prepare(self):
     if match1(self.url, '(new-play|video)\.tudou\.com/') is None:
         self.url = get_location(self.url)
     return Youku.prepare(self)
Ejemplo n.º 16
0
    def prepare(self):
        info = VideoInfo(self.name)
        html = None
        title = None

        if 'show' in self.url:
            new_url = get_location(self.url)
            if new_url != self.url:
                self.logger.debug('redirect to' + new_url)
                self.url = new_url

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


        if len(self.vid) > 24:
            add_header('Referer', self.url)
            cb = '_jsonp{}'.format(get_random_str(10))
            json_html = get_content(api_info1.format(self.vid, cb))
            data = json.loads(json_html[json_html.find('{'):-2])
            assert data['code'] == 200, data['msg']

            data = data['data']
            title = data['description']
            url = data['meta_data'][0]['play_urls']['m']
            _, ext, _ = url_info(url)
        
        else:
            try:
                data = json.loads(get_content(api_info2.format(self.vid)))
                assert data['status'] == 200, data['msg']

                data = data['result']
                title = data['ext']['t']
                scid = data['scid'] or self.vid
                ext = data['stream']['and']
                base = data['stream']['base']
                vend = data['stream']['vend']
                url = '{}{}.{}?vend={}'.format(base, scid, ext, vend)
            except:
                # fallback
                data = json.loads(get_content(api_stream.format(self.vid)))
                assert data['status'] == 200, data['msg']

                data = data['result'][0]
                ext = None
                scheme = data['scheme']
                host = data['host']
                path = data['path']
                sign = data['sign']
                url = '{}{}{}{}'.format(scheme, host, path, sign)

        if not title:
            if not html:
                html = get_content(self.url)
            title = match1(html, '<meta name="description" content="([^"]+)">')
        if title:
            info.title = title

        info.stream_types.append('current')
        info.streams['current'] = {
            'container': ext or 'mp4',
            'src': [url],
            'size' : 0
        }
        return info