How to use the ykdl.extractor.VideoExtractor function in ykdl

To help you get started, we’ve selected a few ykdl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ForgQi / bilibiliupload / ykdl / extractors / youku.py View on Github external
i31 = random.randrange(1 << 31)
    imei = hashCode(str(i31))
    msg = struct.pack('!2i2bi', timestamp, i31, 3, 0, imei)
    key = b'd6fc3a4a06adbde89223bvefedc24fecde188aaa9161'
    data = hmac.new(key, msg, hashlib.sha1).digest()
    msg += struct.pack('!i', hashCode(base64.standard_b64encode(data)))
    return base64.standard_b64encode(msg)

def fetch_cna():
    url = 'https://gm.mmstat.com/yt/ykcomment.play.commentInit?cna='
    req = urlopen(url)
    cookies = req.info()['Set-Cookie']
    cna = match1(cookies, "cna=([^;]+)")
    return cna if cna else "oqikEO1b7CECAbfBdNNf1PM1"

class Youku(VideoExtractor):
    name = u"优酷 (Youku)"
    ref_youku = 'https://v.youku.com'
    ref_tudou = 'https://video.tudou.com'
    ckey_default = "DIl58SLFxFNndSV1GFNnMQVYkx1PP5tKe1siZu/86PR1u/Wh1Ptd+WOZsHHWxysSfAOhNJpdVWsdVJNsfJ8Sxd8WKVvNfAS8aS8fAOzYARzPyPc3JvtnPHjTdKfESTdnuTW6ZPvk2pNDh4uFzotgdMEFkzQ5wZVXl2Pf1/Y6hLK0OnCNxBj3+nb0v72gZ6b0td+WOZsHHWxysSo/0y9D2K42SaB8Y/+aD2K42SaB8Y/+ahU+WOZsHcrxysooUeND"
    ckey_mobile = "7B19C0AB12633B22E7FE81271162026020570708D6CC189E4924503C49D243A0DE6CD84A766832C2C99898FC5ED31F3709BB3CDD82C96492E721BDD381735026"

    def __init__(self):
        VideoExtractor.__init__(self)
        self.params = (
            ('0503', self.ref_youku, self.ckey_default),
            ('0590', self.ref_youku, self.ckey_default),
            ('0505', self.ref_tudou, self.ckey_default),
            )

    def prepare(self):
        add_header("Cookie", '__ysuid=%d' % time.time())
github ForgQi / bilibiliupload / ykdl / extractors / qq / egame.py View on Github external
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from ykdl.util.html import get_content
from ykdl.util.match import match1
from ykdl.extractor import VideoExtractor
from ykdl.videoinfo import VideoInfo
import json


class QQEGame(VideoExtractor):
    name = u'QQ EGAME (企鹅电竟)'


    stream_ids = ['BD8M', 'BD6M', 'BD', 'TD', 'HD', 'SD']
    
    profile_2_id = {
        u'蓝光8M': 'BD8M',
        u'蓝光6M': 'BD6M',
        u'蓝光': 'BD',
        u'超清': 'TD',
        u'高清': 'HD',
        u'流畅': 'SD',
    }

    def prepare(self):
        info = VideoInfo(self.name, True)
github ForgQi / bilibiliupload / ykdl / extractors / douyu / video.py View on Github external
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from ykdl.util.html import get_content, add_header
from ykdl.util.match import match1
from ykdl.extractor import VideoExtractor
from ykdl.videoinfo import VideoInfo
from ykdl.compact import urlencode

from .util import get_h5enc, ub98484234

import json

class DouyutvVideo(VideoExtractor):
    name = u'斗鱼视频 (DouyuTV)'

    stream_ids = ['BD', 'TD', 'HD', 'SD', 'LD']
    profile_2_id = {
        u'high': 'TD',
        u'normal': 'HD',
    }

    def prepare(self):
        info = VideoInfo(self.name)
        pid = match1(self.url, 'show/(.*)')
        if 'vmobile' in self.url:
            self.url = 'https://v.douyu.com/show/' + pid

        html = get_content(self.url)
        info.title = match1(html, u'title>(.+?)_斗鱼视频 - 最6的弹幕视频网站<')
github ForgQi / bilibiliupload / ykdl / extractors / bilibili / live.py View on Github external
from ykdl.extractor import VideoExtractor
from ykdl.videoinfo import VideoInfo
from ykdl.compact import urlencode
from ykdl.util.html import get_content, get_location
from ykdl.util.match import match1, matchall

import json
import random

api_url = 'https://api.live.bilibili.com/room/v1/Room/playUrl?'
api1_url = 'https://api.live.bilibili.com/room/v1/Room/room_init?id={}'
api2_url = 'https://api.live.bilibili.com/room/v1/Room/get_info?room_id={}'
api3_url = 'https://api.live.bilibili.com/live_user/v1/UserInfo/get_anchor_in_room?roomid={}'

class BiliLive(VideoExtractor):
    name = u'Bilibili live (哔哩哔哩 直播)'

    profile_type = [
        (u'原画', 'BD'),
        (u'超清', 'TD'),
        (u'高清', 'HD'),
        (u'流畅', 'SD')
    ]
    supported_stream_profile = [prf for prf, _ in profile_type]
    profile_2_type = dict(profile_type)

    sorted_format = [fmt for _, fmt in profile_type]

    def prepare(self):
        info = VideoInfo(self.name, True)
github ForgQi / bilibiliupload / ykdl / extractors / cctv.py View on Github external
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from ykdl.util.html import get_content
from ykdl.util.match import match1
from ykdl.extractor import VideoExtractor
from ykdl.videoinfo import VideoInfo
from ykdl.compact import urlencode

import json
import time

