腾讯视频cKey算法

腾讯视频cKey算法_第1张图片

接口地址

https://vd.l.qq.com/proxyhttp

接口参数示例

{
  "buid": "vinfoad",
  "adparam": "pf=in&ad_type=LD|KB|PVL
&pf_ex=pc
&url=https://v.qq.com/x/cover/h05z5bsjxw544er.html
&refer=https://v.qq.com/
&ty=web&plugin=1.0.0
&v=3.5.42
&coverid=h05z5bsjxw544er
&vid=w00265x48dj
&pt=
&flowid=44c6ca41dd71d1a28492acf361964054_10201
&vptag=qqbsc|channel-movie:img-1
&pu=-1
&chid=0
&adaptor=2
&dtype=1
&live=0
&resp_type=json
&guid=159341612cb3a33a1d051172f63dfbad
&req_type=1
&platform=10201
&tpid=1
&rfid=3b2e7ec50081322d9848c25e550c5ce3_1521027403",
  "vinfoparam": "charge=1
&defaultfmt=auto
&otype=ojson
&guid=159341612cb3a33a1d051172f63dfbad
&flowid=44c6ca41dd71d1a28492acf361964054_10201
&platform=10201
&sdtfrom=v1010
&defnpayver=1
&appVer=3.5.42
&refer=https://v.qq.com/x/cover/h05z5bsjxw544er.html
&host=v.qq.com
&ehost=https://v.qq.com/x/cover/h05z5bsjxw544er.html
&sphttps=1
&tm=1521027592
&spwm=4
&unid=6079608ba00b11e79d19a042d48ad00a
&vid=w00265x48dj
&defn=fhd&fhdswitch=0
&show1080p=1
&isHLS=1
&dtype=3
&sphls=2
&spgzip=1
&dlver=2
&defsrc=2
&encryptVer=7.3
&cKey=7a53ae41c1642d99f96060b605ef6865
&fp2p=1"
}

cKey值算法

ha = function(a) {
    function b(a, b) {
        return ((a >> 1) + (b >> 1) << 1) + (1 & a) + (1 & b)
    }
    for (var c = [], d = 0; d < 64;) {
        c[d] = 0 | 4294967296 * Math.abs(Math.sin(++d))
    }
    var e = function(d) {
        for (var e, f, g, h, i = [], j = unescape(encodeURI(d)), k = j.length, l = [e = 1732584193, f = -271733879, ~e, ~f], m = 0; m <= k;) {
            i[m >> 2] |= (j.charCodeAt(m) || 128) << 8 * (m++%4)
        }
        for (i[d = (k + 8 >> 6) * a + 14] = 8 * k, m = 0; m < d; m += a) {
            for (k = l, h = 0; h < 64;) {
                k = [g = k[3], b(e = k[1], (g = b(b(k[0], [e & (f = k[2]) | ~e & g, g & e | ~g & f, e ^ f ^ g, f ^ (e | ~g)][k = h >> 4]), b(c[h], i[[h, 5 * h + 1, 3 * h + 5, 7 * h][k] % a + m]))) << (k = [7, 12, 17, 22, 5, 9, 14, 20, 4, 11, a, 23, 6, 10, 15, 21][4 * k + h++%4]) | g >>> 32 - k), e, f]
            }
            for (h = 4; h;) {
                l[--h] = b(l[h], k[h])
            }
        }
        for (d = ""; h < 32;) {
            d += (l[h >> 3] >> 4 * (1 ^ 7 & h++) & 15).toString(a)
        }
        return d
    };
    return e
} (16),
$xx = function(a, b, d, e, f, g) {
    if (magic = "123456", g.length < 3) {
        return "err"
    }
    if ("7." != g.substr(0, 2)) {
        return "err"
    }
    subver = g.substr(2),
    "1" == subver && (magic = "06fc1464"),
    "2" == subver && (magic = "4244ce1b"),
    "3" == subver && (magic = "77de31c5"),
    "4" == subver && (magic = "e0149fa2"),
    "5" == subver && (magic = "60394ced"),
    "6" == subver && (magic = "2da639f0"),
    "7" == subver && (magic = "c2f0cf9f");
    var f = f || parseInt( + new Date / 1000),
    e = ("" + e).charAt(0),
    h = ha(magic + b + f + "*#06#" + a);
    return h
};
ckey = function(vid, tm) {
    var g = (new Date).getDay();
    var d = "7." + (0 == g ? 7 : g);
    var i = $xx(10201, vid, "v1010", 1, tm, d);
    return i
};

