目录
芒果TV真实播放源解析【播放下载VIP视频】
/        

芒果TV真实播放源解析【播放下载VIP视频】

首先随便找一部剧

例如:https://www.mgtv.com/b/345877/11739597.html?no_wakeup=1

使用浏览器的开发者工具进行抓包

image.png

找到真实的播放源

image.png

然后搜索m3u8找到请求接口

https://web-disp.titan.mgtv.com/atcl?pm2=tDCBvvmih~wVcYpZjI0YN4abvNBY5LkDOPqjcDXxbiltLYd~1I4cOBqKC0FNNgbj~qw~j~LNPSv4osAW8vTH_X_KDGmLGTQtw1xicgKwgbNe4WbywYJp_Hnhedc6QgFhD51xfrzv_NMnHi01zrCVkq9zYAYQT~Xhdx~FyqxksGPRTJV9O3ZeQi~rhowYE6d9fc0e5a6QHoU5CQ7~VZG2Mq8LOfN~iAWeNGCRNai83odMHsVGTO0aXARbH6SKlrJ6jsFNJEEcK79N0IFsPY~7VrrCEKLsQ1wjFaUHD3emKqPVfbvE9FXEg~AHlBRWvxkvT6lVSRN7BR983TDPB5j00TTyaVSFPkDqd85oKSPxnuZ5t6OLzqATxRLsUOgOXWUnDKY8y634FPCdX10gjO3zJOT2U9rQMJZ4PY0JY4YcW2Le22VCT2s6xPw10koAO8lw46Ea9qOBAZirDhpSqdh67uQ314MNiP7ILHqxbv8XD0QRRiBuDK7x4ZGhRdnnKKa6jpi1672~pYKUYtJtn9OgwWBGbLimOCJ6l46Ya4Sc0G2e0PCAmPCxBslg~3rqfSp4evPbHB8a4Kk-&gsid=bf514bf3-2aab-459c-84f3-680a552ea570&pno=1030&arange=0&did=b8128c40-90b0-4502-b06c-93e043791785&suuid=b9423edf-d341-4213-ab18-82ff2364c152&&callback=jsonp_1620520305826_49507

这个链接我们直接访问时400错误,后面请求接口中的type参数改成pad即可解决

继续搜索,搜atcl

image.png

将 stream_domain 和 url 构成了获取真实播放源的接口

https://pcweb.api.mgtv.com/player/getSource?_support=10000000&tk2=wAzMwITNwIjNx0Ddpx2Y8FDMzAjLz4CM9IXZ2xHMzATM98mbwxXN4cTM5czM0ATZzkTLjZDMi1iMwUDNtAjYwkTLwQzY4ITM4IWPklGZ&pm2=BueMls6MBq9QrCTJcUNrmWt4GEjzqpONdn9YBNFix0Pbafl9aFgIAxrd7l~C6FdK6spw61pCMuD4ADBhMBgatj5NbYUd8ZfhWzXaUTDMYunpO4kE4ENBkcqvbZ5NYMvOBnfntitqFYsAVt6pCMmMR_qSpLVHH0FiVuo51UoG4_Vhv4tHP0RhygqC0naInZAnLHYmoYxjxPf3KEpf7GTXc4g~RLi11p_5py9DYUa4wsfN_JIpVegki2LDtEZn4oWc5sv9gA7TeDsTNUxleKRBEtm2I8tfzZxZqeIT0DRyiF3F4wi4WV1mhK3uoQHr0ySoZpsJanERJZv1FakojKb1IWcZ4jVI2ztrN8nm0g--&video_id=11739597&type=pch5&auth_mode=1&src=&abroad=&callback=jsonp_1620520300742_98918

经过简化后留下