class CNTV(VideoExtractor):
    name = u'央视网 (CNTV)'

    supported_chapters = [
        ['chapters6',   'BD', u'超高清 1080P'],
        ['chapters5',   'TD', u'超高清 720P'],
        ['chapters4',   'TD', u'超清'],
        ['chapters3',   'HD', u'高清'],
        ['chapters2',   'SD', u'标清'],
        ['lowChapters', 'LD', u'流畅']]

    def prepare(self):
        info = VideoInfo(self.name)
        self.vid = match1(self.url, 'videoCenterId=(\w+)')
        if self.url and not self.vid:
            content = get_content(self.url)
            self.vid = match1(content, 'guid = "([^"]+)', '"videoCenterId","([^"]+)')
github ForgQi / bilibiliupload / ykdl / extractors / sohu / sohubase.py View on Github external
from ykdl.extractor import VideoExtractor
from ykdl.videoinfo import VideoInfo
from ykdl.compact import urlparse, urlencode

import json
import time
from random import random

'''
Changelog:
    1. http://tv.sohu.com/upload/swf/20150604/Main.swf
        new api
'''


class SohuBase(VideoExtractor):

    supported_stream_types = [
        #'h2654kVid',
        #'h2654mVid',
        #'h265oriVid',
        #'h265superVid',
        #'h265highVid',
        #'h265norVid',
        'h2644kVid',
        'oriVid',
        'superVid',
        'highVid',
        'norVid'
    ]
    types_2_id = {
        'h2654kVid': '4k',
github ForgQi / bilibiliupload / ykdl / extractors / douyu / live.py View on Github external
from ykdl.compact import urlencode

from .util import get_h5enc, ub98484234

import time
import json
import uuid
import random
import string


douyu_match_pattern = [ 'class="hroom_id" value="([^"]+)',
                        'data-room_id="([^"]+)'
                      ]

class Douyutv(VideoExtractor):
    name = u'斗鱼直播 (DouyuTV)'

    stream_ids = ['BD10M', 'BD8M', 'BD4M', 'BD', 'TD', 'HD', 'SD']
    profile_2_id = {
        u'蓝光10M': 'BD10M',
        u'蓝光8M': 'BD8M',
        u'蓝光4M': 'BD4M',
        u'蓝光': 'BD',
        u'超清': 'TD',
        u'高清': 'HD',
        u'流畅': 'SD'
     }

    def prepare(self):
        info = VideoInfo(self.name, True)
        add_header("Referer", 'https://www.douyu.com')
github ForgQi / bilibiliupload / ykdl / extractors / iqiyi / live.py View on Github external
'dfp': get_random_str(66),
        'v': 1,
        'k_err_retries': 0,
        'tm': int(tm + 1),
    }
    src = '/live?{}'.format(urlencode(params))
    vf = cmd5x(src)
    req_url = '{}{}&vf={}'.format(host, src, vf)
    st = int(tm * 1000)
    et = int((tm + 1296000) * 1000)
    c_dfp = '__dfp={}@{}@{}'.format(params['dfp'], et, st)
    add_header('Cookie', c_dfp)
    html = get_content(req_url)
    return json.loads(html)

class IqiyiLive(VideoExtractor):
    name = u"爱奇艺直播 (IqiyiLive)"

    ids = ['4k','BD', 'TD', 'HD', 'SD', 'LD']
    type_2_id = {
        #'': '4k',
        'RESOLUTION_1080P': 'BD',
        'RESOLUTION_720P': 'TD',
        'HIGH_DEFINITION': 'HD',
        'SMOOTH': 'SD',
        #'': 'LD'
    }

    def prepare(self):
        info = VideoInfo(self.name, True)
        html = get_content(self.url)
        self.vid = match1(html, '"qipuId":(\d+),')
github ForgQi / bilibiliupload / ykdl / extractors / acfun / acbase.py View on Github external
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from ykdl.util.html import get_content, add_header
from ykdl.util.match import match1, matchall
from ykdl.extractor import VideoExtractor
from ykdl.videoinfo import VideoInfo
from ykdl.compact import urljoin

import json
import random

class AcBase(VideoExtractor):

    stream_ids = ['BD', 'TD', 'HD', 'SD', 'LD']
    quality1_2_id = {
        # min resolution
        1080: 'BD',
        720: 'TD',
        540: 'HD',
        360: 'SD',
        270: 'LD'
    }
    quality2_2_id = {
        # max resolution
        1920: 'BD',
        1280: 'TD',
        960: 'HD',
        640: 'SD',
github ForgQi / bilibiliupload / ykdl / extractors / iqiyi / video.py View on Github external
'vid': vid,
        'v': 0,
        'qypid': '{}_12'.format(tvid),
        'src': '01012001010000000000',
        't': tm,
        'k_tag': 1,
        'k_uid': get_macid(),
        'rs': 1,
    }
    src = '/vps?{}'.format(urlencode(params))
    vf = md5x(src)
    req_url = '{}{}&vf={}'.format(host, src, vf)
    html = get_content(req_url)
    return json.loads(html)

class Iqiyi(VideoExtractor):
    name = u"爱奇艺 (Iqiyi)"

    ids = ['4k','BD', 'TD', 'HD', 'SD', 'LD']
    vd_2_id = dict(sum([[(vd, id) for vd in vds] for id, vds in {
        '4k': [10, 19],
        'BD': [5, 18, 600],
        'TD': [4, 17, 500],
        'HD': [2, 14, 21, 300],
        'SD': [1, 200],
        'LD': [96, 100]
    }.items()], []))
    id_2_profile = {
        '4k': '4k',
        'BD': '1080p',
        'TD': '720p',
        'HD': '540p',