请求结果示例

{"ad":"{\"adList\":{\"IsNeedTime\":\"0\",\"has_scene_info\":\"0\",\"item\":[{\"order_id\":\"1\",\"type\":\"LD\",\"display_code\":\"Empty\",\"url\":\"\",\"duration\":\"\",\"link\":\"\",\"reportUrl\":\"http://livep.l.qq.com/livemsg?o=394&adtype=LD&soid=rJ/eGzkAWuIuTARPsgBHjjedAbtP&r90=1&l=13&refluence=13&requestl=13&tagid=0&pf=in&si=286382858&ev=6.0.380.380&aver_flag=0&traffic=&ip_filter=0&ufc_filter=0&ufc_stra=0&ufc_match=0&backfunnel=401&use_axp=0&axpheader=1&use_txp=0&txpheader=1&st_id_t=0&flow_reuse=1&ping_data=dXBfdmVyc2lvbj1WNi4wLjM4MC4zODA=&vid=t0635gds69v&pf_ex=pc&live=0&aid_tpid=2&aid_tpid2=1090&aid_tpid3=10471&aid_dura=1502&aid_vid_drm=0&aid_cid_drm=0&aid_copyright=5&aid_cover=wxwaravazucarb1&aid_subtype=1048576_2_3&aid_vip_type=1\",\"shareable\":\"0\",\"image\":[{\"index\":\"0\",\"url\":\"\",\"width\":\"0\",\"height\":\"0\",\"vid\":\"\"}],\"reportUrlOther\":{\"reportitem\":[{\"url\":\"http://qq.irs01.com/irt?_iwt_UA=UA-qq-120001&jsonp=SetIDA0&_iwt_vid=wxwaravazucarb1&_iwt_muid=D7B845E7ED81919D&_iwt_reqid=rJ/eGzkAWuIuTARPsgBHjjedAbtP&_iwt_vid1=t0635gds69v\",\"reporttime\":\"0\"}]},\"reportUrlSDK\":{\"reportitem\":[]},\"clickReportUrlOther\":{\"reportitem\":[]},\"reportUrlView\":{\"reportitem\":[]}},{\"order_id\":\"1\",\"type\":\"KB\",\"display_code\":\"Empty\",\"url\":\"\",\"duration\":\"\",\"link\":\"\",\"reportUrl\":\"http://livep.l.qq.com/livemsg?o=394&adtype=KB&soid=rJ/eGzkAWuIuTARPsgBHjjedAbtP&r90=1&l=13&refluence=13&requestl=13&tagid=10093173&pf=in&si=286382858&ev=6.0.380.380&aver_flag=0&traffic=&ip_filter=0&ufc_filter=0&ufc_stra=0&ufc_match=0&backfunnel=401&use_axp=0&axpheader=1&use_txp=0&txpheader=1&st_id_t=0&flow_reuse=1&ping_data=dXBfdmVyc2lvbj1WNi4wLjM4MC4zODA=&vid=t0635gds69v&pf_ex=pc&live=0&aid_tpid=2&aid_tpid2=1090&aid_tpid3=10471&aid_dura=1502&aid_vid_drm=0&aid_cid_drm=0&aid_copyright=5&aid_cover=wxwaravazucarb1&aid_subtype=1048576_2_3&aid_vip_type=1\",\"shareable\":\"0\",\"image\":[{\"index\":\"0\",\"url\":\"\",\"width\":\"0\",\"height\":\"0\",\"vid\":\"\"}],\"reportUrlOther\":{\"reportitem\":[{\"url\":\"http://qq.irs01.com/irt?_iwt_UA=UA-qq-120001&jsonp=SetIDA0&_iwt_vid=wxwaravazucarb1&_iwt_muid=D7B845E7ED81919D&_iwt_reqid=rJ/eGzkAWuIuTARPsgBHjjedAbtP&_iwt_vid1=t0635gds69v\",\"reporttime\":\"0\"}]},\"reportUrlSDK\":{\"reportitem\":[]},\"clickReportUrlOther\":{\"reportitem\":[]},\"reportUrlView\":{\"reportitem\":[]}},{\"order_id\":\"1\",\"type\":\"PVL\",\"display_code\":\"Empty\",\"url\":\"\",\"duration\":\"\",\"link\":\"\",\"reportUrl\":\"http://livep.l.qq.com/livemsg?o=394&adtype=PVL&soid=rJ/eGzkAWuIuTARPsgBHjjedAbtP&r90=1&l=13&refluence=13&requestl=13&tagid=10061807&pf=in&si=286382858&ev=6.0.380.380&aver_flag=0&traffic=&ip_filter=0&ufc_filter=0&ufc_stra=0&ufc_match=0&backfunnel=401&use_axp=0&axpheader=1&use_txp=0&txpheader=1&st_id_t=0&flow_reuse=1&ping_data=dXBfdmVyc2lvbj1WNi4wLjM4MC4zODA=&vid=t0635gds69v&pf_ex=pc&live=0&aid_tpid=2&aid_tpid2=1090&aid_tpid3=10471&aid_dura=1502&aid_vid_drm=0&aid_cid_drm=0&aid_copyright=5&aid_cover=wxwaravazucarb1&aid_subtype=1048576_2_3&aid_vip_type=1\",\"shareable\":\"0\",\"image\":[{\"index\":\"0\",\"url\":\"\",\"width\":\"0\",\"height\":\"0\",\"vid\":\"\"}],\"reportUrlOther\":{\"reportitem\":[]},\"reportUrlSDK\":{\"reportitem\":[]},\"clickReportUrlOther\":{\"reportitem\":[]},\"reportUrlView\":{\"reportitem\":[]}}]},\"adLoc\": {\"adFlag\":0,\"add\":0,\"aid\":\"13\",\"aidInAdtype\":[{\"adid\":\"13\",\"adtype\":\"KB\"},{\"adid\":\"13\",\"adtype\":\"LD\"},{\"adid\":\"13\",\"adtype\":\"PVL\"},{\"adid\":\"13\",\"adtype\":\"VM\"}],\"breakTime\":null,\"breaks\":\"0.0\",\"duration\":1502,\"iCheckLogin\":3,\"iCheckUser\":1,\"iUserTypeReq\":-1,\"iVipInfoRsp\":1,\"isvip\":0,\"mult\":{\"imgtag\":[{\"time\":600000,\"type\":4}],\"ivb\":[{\"time\":60000,\"type\":1},{\"time\":960000,\"type\":1}]},\"oaid\":\"13\",\"rfid\":\"7361a6a7702223cb432957a600961f5a_1524743609\",\"tm\":1524743628,\"tpid\":2,\"vad\":null,\"vid\":\"t0635gds69v\",\"vid2aid\": \"0\"}}","errCode":0,"vinfo":"{\"dltype\":8,\"exem\":0,\"fl\":{\"cnt\":4,\"fi\":[{\"id\":321001,\"name\":\"sd\",\"lmt\":0,\"sb\":1,\"cname\":\"标清;(270P)\",\"br\":327,\"profile\":4,\"drm\":0,\"video\":1,\"audio\":1,\"fs\":60022572,\"sl\":0},{\"id\":321002,\"name\":\"hd\",\"lmt\":0,\"sb\":1,\"cname\":\"高清;(480P)\",\"br\":332,\"profile\":4,\"drm\":0,\"video\":1,\"audio\":1,\"fs\":120604068,\"sl\":0},{\"id\":321003,\"name\":\"shd\",\"lmt\":0,\"sb\":1,\"cname\":\"超清;(720P)\",\"br\":337,\"profile\":4,\"drm\":0,\"video\":1,\"audio\":1,\"fs\":266568020,\"sl\":0},{\"id\":321004,\"name\":\"fhd\",\"lmt\":1,\"sb\":1,\"cname\":\"蓝光;(1080P)\",\"br\":352,\"profile\":4,\"drm\":0,\"video\":1,\"audio\":1,\"fs\":560167056,\"sl\":1}]},\"fp2p\":2,\"hs\":0,\"ip\":\"27.222.159.172\",\"ls\":0,\"preview\":1502,\"s\":\"o\",\"sfl\":{\"cnt\":0},\"tstid\":6,\"tm\":1524743628,\"vl\":{\"cnt\":1,\"vi\":[{\"br\":352,\"ch\":0,\"ct\":21600,\"dm\":\"1\",\"drm\":0,\"dsb\":0,\"enc\":\"0\",\"fc\":5,\"fmd5\":\"610825e3450d16f01bd67aadcde3d14d\",\"fn\":\"t0635gds69v.321004.ts\",\"fps\":\"25\",\"fs\":560167056,\"fst\":5,\"head\":0,\"hevc\":0,\"hfs\":\"644192114\",\"iflag\":0,\"keyid\":\"t0635gds69v.321004\",\"lnk\":\"t0635gds69v\",\"logo\":0,\"mst\":8,\"pl\":null,\"share\":1,\"sig\":\"08b42f328449356c6a4cde86344acde3885fa75b\",\"st\":2,\"tail\":170,\"targetid\":\"2600610347\",\"td\":\"1501.82\",\"ti\":\"哦!我的皇帝陛下_01\",\"tie\":0,\"type\":9,\"ul\":{\"ui\":[{\"url\":\"https://apd-976d1defed1facc22e01dd8d35d30a74.v.smtcdns.com/omts.tc.qq.com/AAAGUqYMsWG-uZ5VX5Wt2r3HdQPYDvez6fIA4-fWR9Fw/pShmpcEai1YbFlGKyxPIFS3fsNtEzeORD15WsRbDyHjn3xNHEUbon9m8mv7Y7LfRXS8GKo4P3_g5sDipRVHAU8bKJ8VEghmtvwpFNgaQ5ium0mn0nfHIhBFf5Hr9Nk2SD9C1gOdUaZl5TXY1tv6CAeIcEa_Ew6Wv/t0635gds69v.321004.ts.m3u8?ver=4\",\"vt\":2806,\"dtc\":0,\"dt\":2},{\"url\":\"https://apd-9bd19a4a5e1c168ed3506ccdd50529a4.v.smtcdns.com/omts.tc.qq.com/AAAGUqYMsWG-uZ5VX5Wt2r3HdQPYDvez6fIA4-fWR9Fw/pShmpcEai1YbFlGKyxPIFS3fsNtEzeORD15WsRbDyHjn3xNHEUbon9m8mv7Y7LfRXS8GKo4P3_g5sDipRVHAU8bKJ8VEghmtvwpFNgaQ5ium0mn0nfHIhBFf5Hr9Nk2SD9C1gOdUaZl5TXY1tv6CAeIcEa_Ew6Wv/t0635gds69v.321004.ts.m3u8?ver=4\",\"vt\":2806,\"dtc\":0,\"dt\":2},{\"url\":\"https://apd-7393661ef380d89ab62bf00db3cef3d8.v.smtcdns.com/omts.tc.qq.com/AAAGUqYMsWG-uZ5VX5Wt2r3HdQPYDvez6fIA4-fWR9Fw/pShmpcEai1YbFlGKyxPIFS3fsNtEzeORD15WsRbDyHjn3xNHEUbon9m8mv7Y7LfRXS8GKo4P3_g5sDipRVHAU8bKJ8VEghmtvwpFNgaQ5ium0mn0nfHIhBFf5Hr9Nk2SD9C1gOdUaZl5TXY1tv6CAeIcEa_Ew6Wv/t0635gds69v.321004.ts.m3u8?ver=4\",\"vt\":2806,\"dtc\":0,\"dt\":2},{\"url\":\"https://ltsdl.qq.com/pShmpcEai1YbFlGKyxPIFS3fsNtEzeORD15WsRbDyHjn3xNHEUbon9m8mv7Y7LfRXS8GKo4P3_g5sDipRVHAU8bKJ8VEghmtvwpFNgaQ5ium0mn0nfHIhBFf5Hr9Nk2SD9C1gOdUaZl5TXY1tv6CAeIcEa_Ew6Wv/t0635gds69v.321004.ts.m3u8?ver=4\",\"vt\":12620,\"dtc\":0,\"dt\":2}]},\"vh\":1072,\"vid\":\"t0635gds69v\",\"videotype\":2,\"vr\":0,\"vst\":2,\"vw\":1920,\"wh\":1.7910448,\"wl\":{\"wi\":[{\"id\":19,\"x\":54,\"y\":54,\"w\":334,\"h\":107,\"a\":100,\"md5\":\"dcc9dc5c478c4100ea2817c5e6020f26\",\"url\":\"http://puui.qpic.cn/vcolumn_pic/0/logo_qing_xi_color_336_108.png/0\",\"surl\":\"https://puui.qpic.cn/vcolumn_pic/0/logo_qing_xi_color_336_108.png/0\"}]}}]}}"}

你可能感兴趣的:(腾讯视频cKey算法)