https://pcweb.api.mgtv.com/player/getSource?tk2=1EjNxITNwIjNx0Ddpx2Y8FDMzAjLz4CM9IXZ2xHMzATM98mbwxXN4cTM5czM0ATZzkTLjZDMi1iMwUDNtAjYwkTLwQzY4ITM4IWPklGZ&pm2=6bkA07mW3XLMTsmeERjbghCZxNCPEEAOpqin8py~PAF~bgknZ8Me0vc3ufjSET4al30qELtfuswAd4cWf8_zP4PvOktuPMtkNzCbcBV561g9jMn9w_LBD2QXPInr_cp21wXwGVuXNkqwNWz8bHUa4RsbEhCNw~rUHPFUfKUPlilVMvWsjTd3tjmaSJBOj2x7MSIAI_MqlBFJvL8zZwPoBLYn4F9lKg2Nvcq2RN6ACJ1~RV9f_dlNXsya_XiNStzeurrBhTvxjNhZucv93W3cNIQeIvSfImedbwoth2Jak4~SomfbVTB8~h2snEdJ0tyrYdhds~eY_jEcFhw7dgruHI2ypPrscZx3dr8rBA--&video_id=11739597&type=pad&auth_mode=1

需要找出参数 tk2, pm2,其他的参数固定

image.png

正好发现这个接口返回的数据中有pm2参数

简化后

https://pcweb.api.mgtv.com/player/video?tk2=wMjM0ITNwIjNx0Ddpx2Y8FDMzAjLz4CM9IXZ2xHMzATM98mbwxXN4cTM5czM0ATZzkTLjZDMi1iMwUDNtAjYwkTLwQzY4ITM4IWPklGZ&video_id=11739597

现在只需要找到tk2参数就行了

image.png

ctrl + f 搜索 tk2

image.png

tk2 = btoa("did=" + s + "|pno=" + e + "|ver=0.3.0301|clit=" + l)
.replace(/\+/g, "_").replace(/\//g, "~")
.replace(/=/g, "-").split("").reverse().join("")

s = "b3fa1a11-def2-46c1-bf08-6d937a284338" 固定值

e = 1030

l = ~~(+new Date / 1e3); // 这里 ~~ 是类型转换,强行转换成 整数型

image.png

+ 转成数值型

~~ 转成整数类型

可参考 JavaScript字符串转数字:https://www.html.cn/web/javascript/13155.html

然后将拼接的字符进行base64编码

最后通过正则将指定字符进行替换,然后将字符串进行翻转

这样就找到tk2参数。

请求播放源的时候,带上VIP的Cookie即可 解析VIP视频。

更新

2021-05-15更新

参数did的算法: https://honey.mgtv.com/honey-2.0/plugin/stk.js?202003050022:formatted

208行

改装后的js代码

for (var c = "function" == typeof Buffer ? Buffer : Array, d = [], u = {}, t = 0; t < 256; t++)
d[t] = (t + 256).toString(16).substr(1),
u[d[t]] = t;

function h(e, t) {
    var n = t || 0
        , o = d;
    return o[e[n++]] + o[e[n++]] + o[e[n++]] + o[e[n++]] + "-" + o[e[n++]] + o[e[n++]] + "-" + o[e[n++]] + o[e[n++]] + "-" + o[e[n++]] + o[e[n++]] + "-" + o[e[n++]] + o[e[n++]] + o[e[n++]] + o[e[n++]] + o[e[n++]] + o[e[n++]]
}
function getRandom16() {
    let p = new Uint8Array(16);
    for(let i = 0; i < 16; i++) {
        p[i] =  Math.ceil(Math.random() * (255 + 1))
    }
    return p;
}
var o = getRandom16()
var s = getRandom16()
, f = [1 | o[0], o[1], o[2], o[3], o[4], o[5]]
, p = 16383 & (o[6] << 8 | o[7])
, w = 0
, v = 0;
function g(e, t, n) {
    var o = t && n || 0;
    "string" == typeof e && (t = "binary" === e ? new c(16) : null,
    e = null);
    var i = getRandom16();
    if (i[6] = 15 & i[6] | 64,
    i[8] = 63 & i[8] | 128,
    t)
        for (var r = 0; r < 16; r++)
            t[o + r] = i[r];
    return t || h(i)
}

let getDid = function () {
    return g(undefined, undefined, undefined)
}
let did = getDid()
console.log(did)

教程仅供学习使用

示例页面:https://lacknb.cn/vip-analysis

前端播放器示例代码:https://github.com/MrNiebit/vip-analysis


标题:芒果TV真实播放源解析【播放下载VIP视频】
作者:gitsilence
地址:http://blog.lacknb.cn/articles/2021/05/09/1620528564435.html