• 大小: 4.03MB
    文件类型: .zip
    金币: 2
    下载: 0 次
    发布日期: 2024-02-06
  • 语言: 其他
  • 标签: 开源项目  

资源简介

kuplayer:一个基于对优酷网站的分析获得播放地址,经过播放地址的解码,由开源的QtAV的播放库相应解码播放。引用的相关开源库:https://github.com/wang-bin/QtAV


标签:kuplayer

资源截图

代码片段和文件信息

#!/usr/bin/env python
# -*-coding:utf-8-*-

import urllib
import urllib2
import re
import threading
import time
import base64
import json

# from py_kuplayer import *
# L = get_html(“http://box.zhangmen.baidu.com/x?op=12&count=1&title=最炫民族风$$凤凰传奇$$$$“)
# print L

            

fake_headers = {
    ‘Accept‘: ‘text/htmlapplication/xhtml+xmlapplication/xml;q=0.9*/*;q=0.8‘
    ‘Accept-Charset‘: ‘UTF-8*;q=0.5‘
    ‘Accept-Language‘: ‘en-USen;q=0.8‘
    ‘User-Agent‘: ‘Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20100101 Firefox/13.0‘
}

def get_html(url):
    req = urllib2.Request(urlheaders=fake_headers)
    response = urllib2.urlopen(req)
    return response.read()


class Youku():

    def __init__(self *args):
        self.url = None
        self.vid = None
        self.streams = {}
        # self.audiolang = None

    stream_types = [
        {‘id‘: ‘hd2‘ ‘container‘: ‘flv‘}
        {‘id‘: ‘mp4‘ ‘container‘: ‘mp4‘}
        {‘id‘: ‘flv‘ ‘container‘: ‘flv‘}
    ]

    @staticmethod
    def generate_ep(vid ep):
        f_code_1 = ‘becaf9be‘
        f_code_2 = ‘bf7e5f01‘

        def trans_e(a c):
            f = h = 0
            b = list(range(256))
            result = ‘‘
            while h < 256:
                f = (f + b[h] + ord(a[h % len(a)])) % 256
                b[h] b[f] = b[f] b[h]
                h += 1
            q = f = h = 0
            while q < len(c):
                h = (h + 1) % 256
                f = (f + b[h]) % 256
                b[h] b[f] = b[f] b[h]
                if isinstance(c[q] int):
                    result += chr(c[q] ^ b[(b[h] + b[f]) % 256])
                else:
                    result += chr(ord(c[q]) ^ b[(b[h] + b[f]) % 256])
                q += 1

            return result

        e_code = trans_e(f_code_1 base64.b64decode(bytes(ep)))
        sid token = e_code.split(‘_‘)
        new_ep = trans_e(f_code_2 ‘%s_%s_%s‘ % (sid vid token))
        return base64.b64encode(bytes(new_ep)) sid token

    @staticmethod
    def parse_m3u8(m3u8):
        return re.findall(r‘(http://[^?]+)\?ts_start=0‘ m3u8)

    @staticmethod
    def match_vid(text pattern):
        match = re.search(pattern text)
        if match:
            return match.group(1)
        else:
            return None

    @staticmethod
    def get_vid_from_url(url):
        return Youku.match_vid(url r‘youku\.com/v_show/id_([a-zA-Z0-9=]+)‘)

    def prepare(self **kwargs):
        assert self.url or self.vid

        if self.url and not self.vid:
            self.vid = self.__class__.get_vid_from_url(self.url)

        playlist = json.loads(
         get_html(‘http://v.youku.com/player/getPlayList/VideoIDS/%s/Pf/4/ctype/12/ev/1‘ % self.vid)
         )
        playlistdata0 = playlist[‘data‘][0]

        self.ep = playlistdata0[‘ep‘]
        self.ip = playlistdata0[‘ip‘]

        for stream_type in self.stream_types:
            if stream_type[‘id‘] in playlistdata0[‘streamsizes‘]:
                stream_id 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-08-16 05:37  kuplayer-master\
     文件         117  2018-08-16 05:37  kuplayer-master\.gitignore
     文件      462146  2018-08-16 05:37  kuplayer-master\.main.png
     文件        1210  2018-08-16 05:37  kuplayer-master\LICENSE
     文件         277  2018-08-16 05:37  kuplayer-master\README.md
     文件       16958  2018-08-16 05:37  kuplayer-master\kuplayer.ico
     文件        2559  2018-08-16 05:37  kuplayer-master\kuplayer.pro
     文件       18373  2018-08-16 05:37  kuplayer-master\kuplayer.pro.user
     文件          51  2018-08-16 05:37  kuplayer-master\kuplayer.rc
     文件       16179  2018-08-16 05:37  kuplayer-master\kuplayer_zn.ts
     目录           0  2018-08-16 05:37  kuplayer-master\pyscript\
     文件        8453  2018-08-16 05:37  kuplayer-master\pyscript\py_kuplayer.py
     目录           0  2018-08-16 05:37  kuplayer-master\resources\
     目录           0  2018-08-16 05:37  kuplayer-master\resources\libs\
     文件        3983  2018-08-16 05:37  kuplayer-master\resources\libs\QtSingleApplication
     文件       53110  2018-08-16 05:37  kuplayer-master\resources\libs\libQtSingleApplication.so
     文件      668742  2018-08-16 05:37  kuplayer-master\resources\libs\libboost_python.a
     文件       49218  2018-08-16 05:37  kuplayer-master\resources\libs\libboost_system.a
     文件      475920  2018-08-16 05:37  kuplayer-master\resources\libs\liboptions_64.so
     目录           0  2018-08-16 05:37  kuplayer-master\src\
     文件        4634  2018-08-16 05:37  kuplayer-master\src\about_widget.ui
     文件        8148  2018-08-16 05:37  kuplayer-master\src\base_set_weidget.ui
     文件        1032  2018-08-16 05:37  kuplayer-master\src\common.cpp
     文件        2171  2018-08-16 05:37  kuplayer-master\src\common.h
     文件         739  2018-08-16 05:37  kuplayer-master\src\conf_info.cpp
     文件        2156  2018-08-16 05:37  kuplayer-master\src\conf_info.h
     文件        1103  2018-08-16 05:37  kuplayer-master\src\control_label.cpp
     文件        1165  2018-08-16 05:37  kuplayer-master\src\control_label.h
     文件        6607  2018-08-16 05:37  kuplayer-master\src\control_widget.cpp
     文件        1667  2018-08-16 05:37  kuplayer-master\src\control_widget.h
     文件        3544  2018-08-16 05:37  kuplayer-master\src\detail_label.cpp
............此处省略90个文件信息

评论

共有 条评论