20
2017
09

CNTV直播M3U8真实地址获取及算法PHP版本.

<?php
if (!empty($_GET['auth'])) {
	$auth = trim($_GET['auth']);
	$data = file_get_contents(dirname(__FILE__)."/cntv000120170623.dat");
	$pos = ((time() / 86400 ^ 1234509876) + 9876512340) % 4096;
	$mstr = substr($data, 16 + $pos * 16, 16);
	$key = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, "13Abde%6@UdwerPh", $mstr, MCRYPT_MODE_ECB);
	$enstr = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, base64_decode($auth), MCRYPT_MODE_ECB));
	exit("cntv000120170623".$enstr);
}

最近CNTV的直播地址加密了,我就开源了。

http://vdn.live.cntv.cn/api2/live.do?channel=pa://cctv_p2p_hdcctv1&client=iosapp

get 请求拿到json数据得到M3U8地址

{"ack":"yes","lc":{"isp_code":"1","city_code":"SZ","provice_code":"GD","country_code":"CN","ip":"183.15.176.38"},"client_sid":"7284da8c-9dde-11e7-9e1b-00505689fab7","flv_cdn_info":{"cdn_code":"LIVE-FLV-CDN-DN","cdn_name":"3rdFLV帝联"},"flv_url":{"flv1":"","flv2":"http://studio.vtime.cntv.dnion.com:8000/live/flv/channel13?amode=1&AUTH=yxzQ4e+9Vc9xuT0/hOkhoZl4ZVqb5Tu/CNSMwpyBcPbDFa8iqke7py1I7ks3bkZU5Er9AVMo3l0YHP61HB+sEg==","flv3":"cctv?AUTH=yxzQ4e+9Vc9xuT0/hOkhoZl4ZVqb5Tu/CNSMwpyBcPbDFa8iqke7py1I7ks3bkZU5Er9AVMo3l0YHP61HB+sEg==","flv4":"http://cctv1.vtime.cntv.dnion.com:8000/live/no/14_/seg0/index.m3u8?amode=1&AUTH=yxzQ4e+9Vc9xuT0/hOkhoZl4ZVqb5Tu/CNSMwpyBcPbDFa8iqke7py1I7ks3bkZU5Er9AVMo3l0YHP61HB+sEg==","flv5":"http://cctv1.live.cntv.dnion.com/cache/14_/channel.pub?AUTH=yxzQ4e+9Vc9xuT0/hOkhoZl4ZVqb5Tu/CNSMwpyBcPbDFa8iqke7py1I7ks3bkZU5Er9AVMo3l0YHP61HB+sEg==","flv6":""},"hls_cdn_info":{"cdn_code":"LIVE-HLS-CDN-DN","cdn_name":"3rdHLS帝联"},"hls_url":{"hls1":"http://cctv1.live.cntv.dnion.com/live/cctv1hls_/index.m3u8?ptype=1&amode=1&AUTH=yxzQ4e+9Vc9xuT0/hOkhoZl4ZVqb5Tu/CNSMwpyBcPbDFa8iqke7py1I7ks3bkZU5Er9AVMo3l0YHP61HB+sEg==","hls2":"http://cctv1.live.cntv.dnion.com/live/no/13_/seg0/index.m3u8?amode=1&AUTH=yxzQ4e+9Vc9xuT0/hOkhoZl4ZVqb5Tu/CNSMwpyBcPbDFa8iqke7py1I7ks3bkZU5Er9AVMo3l0YHP61HB+sEg==","hls3":"cctv?AUTH=yxzQ4e+9Vc9xuT0/hOkhoZl4ZVqb5Tu/CNSMwpyBcPbDFa8iqke7py1I7ks3bkZU5Er9AVMo3l0YHP61HB+sEg==","hls4":"http://cctv1.vtime.cntv.dnion.com:8000/live/no/14_/seg0/index.m3u8?amode=1&AUTH=yxzQ4e+9Vc9xuT0/hOkhoZl4ZVqb5Tu/CNSMwpyBcPbDFa8iqke7py1I7ks3bkZU5Er9AVMo3l0YHP61HB+sEg==","hls5":"http://cctv1.vtime.cntv.dnion.com:8000/live/pic/channel14?AUTH=yxzQ4e+9Vc9xuT0/hOkhoZl4ZVqb5Tu/CNSMwpyBcPbDFa8iqke7py1I7ks3bkZU5Er9AVMo3l0YHP61HB+sEg==","hls6":"http://audio.live.cntv.cloudcdn.net:8000/cache/14_/seg2/index.m3u8?AUTH=yxzQ4e+9Vc9xuT0/hOkhoZl4ZVqb5Tu/CNSMwpyBcPbDFa8iqke7py1I7ks3bkZU5Er9AVMo3l0YHP61HB+sEg=="},"hds_cdn_info":{"cdn_code":"LIVE-HDS-CDN-DN","cdn_name":"3rdHDS帝联"},"hds_url":{"hds1":"http://cctv1.live.cntv.dnion.com/cache/cctv1hds.f4m?amode=1&AUTH=yxzQ4e+9Vc9xuT0/hOkhoZl4ZVqb5Tu/CNSMwpyBcPbDFa8iqke7py1I7ks3bkZU5Er9AVMo3l0YHP61HB+sEg==","hds2":"http://studio.vtime.cntv.dnion.com:8000/live/flv/channel14?amode=1&AUTH=yxzQ4e+9Vc9xuT0/hOkhoZl4ZVqb5Tu/CNSMwpyBcPbDFa8iqke7py1I7ks3bkZU5Er9AVMo3l0YHP61HB+sEg==","hds3":"cctv?AUTH=ip%3D183.15.176.38%7Est%3D1505896138%7Eexp%3D1505982538%7Eacl%3D%2F*%7Ehmac%3Dddfc500d5d06bc7322c7f76e5163c7254513e02ac8ce426112a2f947d331af5a","hds4":"","hds5":"","hds6":""},"public":"0"}

地址包含

amode=1

需要重新计算auth密钥。

计算密钥的代码在最上面。

还需要本地随机密钥文件dat.

我贴出下载地址 配置文件 http://cbox.cntv.cn/json2015/other/mobileconfig/index.json

GET的得到JSON数据 encryption_file_url 字段

http://player.cntv.cloudcdn.net/liveconfig/cntv000120170623.dat


下载到本地读取即可。


« 上一篇 下一篇 »