lihu5841314 发表于 2021-8-7 19:39

m3u8 获取 (js学习)

importrequests,datetime,os
import execjs

url = "https://z1.m1907.cn/api/v/"

y = datetime.datetime.now()
p = int(y.day) +9 + 9 ^ 10
slig= y.weekday()+ 11397
with open(r'F:\pycharm社区版\学习目录\学习02\mov\Z.JS','r') asf:
    js = f.read()
node = execjs.compile(js)
z = node.call('get_z')


def   m3u8_dowm(url):
    headers = {
      "authority": "z1.m1907.cn",
      "method": "GET",
      "path": f"/api/v/?z={z}&jx={index_url}",
      "scheme": "https",
      "accept": "*/*",
      "accept-encoding": "gzip, deflate, br",
      "accept-language": "zh-CN,zh;q=0.9",
      "cache-control": "no-cache",
      # "cookie": "aliyungf_tc=AQAAAFvyfRtP/AIATUWYDheCsQtZUPVB; a=4c38074c82dc4643a2708929c8883d05; UM_distinctid=17b1b2e9efd9dc-02bd59ab8d44ce-4373266-1fa400-17b1b2e9efe90c; CNZZDATA1274263051=1843645965-1628247426-%7C1628247426; Hm_lvt_386584f4a5a7eb7020f177ea913b7ef9=1627728610,1627730601,1627736443,1628248645; play_history={%22%E5%A4%AA%E4%B9%99%E4%BB%99%E9%AD%94%E5%BD%95%E4%B9%8B%E7%81%B5%E9%A3%9E%E7%BA%AA%20%E7%AC%AC%E5%9B%9B%E5%AD%A3%22:{%22ep%22:13%2C%22time%22:1627728677689%2C%22t%22:170.975558}%2C%22%E5%A4%AA%E4%B9%99%E4%BB%99%E9%AD%94%E5%BD%95%E4%B9%8B%E7%81%B5%E9%A3%9E%E7%BA%AA%20%E7%AC%AC%E4%B8%89%E5%AD%A3%22:{%22ep%22:11%2C%22time%22:1627736481050%2C%22t%22:0.143332}%2C%22%E9%99%8C%E7%94%9F%E7%9A%84%E6%81%8B%E4%BA%BA%22:{%22ep%22:26%2C%22time%22:1628248790359%2C%22t%22:434.921449}}; Hm_lpvt_386584f4a5a7eb7020f177ea913b7ef9=1628248793; igh={%22t%22:1628248842851%2C%22h%22:[%22vod.bun%22]}",
      "pragma": "no-cache",
      "referer": f"https://z1.m1907.cn/?jx={index_url}",
      "sec-ch-ua": 'Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"',
      "sec-ch-ua-mobile": "?0",
      "sec-fetch-dest": "empty",
      "sec-fetch-mode": "cors",
      "sec-fetch-site": "same-origin",
      "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.106 Safari/537.36",
    }

    params = {
      "z": z,
      "jx": index_url,
      "s1ig": slig,
      "g": "vod.bun",
    }
    if not os.path.exists('movies_m3u8'):
      os.makedirs('movies_m3u8')
    resp = requests.get(url=url,headers=headers,params=params,timeout =20).json()
    mov_name = resp['data']['name']
    num = len(resp['data']['source']['eps'])
    if not os.path.exists(mov_name):
      os.makedirs(f'movies_m3u8/{mov_name}')
    fori inrange(num):
      mov_name_child = mov_name + resp['data']['source']['eps']['name']
      mov_name_child_url = resp['data']['source']['eps']['url']
      print(mov_name_child)
      print(mov_name_child_url)
      m3u8_resp = requests.get(mov_name_child_url,headers=headers).text
      path = 'movies_m3u8/' +mov_name + "/"+ mov_name_child+'.m3u8'
      with open(path,"w",encoding='utf-8')asf:
             f.write(m3u8_resp)


