Giter Site home page Giter Site logo

斗鱼失效了 about iina-plus HOT 2 CLOSED

xjbeta avatar xjbeta commented on September 6, 2024
斗鱼失效了

from iina-plus.

Comments (2)

xjbeta avatar xjbeta commented on September 6, 2024 2

已修复 (晚点更新 还有个别的bug)
a64017b
3adebb8

from iina-plus.

guest6379 avatar guest6379 commented on September 6, 2024

js: get_sign

function get_sign(rid, dy_did, tt) 
{
    var cb = rid + dy_did + tt + "220120190227";
    var rb = CryptoJS.MD5(cb).toString();
    var re = [];
    for (var i = 0; i < rb.length / 8; i++)
        re[i] = (parseInt(rb.substr(i * 8, 2), 16) & 0xff) | ((parseInt(rb.substr(i * 8 + 2, 2), 16) << 8) & 0xff00) | ((parseInt(rb.substr(i * 8 + 4, 2), 16) << 24) >>> 8) | (parseInt(rb.substr(i * 8 + 6, 2), 16) << 24);

    var k2 = [0x426d8845, 0x59edcc2d, 0x365400, 0x31b96b4d];
    for (var I = 0; I < 2; I++) 
    {
        var v0 = re[I * 2],
        v1 = re[I * 2 + 1],
        sum = 0,
        i = 0;
        var delta = 0x9e3779b9;
        for (i = 0; i < 32; i++) 
        {
            sum += delta;
            v0 += ((v1 << 4) + k2[0]) ^ (v1 + sum) ^ ((v1 >>> 5) + k2[1]);
            v1 += ((v0 << 4) + k2[2]) ^ (v0 + sum) ^ ((v0 >>> 5) + k2[3]);
        }
        re[I * 2] = v0;
        re[I * 2 + 1] = v1;
    }
    re[0] ^= k2[0];
    re[0] ^= k2[2];
    re[0] ^= k2[0];
    re[0] -= k2[2];
    re[1] = (re[1] >>> (k2[1] % 16)) | (re[1] << (32 - (k2[1] % 16)));
    re[1] ^= k2[3];
    re[1] = (re[1] >>> (k2[3] % 16)) | (re[1] << (32 - (k2[3] % 16)));
    re[2] = (re[2] >>> (k2[0] % 16)) | (re[2] << (32 - (k2[0] % 16)));
    re[2] += k2[2];
    re[2] -= k2[2];
    re[3] -= k2[1];
    re[3] ^= k2[3];
    re[3] -= k2[3];
    re[0] -= k2[0];
    re[0] += k2[2];
    re[0] = (re[0] >>> (k2[2] % 16)) | (re[0] << (32 - (k2[2] % 16)));
    re[1] = (re[1] << (k2[1] % 16)) | (re[1] >>> (32 - (k2[1] % 16)));
    re[1] ^= k2[3];
    re[1] ^= k2[3];
    re[2] += k2[0];
    re[2] = (re[2] >>> (k2[2] % 16)) | (re[2] << (32 - (k2[2] % 16)));
    re[2] = (re[2] >>> (k2[0] % 16)) | (re[2] << (32 - (k2[0] % 16)));
    re[2] += k2[2];
    re[2] = (re[2] << (k2[2] % 16)) | (re[2] >>> (32 - (k2[2] % 16)));
    re[3] += k2[1];
    re[3] = (re[3] << (k2[3] % 16)) | (re[3] >>> (32 - (k2[3] % 16)));
    re[3] += k2[3];
    re[3] = (re[3] << (k2[3] % 16)) | (re[3] >>> (32 - (k2[3] % 16))); 
    {
        var hc = '0123456789abcdef'.split('');
        for (var i = 0; i < re.length; i++) {
            var j = 0,
            s = '';
            for (; j < 4; j++) s += hc[(re[i] >> (j * 8 + 4)) & 15] + hc[(re[i] >> (j * 8)) & 15];
            re[i] = s;
        }
        re = re.join('');
    }
    return re;
}

pseudocode: get_douyu_rtmp_url

def get_douyu_rtmp_url(room_id):
    cookie = get_cookie()
    # example:
    # cookie: dy_did=10ab4930def0490493e0a0b0c29573f1; acf_did=10ab4930def0490493e0a0b0c29573f1;  ...
    # dy_did = 10ab4930def0490493e0a0b0c29573f1

    rid = str(room_id)
    tt = str(time.time()) 
    values = {
    "v": 220120190227,
    "did": dy_did,            
    "tt": tt,
    "sign": get_sign(rid, dy_did, tt),
    "cdn": "",
    "rate": 0,
    "ver": "Douyu_219022605",
    "iar": 1,
    "ive": 0,
    }

    headers = { 'Accept':'application/json, text/plain, */*',
                'Accept-Encoding':'gzip, deflate, br',
                'Accept-Language':'en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7',
                'Content-Type': 'application/x-www-form-urlencoded',
                'Cookie': cookie,
                'DNT':'1',
                'Origin':'https://www.douyu.com',
                'Referer':'https://www.douyu.com/' + rid,
                'User-Agent':'Mozilla/5.0',
                'X-Requested-With':'XMLHttpRequest'}

    data = urllib.urlencode(values)
    url = "https://www.douyu.com/lapi/live/getH5Play/" + rid
    request = urllib2.Request(url, data, headers)# post
    response = urllib2.urlopen(request)
    json_data = response.read()
    print json_data

json_data: example

{
    "error": 0, 
    "msg": "ok", 
    "data": {
        "room_id": 2268066, 
        "is_mixed": false, 
        "mixed_live": "", 
        "mixed_url": "", 
        "rtmp_cdn": "ws-h5", 
        "rtmp_url": "https://hdls3a.douyucdn.cn/live", 
        "rtmp_live": "yyyyyyyyyyyyyyyyyyyyyyyyy", 
        "client_ip": "xxx.xxx.xxx.xxx", 
        "inNA": 0, 
        "rateSwitch": 0, 
        "rate": 0, 
        "cdnsWithName": [
            {
                "name": "主线路", 
                "cdn": "ws-h5"
            }, 
            {
                "name": "备用线路5", 
                "cdn": "tct-h5"
            }
        ], 
        "multirates": [
            {
                "name": "超清", 
                "rate": 0, 
                "highBit": 0
            }
        ], 
        "isPassPlayer": 0, 
        "eticket": null, 
        "online": 0, 
        "mixedCDN": "", 
        "p2p": 2, 
        "streamStatus": 1
    }
}

通过 https://www.douyu.com/lapi/live/getH5Play 获取的 rtmp_url/rtmp_live 好像是分段的,只能播放几秒就会断
斗鱼将h5player的流改成了一段段小的流量包了

from iina-plus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.