某酷视频网站-逆向分析
pc端网站接口:
https://acs.youku.com/h5/mtop.youku.play.ups.appinfo.get/1.1/?jsv=2.5.7&appKey=24679788&t=1581073695408&sign=4d9fd1e93c17ea74690b9d207f1d436a&api=mtop.youku.play.ups.appinfo.get&v=1.1&timeout=20000&YKPid=20160317PLF000211&YKLoginRequest=true&AntiFlood=true&AntiCreep=true&type=jsonp&dataType=jsonp&callback=mtopjsonp1&data=%7B%22steal_params%22%3A%22%7B%5C%22ccode%5C%22%3A%5C%220502%5C%22%2C%5C%22client_ip%5C%22%3A%5C%22192.168.1.1%5C%22%2C%5C%22utid%5C%22%3A%5C%22G1%2BGFm9l4TgCAXFK6rtolCDo%5C%22%2C%5C%22client_ts%5C%22%3A1581073695%2C%5C%22version%5C%22%3A%5C%221.10.22%5C%22%2C%5C%22ckey%5C%22%3A%5C%22122%23IyDbGJIUEEaXYEpZy4pIEJponDJE7SNEEP7ZpJRBuDPpJFQLpCGwpEM4pJEL7SwBEyGZpJLlu4Ep%2BFQLpoGUEELWn4yE7SNEEP7ZpERBuDPE%2BBQPpC76EJponDJLKMQEs%2B9G0DnTh6aSpFwVUHldPqJay9QV7xb1hJSyODcUq0nF8vUIbi14BoxWD%2BvTYFPtLMp1uObkvBpr8Cpfpdq%2ByBvmqM3bDEpanSp1uO0bDLVZ8C%2Bw%2BBiHRBfmqV12EEpadSX4ul0EDLVr8CpUJ4bEyFvmqM3bDEpxnSp1uOIEDLXZ8oL6JNEEyB6nqW32p5%2Bangp1ula2fElver47dP02Rey27N1ZcSR81PRo79nQgzsUyadCL0dgstG8hy1gg5%2BHPbiPWOmiY4PMeBEQkiCm9HAtXDN7rJc9xJHJBckVbQjuOXmQkguPD4m0ARKqyVtZXn3AL%2B6Gb1Mt3DV5bt5G1n6u1zid4S5Tl52FMSdPIu%2FmNuujWw%2Bg3uJpV0f8aZZW2HoB3UwOuhulS2mv67PFJnmm7VV8ixX0WRTUcdfTxQRw5lftXc0fr5ICo%2BTmvRUWG1PuT2BeCX2IKMGa2KCxADNLkT%2FqzroQpEtOWALdZR6Saz8%2BKGB0FY%2B99kqxnEf3HRHoAdC6cEmFYUdjDwPewGnYQ%2BYWQobcmfnlv5tKttIFAsGC9jEtAvp9D0VgC83yJRk3eXhH%2FDD1weTBe%2FwK%2B8u%2BDTA35GAxHiL11QhXGTxNp5IHcKBWZ%2FA8Dx6TbpZZ1wrM67mz%2FiZkeYQ%2B5HCgbwayswZFtTzMvf0o91cXeyZEUVbjwuMUa1N94%2FEacujT12VoKBg5qjWjW5ccysMEDywGE%2BPSIxSlpNb8xZBs%2FNBDCEyk%2FHAfVVdMLWlJGd%2FfGYcID%2F6Jafauzbdy2TxK3BnhU%2FklEM0%3D%5C%22%7D%22%2C%22biz_params%22%3A%22%7B%5C%22vid%5C%22%3A%5C%22XNDUxMDczMTk4NA%3D%3D%5C%22%2C%5C%22play_ability%5C%22%3A5376%2C%5C%22current_showid%5C%22%3A%5C%22442625%5C%22%2C%5C%22preferClarity%5C%22%3A11%2C%5C%22master_m3u8%5C%22%3A1%2C%5C%22media_type%5C%22%3A%5C%22standard%2Csubtitle%5C%22%2C%5C%22app_ver%5C%22%3A%5C%221.10.22%5C%22%7D%22%2C%22ad_params%22%3A%22%7B%5C%22vs%5C%22%3A%5C%221.0%5C%22%2C%5C%22pver%5C%22%3A%5C%221.10.22%5C%22%2C%5C%22sver%5C%22%3A%5C%222.0%5C%22%2C%5C%22site%5C%22%3A1%2C%5C%22aw%5C%22%3A%5C%22w%5C%22%2C%5C%22fu%5C%22%3A0%2C%5C%22d%5C%22%3A%5C%220%5C%22%2C%5C%22bt%5C%22%3A%5C%22pc%5C%22%2C%5C%22os%5C%22%3A%5C%22win%5C%22%2C%5C%22osv%5C%22%3A%5C%2210%5C%22%2C%5C%22dq%5C%22%3A%5C%22auto%5C%22%2C%5C%22atm%5C%22%3A%5C%22%5C%22%2C%5C%22partnerid%5C%22%3A%5C%22null%5C%22%2C%5C%22wintype%5C%22%3A%5C%22interior%5C%22%2C%5C%22isvert%5C%22%3A0%2C%5C%22vip%5C%22%3A0%2C%5C%22emb%5C%22%3A%5C%22AjExMjc2ODI5OTYCdi55b3VrdS5jb20CL3Zfc2hvdy9pZF9YTkRVeE1EY3pNVGs0TkE9PS5odG1s%5C%22%2C%5C%22p%5C%22%3A1%2C%5C%22rst%5C%22%3A%5C%22mp4%5C%22%2C%5C%22needbf%5C%22%3A2%7D%22%7D
pc端参数太多,不好弄,逆向的时候还出现了令牌过期,直接放弃pc端,转战m端
逆向目标:https://m.youku.com/video/id_XNDUxMDczMTk4NA==.html
模拟手机UA访问
抓包到接口:
https://ups.youku.com/ups/get.json
请求方式:GET,请求由 h5phoneplayer.min.js
发出
请求参数:
Name | Value | 分析 |
---|---|---|
vid | XNDUxMDczMTk4NA== | 视频id,可从视频链接获取 |
ccode | 0501 | 默认值 |
client_ip | 0.0.0.0 | 默认值 |
app_ver | 1.0.0 | 默认值 |
client_ts | 1581050008 | 当前时间的十位时间戳 |
fu | 0 | 默认值 |
vr | 0 | 默认值 |
rst | mp4 | 默认值 |
dq | mp4 | 默认值 |
os | android | 默认值 |
bt | phone | 默认值 |
bd | 空值,不理会 | |
tict | 0 | 默认值 |
d | 0 | 默认值 |
needbf | 1 | 默认值 |
site | 1 | 默认值 |
aw | w | 默认值 |
vs | 1.0 | 默认值 |
pver | 1 | 默认值 |
wintype | xplayer_m3u8 | 默认值 |
play_ability | 1024 | 默认值 |
utid | G1%2BGFm9l4TgCAXFK6rtolCDo | 需要找到算法或者找到提供该值的接口 |
ckey | 122%23lEK%2BZDohEEJI84pZy4pIE | 需要找到算法或者找到提供该值的接口 |
头部信息:
'origin:https://m.youku.com',
'user-agent:Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Mobile Safari/537.36',
'accept:*/*',
'referer:https://m.youku.com/video/id_XNDUxMDczMTk4NA==.html?spm=a2hcb.12528442.m_4424_c_11054_1.d_4&s=eedda6310d7c48e6bf34&scm=20140719.rcmd.4424.show_eedda6310d7c48e6bf34&source=https%3A%2F%2Fmovie.youku.com%2F%3Fspm%3Da2hcb.12675304.m_6913.5~5~5~5~5!2~5~5~A',
'accept-language:zh-CN,zh;q=0.9',
Cookie:
__ysuid=1578047754808EM4;
UM_distinctid=16feca959a43d6-04b2de1c6c7837-3c604504-1fa400-16feca959a5422;
cna=G1+GFm9l4TgCAXFK6rtolCDo;
l=Ah4ep8QRJgIqF/us4ZJkYcDf7r5g3-JZ;
P_pck_rm=QHps1SF9b4fcb3c407299dZBsA8IKcgNjme%2FYxy667HQbc2NQzw3YEZbvcL63XJlwZmj9fn4hSyCr6RpyHOrahLWkkgyeXFJFPj2lmaLZZK0rz54RSVZSF3qnCQeYGU9q9%2BOtIDC7YEKnKcMW6EmZcu8CM2%2F3sXZD3Mo0g%3D%3D_V2;
P_gck=NA%7CMdBxRFQ62igOpbOtGQYjDA%3D%3D%7CNA%7C1580223702318;
juid=01dvmao9f32os3;
__aysid=1580814684357WYs;
youku_history_word=[%22%E7%89%B9%E8%AD%A6%E9%98%9F%22%2C%22%E5%BE%B7%E4%BA%91%E7%A4%BE%E5%B7%B1%E4%BA%A5%E5%B9%B4%E5%B0%81%E7%AE%B1%E5%BA%86%E5%85%B82020%22];
ysestep=1;
yseidcount=1;
ystep=1;
__guid=137678068.956797043122212000.1580818444411.8516;
__ayft=1581049940030;
__ayscnt=1;
_m_h5_tk=0d9a820717bd56fc371cc9567f02c256_1581054274354;
_m_h5_tk_enc=a5f7a7296adc5fa5cfeb5a8387b3a696;
P_ck_ctl=029D4F4CAE9E48174D2663EB43F6E640;
_m_h5_c=e07bfa6a03e4e8116a94c24d9ba25723_1581058241213%3B0211ac4702e3c22f75a3348201387322;
__arycid=dc-3-00;
__arcms=dc-3-00;
modalObj={"UUID":"1"};
__ayvstp=3;
__aysvstp=110;
isg=BK2teET_jzAzeGvQExOVpp6MvEknCuHcqJ2rEO-y6cSzZs0Yt1rxrPsnVjyAYvmU;
__arpvid=1581050007598KFfvr6-1581050007654;
__aypstp=6;
__ayspstp=93
Curl命令行:
curl -H 'Host: ups.youku.com' -H 'Cookie: __ysuid=1578047754808EM4; UM_distinctid=16feca959a43d6-04b2de1c6c7837-3c604504-1fa400-16feca959a5422; cna=G1+GFm9l4TgCAXFK6rtolCDo; l=Ah4ep8QRJgIqF/us4ZJkYcDf7r5g3-JZ; P_pck_rm=QHps1SF9b4fcb3c407299dZBsA8IKcgNjme%2FYxy667HQbc2NQzw3YEZbvcL63XJlwZmj9fn4hSyCr6RpyHOrahLWkkgyeXFJFPj2lmaLZZK0rz54RSVZSF3qnCQeYGU9q9%2BOtIDC7YEKnKcMW6EmZcu8CM2%2F3sXZD3Mo0g%3D%3D_V2; P_gck=NA%7CMdBxRFQ62igOpbOtGQYjDA%3D%3D%7CNA%7C1580223702318; juid=01dvmao9f32os3; __aysid=1580814684357WYs; youku_history_word=[%22%E7%89%B9%E8%AD%A6%E9%98%9F%22%2C%22%E5%BE%B7%E4%BA%91%E7%A4%BE%E5%B7%B1%E4%BA%A5%E5%B9%B4%E5%B0%81%E7%AE%B1%E5%BA%86%E5%85%B82020%22]; ysestep=1; yseidcount=1; ystep=1; __guid=137678068.956797043122212000.1580818444411.8516; __ayft=1581049940030; __ayscnt=1; _m_h5_tk=0d9a820717bd56fc371cc9567f02c256_1581054274354; _m_h5_tk_enc=a5f7a7296adc5fa5cfeb5a8387b3a696; P_ck_ctl=029D4F4CAE9E48174D2663EB43F6E640; _m_h5_c=e07bfa6a03e4e8116a94c24d9ba25723_1581058241213%3B0211ac4702e3c22f75a3348201387322; __arycid=dc-3-00; __arcms=dc-3-00; modalObj={"UUID":"1"}; __ayvstp=3; __aysvstp=110; isg=BK2teET_jzAzeGvQExOVpp6MvEknCuHcqJ2rEO-y6cSzZs0Yt1rxrPsnVjyAYvmU; __arpvid=1581050007598KFfvr6-1581050007654; __aypstp=6; __ayspstp=93' -H 'origin: https://m.youku.com' -H 'user-agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Mobile Safari/537.36' -H 'accept: */*' -H 'referer: https://m.youku.com/video/id_XNDUxMDczMTk4NA==.html?spm=a2hcb.12528442.m_4424_c_11054_1.d_4&s=eedda6310d7c48e6bf34&scm=20140719.rcmd.4424.show_eedda6310d7c48e6bf34&source=https%3A%2F%2Fmovie.youku.com%2F%3Fspm%3Da2hcb.12675304.m_6913.5~5~5~5~5!2~5~5~A' -H 'accept-language: zh-CN,zh;q=0.9' --compressed 'https://ups.youku.com/ups/get.json?vid=XNDUxMDczMTk4NA==&ccode=0501&client_ip=0.0.0.0&app_ver=1.0.0&client_ts=1581050008&fu=0&vr=0&rst=mp4&dq=mp4&os=android&bt=phone&bd=&tict=0&d=0&needbf=1&site=1&aw=w&vs=1.0&pver=1&wintype=xplayer_m3u8&play_ability=1024&utid=G1%2BGFm9l4TgCAXFK6rtolCDo&ckey=122%23lEK%2BZDohEEJI84pZy4pIEJponDJE7SNEEP7ZpJRBuDPpJFQLpCGwpEW4pJEL7SwBEyGZpJLlu4Ep%2BFQLpoGUEELWn4yE7SNEEP7ZpERBuDPE%2BBQPpC76EJponDJyKMQEV4YCXDnTh6bsGGb%2FMDS4VK%2Buuv%2FGvbMpV3DXNSp3m24MbeUBjyRulWlKHgp1uOjTDLVr8E16%2B4EEyFfDqM3bDEpxngR4ul5EDtGrt4AiJDbEfC3mqM3WE8pangL4ul0EDLVr8CpU%2B4EEyFfDqMfbDEpxnSp4uOIEELXZ8oL6ywTEyF3F7S32DEpadS%2B1ul58AK%2BPABRiKJVWUSbIGRk27bAbUGrah%2FJP%2BK1Pzqqi%2FvAPZER0906N%2BoiP4ew1nOk1BSigLZcWdfqdRxhns4ef8pkZT3IxefoUhywfdtBrx6howTEsDrvUa7xC4zuelg2vB%2FXAzuXvVD4vp91%2BIYo2ZCmHyK5izem7Zc1wrtsIsUWevTVdsESScdjTjro5J4iisqBJITIuW4%2F33kzUlIRY6ir%2BcIOCfvTXpzNrLgyHYf%2Bznfn2wa5xamhiVcutYiwwR5plp%2B4PzykafU8%2B1Hdw0DWfBLaWKG1d5S9VQKiVRt9jvs28AWepC3YokZkA4sYdAWrbAm04GRqJlUlU24lXX9oNwHiR3CfFifkbJC6kH1hd'
使用工具,将Curl命令行转换为php代码和清洗无用的cookie数据
Curl转php生成成功,成功调用视频解析接口
把cookie改为空值,获取当cookie为空时的提示,用于Cookie数据清洗的判断
获得判断字符"开通VIP会员后观看完整"
开始清洗Cookie
清洗结果:保留 P_pck_rm
参数就ok,其他参数都是多余的
清洗完Cookie再测试访问一次接口:
调用成功!!
逆向思路:
- 获得
utid
和ckey
- 解析视频的请求是由
h5phoneplayer.min.js
发出的,utid
和ckey
应该可在js文件内的获得
1.获取utid
js文件内搜索接口关键字 get.json
只有一次匹配,所以只有这个 UPS_API_URL
变量和接口有关,顺藤摸瓜,接着搜索 UPS_API_URL
有两次匹配,所以带上刚刚那个变量,就只有这个了
可以看到utid是url编码后的 this.utid
,接着顺藤摸瓜,搜索 this.utid
这个 this.utid
,一般在当前位置的上面,所以用反向查找比较快
找到一行关键代码
this.param.utid ? this.utid = this.param.utid: this.utid = o.default.getCna(),
从代码可以看出来和这个 this.utid
有关的有 this.param.utid
和 o.default.getCna()
搜索了一下 this.param.utid
没有任何价值....
然后找到这个 getCna()
函数
getCna: function() {
return this.cna ? this.cna: this.cookie.getCookie("cna") ? (this.cna = this.cookie.getCookie("cna"), this.cna) : window.goldlog && window.goldlog.Etag ? (this.cna = window.goldlog.Etag, this.cna) : (this.loadfile("https://log.mmstat.com/eg.js", "js"), null)
},
代码太乱,太长,只找根据部分
这个里面的js文件犹如腰间盘一般突出,直接打开访问看一下
咦惹,这个 G1+GFm9l4TgCAXFK6rtolCDo
不就是我们要找的utid吗?
好了utid现在已经搞定了,哈哈哈,如此简单粗暴
2.获取ckey
老套路,js文件内搜索接口关键字 get.json
,然后顺藤摸瓜
原来ckey也是经过url编码的
顺着this.ckey接着摸,老套路,反向查找,往上摸
摸到一行关键代码:
this.ckey = o.default.getUA() ? o.default.getUA():this.ckey,
还是熟悉的三元表达式,看起来最突出最有用的就是 o.default.getUA()
,先不分析代码,直接找一下这个函数看一下
getUA: function() {
var t = window[window.UA_Opt.LogVal];
return window.UA_Opt.Token = (new Date).getTime() + ":" + Math.random(),
window.UA_Opt.reload && window.UA_Opt.reload(),
t
},
现在按理说要找这一堆乱七八糟的什么window叽里呱啦
但是搜索之后还是没有头绪,js代码不熟悉,看不懂...
这个函数名叫getUA所以搜索一下UA看一下,不匹配大小写
然后找到这么个东西
h = Object.freeze({
UPS_API_URL: "https://ups.youku.com/ups/get.json",
OPEN_API_URL: "https://api.youku.com/players/custom.json",
OPEN_API_URL_TOKEN: "https://api.youku.com/players/consume.json",
defaultUA: "DIl58SLFxFNndSV1GFNnMQVYkx1PP5tKe1siZu/86PR1u/Wh1Ptd+WOZsHHWxysSfAOhNJpdVWsdVJNsfJ8Sxd8WKVvNfAS8aS8fAOzYARzPyPc3JvtnPHjTdKfESTdnuTW6ZPvk2pNDh4uFzotgdMEFkzQ5wZVXl2Pf1/Y6hLK0OnCNxBj3+nb0v72gZ6b0td+WOZsHHWxysSo/0y9D2K42SaB8Y/+aD2K42SaB8Y/+ahU+WOZsHcrxysooUeND"
}),
咦惹,这东西好特么熟悉,这个不是摸瓜摸到的地方吗,刚才居然没留意到
这里有个常量 defaultUA
顾名思义就是默认的UA,换句话说就是默认的Ckey
用这个 defaultUA
和刚刚获得的utid调用一下接口吧
$cookie = 'P_pck_rm=QHps1SF9b4fcb3c407299dZBsA8IKcgNjme%2FYxy667HQbc2NQzw3YEZbvcL63XJlwZmj9fn4hSyCr6RpyHOrahLWkkgyeXFJFPj2lmaLZZK0rz54RSVZSF3qnCQeYGU9q9%2BOtIDC7YEKnKcMW6EmZcu8CM2%2F3sXZD3Mo0g%3D%3D_V2;';
$vid = "XNDUxMDczMTk4NA==";
$utid_url = 'https://log.mmstat.com/eg.js';
$utid_hs = hs($utid_url,$header,$cookie);
$utid = urlencode(sj($utid_hs,'goldlog.Etag="','"'));
$ckey = 'DIl58SLFxFNndSV1GFNnMQVYkx1PP5tKe1siZu/86PR1u/Wh1Ptd+WOZsHHWxysSfAOhNJpdVWsdVJNsfJ8Sxd8WKVvNfAS8aS8fAOzYARzPyPc3JvtnPHjTdKfESTdnuTW6ZPvk2pNDh4uFzotgdMEFkzQ5wZVXl2Pf1/Y6hLK0OnCNxBj3+nb0v72gZ6b0td+WOZsHHWxysSo/0y9D2K42SaB8Y/+aD2K42SaB8Y/+ahU+WOZsHcrxysooUeND';
$ckey = urlencode($ckey);
$url = 'https://ups.youku.com/ups/get.json?vid=' . $vid . '&ccode=0501&client_ip=0.0.0.0&app_ver=1.0.0&client_ts=' . '&fu=0&vr=0&rst=mp4&dq=mp4&os=android&bt=phone&bd=&tict=0&d=0&needbf=1&site=1&aw=w&vs=1.0&pver=1&wintype=xplayer_m3u8&play_ability=1024&utid=' . $utid . '&ckey=' . $ckey;
$callback_hs = hs($url,$header,$cookie);
$callback_hs_a = $callback_hs;
echo $callback_hs_a;
调用成功!!!
不知道utid和ckey可不可以使用固定值,但是为了避免utid和ckey会过期,就直接用默认的ckey和从js文件里面获取出来的utid
逆向思路:
1.查看正在播放的vip视频的文件名,根据文件名在返回的json里面找到对应的位置,用于截取视频链接
视频链接:
https://ip3811021687.mobgslb.tbcache.com/6773EC40F183D719216592B8A/03000811005E1EEA9F5A59205CF07D0BD01DD2-F684-4758-A539-F2920135CAD2.mp4?ccode=0501&duration=389&expire=18000&psid=17e2b8c576141d99500fc1d0913d8fec&ups_client_netip=77874005&ups_ts=1581071612&ups_userid=1827131445&utid=G1%2BGFm9l4TgCAXFK6rtolCDo&vid=XNDUxMDczMTk4NA&vkey=A4a9bd4e77d50bc9a8a90873de9ab3d8d&s=eedda6310d7c48e6bf34&iv=1&bc=2&dre=u17&si=45&sp=400&ali_redirect_domain=vali-dns.cp31.ott.cibntv.net&ali_redirect_ex_ftag=101484825914dc696374a9aa54f4a344df1544fd023bc991&ali_redirect_ex_tmining_ts=1581071613&ali_redirect_ex_tmining_expire=3600&ali_redirect_ex_hot=100
居然是mp4文件,不是m3u8文件,而且也没有m3u8文件的出现,文件也只有33.14M但视频是可以看到时完整版的,所以这个应该是整个视频的一个分段,而且用的不是m3u8来整合分段视频的
文件名:03000811005E1EEA9F5A59205CF07D0BD01DD2-F684-4758-A539-F2920135CAD2.mp4
在返回的json里面搜索一下这个文件名
找到位置 ['data']['stream'][1]['segs'][0]['cdn_url']
其中 ['data']['stream']
里面是各清晰度的视频链接,里面的 ['segs']
装着该清晰度的视频分段视频链接
很奇怪为什么猫抓抓到的视频是mp4不是m3u8
而且里面明明有m3u8的链接但是不用呢?手动选择下载一下看看
第一个文件就是m端里面的json里面的m3u8文件,第二个文件是pc网页端json里面的m3u8,pc端的m3u8是正常的可以正常播放,m端的是来搞笑的,只能用json列表里面的mp4分段视频链接了
没想到某酷居然是用这种方式输出分段视频列表的,66666
['data']['stream'][2]['stream_type']
的值表示的是清晰度的名称,根据多次抓包用视频文件名和json参数对比,得出json里的清晰度名称与播放器上面显示出来被我们看到的清晰度名称如下:
JSON | 清晰度 |
---|---|
mp4hd3v2 | 蓝光 |
hls4hd3_sdr | HDR(我们调用的是m端的接口,好像没有这个HDR的清晰度) |
mp4hd2v2 | 超清 |
mp4hd | 高清 |
HDR清晰度的视频不是以json列表输出的,~是 ['data']['stream'][1]['segs'][0]['path']
里面的m3u8文件~,是 ['data']['stream'][2]['m3u8_url']
里面的m3u8文件,不是上面的path里面的m3u8文件,对照猫抓里面抓到的视频链接找到的
~但是这个m3u8既不能下载,又不能访问,所有播放器貌似都播放不了,不知道是不是里面oss搞的鬼~
参考网上解析某酷视频的php源码得到以下清晰度对应的名称:
JSON | Type | 清晰度 |
---|---|---|
mp5hd4 | mp5 | 4K |
mp4sd | mp4 | 普清 |
mp4hd2 | flv | FLV超高清 |
mp4hd3 | flv | FLV原画 |
3gphd | mp4 | 3GP高清 |
flvhd | flv | FLV高清 |
mp4hd2v2 | mp4 | 超清 |
mp4hd | mp4 | 高清 |
mp4hd3v2 | mp4 | 原画(蓝光) |
mp5sd | mp4 | MP5高清 |
mp5hd2 | mp4 | MP5超高清 |
mp5hd3 | mp4 | MP5原画 |
mp5hd | mp4 | MP5超清 |
逆向思路:
1.下载视频链接已经能获取到了,但是是分段的,有没有m3u8把这些分段视频统一起来
2.我们要获取分段视频链接,自己生成一个m3u8
3.首先要了解m3u8的语法
刚好下载了一个pc网页端的m3u8,打开看一下
主要有这几个参数:
Name | Value | 分析 |
---|---|---|
#EXTM3U | 应该是文件的声明,看起来就不重要,不管它 | |
#EXT-X-VERSION | 3 | 应该指的是m3u8版本,看起来就不重要,不管它 |
#EXT-X-TARGETDURATION | 10 | 每片最大时长,单位s, #EXTINF应该小于这个值 |
#EXT-X-MEDIA-SEQUENCE | 0 | 播放列表的第一个音频的序号,如64.m3u8中,有3个音频,序号分别是12591742,12591743,12591744。如果不设置,默认为第一个音频链接序号为0。(可选) |
#EXTINF | 10.000000 | 该片段的播放时间长度,单位s |
#EXT-X-ENDLIST | 有这个参数,说明是点播,是完整的一段音频或者视频;没有这个参数,说明是直播,需要不断从二级索引中去获取下一片段的链接 |
好了,搞定了,我们要获取的就是每片最大时长和片段的播放时间长度就ok了
再看一下json返回数据
size指的应该是整个片段文件的大小,用不上,不管
total_milliseconds_video和total_milliseconds_audio顾名思义指的分别是整个片段视频的时长和音频时长,单位是毫秒,这个对我们有用,但是我们要的是秒,从逆向芒果tv里面学到的,把这个毫秒除以1e3(1000)然后取整就ok
而每片最大时长这个在遍历分段视频的时候对比就可以得到
搞定,现在逆向已经基本完成了就差完善一下功能了
此处评论已关闭