if __name__ == '__main__':
    index_url = input("请输入需要下载的电影或视频url地址:")
    m3u8_dowm(url)#============下面是js解密代码
"use strict";
var t = undefined;
var n = undefined;
function i(e, t) {
var n = (65535 & e) + (65535 & t);
return (e >> 16) + (t >> 16) + (n >> 16) << 16 | 65535 & n
}
function l(e, t, n, r, o, l) {
return i((a = i(i(t, e), i(r, l))) << (u = o) | a >>> 32 - u, n);
var a, u
}
function a(e, t, n, r, o, i, a) {
return l(t & n | ~t & r, e, t, o, i, a)
}
function u(e, t, n, r, o, i, a) {
return l(t & r | n & ~r, e, t, o, i, a)
}
function c(e, t, n, r, o, i, a) {
return l(t ^ n ^ r, e, t, o, i, a)
}
function s(e, t, n, r, o, i, a) {
return l(n ^ (t | ~r), e, t, o, i, a)
}
function f(e, t) {
var n, r, o, l, f;
e |= 128 << t % 32,
e = t;
var d = 1732584193,
p = -271733879,
m = -1732584194,
h = 271733878;
for (n = 0; n < e.length; n += 16) r = d,
o = p,
l = m,
f = h,
d = a(d, p, m, h, e, 7, -680876936),
h = a(h, d, p, m, e, 12, -389564586),
m = a(m, h, d, p, e, 17, 606105819),
p = a(p, m, h, d, e, 22, -1044525330),
d = a(d, p, m, h, e, 7, -176418897),
h = a(h, d, p, m, e, 12, 1200080426),
m = a(m, h, d, p, e, 17, -1473231341),
p = a(p, m, h, d, e, 22, -45705983),
d = a(d, p, m, h, e, 7, 1770035416),
h = a(h, d, p, m, e, 12, -1958414417),
m = a(m, h, d, p, e, 17, -42063),
p = a(p, m, h, d, e, 22, -1990404162),
d = a(d, p, m, h, e, 7, 1804603682),
h = a(h, d, p, m, e, 12, -40341101),
m = a(m, h, d, p, e, 17, -1502002290),
d = u(d, p = a(p, m, h, d, e, 22, 1236535329), m, h, e, 5, -165796510),
h = u(h, d, p, m, e, 9, -1069501632),
m = u(m, h, d, p, e, 14, 643717713),
p = u(p, m, h, d, e, 20, -373897302),
d = u(d, p, m, h, e, 5, -701558691),
h = u(h, d, p, m, e, 9, 38016083),
m = u(m, h, d, p, e, 14, -660478335),
p = u(p, m, h, d, e, 20, -405537848),
d = u(d, p, m, h, e, 5, 568446438),
h = u(h, d, p, m, e, 9, -1019803690),
m = u(m, h, d, p, e, 14, -187363961),
p = u(p, m, h, d, e, 20, 1163531501),
d = u(d, p, m, h, e, 5, -1444681467),
h = u(h, d, p, m, e, 9, -51403784),
m = u(m, h, d, p, e, 14, 1735328473),
d = c(d, p = u(p, m, h, d, e, 20, -1926607734), m, h, e, 4, -378558),
h = c(h, d, p, m, e, 11, -2022574463),
m = c(m, h, d, p, e, 16, 1839030562),
p = c(p, m, h, d, e, 23, -35309556),
d = c(d, p, m, h, e, 4, -1530992060),
h = c(h, d, p, m, e, 11, 1272893353),
m = c(m, h, d, p, e, 16, -155497632),
p = c(p, m, h, d, e, 23, -1094730640),
d = c(d, p, m, h, e, 4, 681279174),
h = c(h, d, p, m, e, 11, -358537222),
m = c(m, h, d, p, e, 16, -722521979),
p = c(p, m, h, d, e, 23, 76029189),
d = c(d, p, m, h, e, 4, -640364487),
h = c(h, d, p, m, e, 11, -421815835),
m = c(m, h, d, p, e, 16, 530742520),
d = s(d, p = c(p, m, h, d, e, 23, -995338651), m, h, e, 6, -198630844),
h = s(h, d, p, m, e, 10, 1126891415),
m = s(m, h, d, p, e, 15, -1416354905),
p = s(p, m, h, d, e, 21, -57434055),
d = s(d, p, m, h, e, 6, 1700485571),
h = s(h, d, p, m, e, 10, -1894986606),
m = s(m, h, d, p, e, 15, -1051523),
p = s(p, m, h, d, e, 21, -2054922799),
d = s(d, p, m, h, e, 6, 1873313359),
h = s(h, d, p, m, e, 10, -30611744),
m = s(m, h, d, p, e, 15, -1560198380),
p = s(p, m, h, d, e, 21, 1309151649),
d = s(d, p, m, h, e, 6, -145523070),
h = s(h, d, p, m, e, 10, -1120210379),
m = s(m, h, d, p, e, 15, 718787259),
p = s(p, m, h, d, e, 21, -343485551),
d = i(d, r),
p = i(p, o),
m = i(m, l),
h = i(h, f);
return
}
function d(e) {
var t, n = "",
r = 32 * e.length;
for (t = 0; t < r; t += 8) n += String.fromCharCode(e >>> t % 32 & 255);
return n
}
function p(e) {
var t, n = [];
for (n[(e.length >> 2) - 1] = void 0, t = 0; t < n.length; t += 1) n = 0;
var r = 8 * e.length;
for (t = 0; t < r; t += 8) n |= (255 & e.charCodeAt(t / 8)) << t % 32;
return n
}
function m(e) {
var t, n, r = "";
for (n = 0; n < e.length; n += 1) t = e.charCodeAt(n),
r += "0123456789abcdef".charAt(t >>> 4 & 15) + "0123456789abcdef".charAt(15 & t);
return r
}
function h(e) {
return unescape(encodeURIComponent(e))
}
function v(e) {
return function(e) {
    return d(f(p(e), 8 * e.length))
} (h(e))
}
function y(e, t) {
return function(e, t) {
    var n, r, o = p(e),
    i = [],
    l = [];
    for (i = l = void 0, o.length > 16 && (o = f(o, 8 * e.length)), n = 0; n < 16; n += 1) i = 909522486 ^ o,
    l = 1549556828 ^ o;
    return r = f(i.concat(p(t)), 512 + 8 * t.length),
    d(f(l.concat(r), 640))
} (h(e), h(t))
}
function Et(e, t, n) {
return t ? n ? y(t, e) : m(y(t, e)) : n ? v(e) : m(v(e))
}

function get_z() {
var d = new Date().getTime();
var m = new Date(d);
var slig = m.getDate() + 9 + 9 ^ 10;
var p = String(slig);
p = Et(p).substring(0, 10);
p = Et(p);
return p

李现在哪 发表于 2021-8-7 20:11

有学习到

涛之雨 发表于 2021-8-7 20:23

试试直接分析js找到算法呢?
提醒一下,下面那个js,一个是md5摘要,一个是base64编码

taikongmao 发表于 2021-8-7 20:26

收藏 楼主这个可以用在油猴吧?

爱吃鱼的有点帅 发表于 2021-8-7 20:26

努力学习,天天向上

细水流长 发表于 2021-8-7 20:40

chengmiao 发表于 2021-8-7 20:43

wwwwwwwwwwwwwwwwww

Stap 发表于 2021-8-7 22:31

说实话,基础不够,没有看懂

lihu5841314 发表于 2021-8-7 23:01

涛之雨 发表于 2021-8-7 20:23
试试直接分析js找到算法呢?
提醒一下,下面那个js,一个是md5摘要,一个是base64编码

小白一个能扣出来就不错了

lin4578 发表于 2021-8-7 23:25

努力学习
页: [1]
查看完整版本: m3u8 获取 (js学习)