hs-m3u8 0.1.3__py3-none-any.whl → 0.1.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
hs_m3u8/__init__.py
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
from hs_m3u8.main import M3u8Downloader
|
|
1
|
+
from hs_m3u8.main import M3u8Downloader, M3u8Key
|
|
2
2
|
|
|
3
|
-
__version__ = "0.1.
|
|
3
|
+
__version__ = "0.1.4"
|
hs_m3u8/main.py
CHANGED
|
@@ -54,8 +54,9 @@ class M3u8Key:
|
|
|
54
54
|
:param key: 密钥
|
|
55
55
|
:param iv: 偏移
|
|
56
56
|
"""
|
|
57
|
+
iv = bytes.fromhex(iv[2:]) if iv and iv.startswith("0x") else iv
|
|
57
58
|
self.key = key
|
|
58
|
-
self.iv = iv
|
|
59
|
+
self.iv = iv
|
|
59
60
|
|
|
60
61
|
|
|
61
62
|
class M3u8Downloader:
|
|
@@ -78,6 +79,7 @@ class M3u8Downloader:
|
|
|
78
79
|
decrypt=False,
|
|
79
80
|
max_workers=None,
|
|
80
81
|
headers=None,
|
|
82
|
+
key: M3u8Key = None,
|
|
81
83
|
get_m3u8_func: Callable = None,
|
|
82
84
|
):
|
|
83
85
|
"""
|
|
@@ -101,6 +103,7 @@ class M3u8Downloader:
|
|
|
101
103
|
self.save_dir = Path(save_path) / "hls"
|
|
102
104
|
self.save_name = Path(save_path).name
|
|
103
105
|
self.key_path = self.save_dir / "key.key"
|
|
106
|
+
self.custom_key = key
|
|
104
107
|
|
|
105
108
|
if not self.save_dir.exists():
|
|
106
109
|
self.save_dir.mkdir(parents=True)
|
|
@@ -216,10 +219,16 @@ class M3u8Downloader:
|
|
|
216
219
|
|
|
217
220
|
# 保存解密key
|
|
218
221
|
if len(m3u8_obj.keys) > 0 and m3u8_obj.keys[0]:
|
|
219
|
-
|
|
220
|
-
|
|
222
|
+
iv = m3u8_obj.keys[0].iv
|
|
223
|
+
if not self.custom_key:
|
|
224
|
+
resp = await self.net.get(m3u8_obj.keys[0].absolute_uri, headers=self.headers)
|
|
225
|
+
key_data = resp.content
|
|
226
|
+
else:
|
|
227
|
+
key_data = self.custom_key.key
|
|
228
|
+
iv = self.custom_key.iv or iv
|
|
229
|
+
|
|
221
230
|
self.save_file(key_data, self.key_path)
|
|
222
|
-
self.ts_key = M3u8Key(key=key_data, iv=
|
|
231
|
+
self.ts_key = M3u8Key(key=key_data, iv=iv)
|
|
223
232
|
key = m3u8_obj.segments[0].key
|
|
224
233
|
key.uri = "key.key"
|
|
225
234
|
m3u8_obj.segments[0].key = key
|
|
@@ -244,7 +253,7 @@ class M3u8Downloader:
|
|
|
244
253
|
if Path(ts_path).exists():
|
|
245
254
|
self.ts_path_list[index] = str(ts_path)
|
|
246
255
|
return
|
|
247
|
-
resp = await self.net.get(ts_item["uri"])
|
|
256
|
+
resp = await self.net.get(ts_item["uri"], self.headers)
|
|
248
257
|
ts_content = resp.content
|
|
249
258
|
if ts_content is None:
|
|
250
259
|
return
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
hs_m3u8/__init__.py,sha256=WxYMLrnGwdYDEmbxZmUV-l2DPs9jrYDP0cAnHxkqtFs,72
|
|
2
|
+
hs_m3u8/main.py,sha256=RELt4z7AM7OuXYiRkCe-yf4A1JGQ9FtIaBj6Vov3Ig0,11574
|
|
3
|
+
hs_m3u8-0.1.4.dist-info/METADATA,sha256=ddVI5SkdoINuFHSPS9uFGDeOmCybhT1al4_4SmXPHRs,2204
|
|
4
|
+
hs_m3u8-0.1.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
5
|
+
hs_m3u8-0.1.4.dist-info/RECORD,,
|
hs_m3u8-0.1.3.dist-info/RECORD
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
hs_m3u8/__init__.py,sha256=t0R3Q2zVnUtOiJ8e2sL29N4QkkBHXKgC54n6OqMbwJs,63
|
|
2
|
-
hs_m3u8/main.py,sha256=kJ4HV1eISz80ttxsr2E9K-tfTKK79URiEJviPcc5tfg,11259
|
|
3
|
-
hs_m3u8-0.1.3.dist-info/METADATA,sha256=nskQSk_KjDfVtGPhdr6cYXdJbfrbHJXnf7JnvtxIcjg,2204
|
|
4
|
-
hs_m3u8-0.1.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
5
|
-
hs_m3u8-0.1.3.dist-info/RECORD,,
|
|
File without changes
|