赞
踩
- #EXTM3U
- #EXT-X-VERSION:3
- #EXT-X-MEDIA-SEQUENCE:0
- #EXT-X-ALLOW-CACHE:YES
- #EXT-X-TARGETDURATION:13
- #EXT-X-KEY:METHOD=AES-128,URI="https://j-island.net/movie/hls_key/s/857401e309d8a032c3bb18f4b09b8db2/?f=jj_20190401_hihijets_004",IV=0xaa3dcf6a7acb92ff4fb08d9b3b3d6f51
- #EXTINF:12.078733,
- https://j-island.stream2.johnnys-net.jp/j-island/jj_20190401_hihijets_004/jj_20190401_hihijets_00400000.ts
- #EXTINF:9.009000,
- https://j-island.stream2.johnnys-net.jp/j-island/jj_20190401_hihijets_004/jj_20190401_hihijets_00400001.ts
- #EXTINF:9.009000,
- https://j-island.stream2.johnnys-net.jp/j-island/jj_20190401_hihijets_004/jj_20190401_hihijets_00400002.ts
- #EXTINF:12.012000,
- https://j-island.stream2.johnnys-net.jp/j-island/jj_20190401_hihijets_004/jj_20190401_hihijets_00400003.ts
- #EXTINF:9.009000,
- https://j-island.stream2.johnnys-net.jp/j-island/jj_20190401_hihijets_004/jj_20190401_hihijets_00400004.ts
- #EXTINF:2.002000,
- https://j-island.stream2.johnnys-net.jp/j-island/jj_20190401_hihijets_004/jj_20190401_hihijets_00400005.ts
- #EXT-X-ENDLIST
m3u8视频另一种下载方式 如上图中用ts链接直接下载下来的ts视频文件是加密的(为什么要下加密的?虽然加密但是下载速度快啊)。
#EXT-X-KEY 字段已经写明了加密方式是AES-128,key通过URI获取,IV也有。
- #EXT-X-KEY:
- METHOD=AES-128,
- URI="https://j-island.net/movie/hls_key/s/857401e309d8a032c3bb18f4b09b8db2/?f=jj_20190401_hihijets_004",
- IV=0xaa3dcf6a7acb92ff4fb08d9b3b3d6f51
那怎么解密呢?
1.复制URI地址到网页,你将秒速自动下载得到一个16字节文件 2.打开终端,打开该文件查看16进制:
打开二进制key
vi -b /路径/key文件
输入“ :%!xxd”再把二进制文件切换到16进制
00000000: 283d cc2d 3747 e965 0a81 ead3 1e04 fa8a (=.-7G.e........
获取到key就是 283dcc2d3747e9650a81ead31e04fa8a 3.打开终端,转化
openssl aes-128-cbc -d -in /路径/media_0.ts -out /路径/media_decryptd_0.ts -nosalt -iv $iv -K $strkey
*media_0.ts* : 加密ts文件(无法播放) *media_decryptd_0.ts* : 解密后ts文件(可以直接播放) *$iv* : aa3dcf6a7acb92ff4fb08d9b3b3d6f51(#EXT-X-KEY字段中获取,注意去掉0x) *$strkey* : 283dcc2d3747e9650a81ead31e04fa8a(上一步获得)
例子:
openssl aes-128-cbc -d -in /Users/用户名/Downloads/001.ts -out /Users/用户名/Downloads/001_dec.ts -nosalt -iv aa3dcf6a7acb92ff4fb08d9b3b3d6f51 -K 283dcc2d3747e9650a81ead31e04fa8a
命令执行完秒速转化(也可能我文件特别短,都切成ts了,一般都不长吧…… 4.到对应路径下去,就能看到转化成功到ts视频了
通过连接:
https://XXXXXXX/video/20210713/48466f15b9094154a3dc405efd5b54fd/cloudv-transfer/555555552773r8qq5556n265646r92r4_e8f05058b8c14e679738b91d96fa6d60_0_3.m3u8?t=1652097774&k=a062691ead867c707b07b5c6caf87385&vid=9e74e191017a1000dd3e822700000000&r=a8aede38018010004b91ff8f00000000
下载文件内容如下
- #EXTM3U
- #EXT-X-VERSION:3
- #EXT-X-MEDIA-SEQUENCE:0
- #EXT-X-ALLOW-CACHE:YES
- #EXT-X-TARGETDURATION:11
- #EXT-X-KEY:METHOD=AES-128,URI="https://api.cloudv.haplat.net/vod/videoManage/getHlsKeyByVideoId?cid=882006&t=1652097774&k=a062691ead867c707b07b5c6caf87385&vid=9e74e191017a1000dd3e822700000000&r=a8aede38018010004b91ff8f00000000",IV=0x993181d25c49657b7b6bfeff30f13d8c
- #EXTINF:1.200000,
- a08a0c0364dc4000b46560e905564520_0000000.ts
- #EXTINF:1.000000,
- a08a0c0364dc4000b46560e905564520_0000001.ts
https://api.cloudv.haplat.net/vod/videoManage/getHlsKeyByVideoId?cid=882006&t=1652097774&k=a062691ead867c707b07b5c6caf87385&vid=9e74e191017a1000dd3e822700000000&r=a8aede38018010004b91ff8f00000000
找到请求的返回值 将字符串进行16进制编码
通过分析,ts下载网址为
https://xxxxxxx/video/20210713/48466f15b9094154a3dc405efd5b54fd/cloudv-transfer/a08a0c0364dc4000b46560e905564520_0000000.ts 构造ts的下载网址为https://xxxxxxx/video/20210713/48466f15b9094154a3dc405efd5b54fd/cloudv-transfer/ + m3u8文件中的数据
下载的ts为加密后的,需要进行解码,采用openssl解码
openssl aes-128-cbc -d -in 0.ts -out 0_1.ts -nosalt -iv 993181d25c49657b7b6bfeff30f13d8c -K f370739f5a517a4724c677a73e156126
5脚本:
- #!C:\Python3.7
- # -*- coding:utf-8 -*-
- # coding=utf-8
- import requests
- import os
- headers = {
- "User - Agent": "Mozilla / 5.0(Windows NT 10.0;WOW64) AppleWebKit / 537.36(KHTML, like Gecko) Chrome / 84.0.4147.105 Safari / 537.36"
- }
-
-
- def download(baseurl,file_m3u8,path_in):
- url_list=[]
- with open(file_m3u8,"r") as f:
- for r in f.readlines():
- if ".ts" in r :
- url_list.append(r.replace("\n","").strip())
- # print(url_list)
-
- for r in url_list:
- url = baseurl+r
- filename=os.path.join(path_in,r.split("_")[1])
- # print(url,filename)
- try:
- re = requests.get(url=url,headers=headers)
- except Exception as e:
- print(e)
- pass
- with open(filename,"ab") as f:
- f.write(re.content)
- print("[*]download:"+filename)
-
-
- def mergeFileToMP4(pathname):
- os.chdir(pathname)
- cmd = "copy /b *.ts new.tmp"
- os.system(cmd)
- os.system('del /Q *.ts')
- os.system('del /Q *.mp4')
- os.rename("new.tmp", "new.mp4")
- os.chdir('..')
- print("merge file is :",str(os.path.join(pathname,"new.mp4")))
-
- def key_test(key):
- print(len(key))
- key_hex=""
- for c in key:
- tem=hex(ord(c))[2:]
- key_hex=key_hex+tem
- print(key_hex)
- return key_hex
-
- def decode_openssl(key,iv,path_in,path_out):
- for file in os.listdir(path_in):
- file_in=os.path.join(path_in,file)
- file_out = os.path.join(path_out,file)
- # print(file_in,file_out)
- cmd=f"openssl aes-128-cbc -d -in {file_in} -out {file_out} -nosalt -iv {iv} -K {key}"
- print(cmd)
- os.system(cmd)
-
- def clear_ts(path):
- os.chdir(path)
- os.system("del /Q *.ts")
-
- def main(baseurl,key,iv,file_m3u8):
- # print("main")
- basepath = os.path.split(file_m3u8)[0]
- basepath_in = os.path.join(basepath, "in")
- basepath_out = os.path.join(basepath, "out")
- if not os.path.exists(basepath_in):
- os.mkdir(basepath_in)
- if not os.path.exists(basepath_out):
- os.mkdir(basepath_out)
-
- download(baseurl=baseurl, file_m3u8=file_m3u8,path_in=basepath_in)
- key = key_test(key)
- decode_openssl(key,iv,basepath_in,basepath_out)
- mergeFileToMP4(basepath_out)
- clear_ts(basepath_in)
-
-
-
- if __name__ == '__main__':
- # https://xxxxxxx/video/20210713/ea044c31965940559162b816ec8e152a/cloudv-transfer/a08a0bff11c84000b465638605564520_0000001.ts
- baseurl="https://xxxxxxxxx/video/20210713/ea044c31965940559162b816ec8e152a/cloudv-transfer/"
- key="±úx£Ú:êh'ÿs{câ"
- iv="131f71ed838a8019b731be5b7f2a1703"
- file_m3u8="./jixian/3.m3u8"
- file_m3u8 = os.path.join(os.getcwd(),file_m3u8)
- if(os.path.exists(file_m3u8)):
- main(baseurl,key,iv,file_m3u8)
- else:
- print("[-]"+file_m3u8+" not found:\n")
- # download(baseurl)
-
-
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。