mirror of
https://github.com/spaam/svtplay-dl.git
synced 2024-11-24 04:05:39 +01:00
Fix bug with key/decryptor and new m3u parser
This commit is contained in:
parent
4207ccef71
commit
ac6cca8919
@ -95,6 +95,7 @@ class HLS(VideoRetriever):
|
|||||||
else:
|
else:
|
||||||
dl_urls = m3u8.media_segment
|
dl_urls = m3u8.media_segment
|
||||||
|
|
||||||
|
decryptor = None
|
||||||
eta = ETA(len(dl_urls))
|
eta = ETA(len(dl_urls))
|
||||||
for index, i in enumerate(dl_urls):
|
for index, i in enumerate(dl_urls):
|
||||||
item = _get_full_url(i[0], self.url)
|
item = _get_full_url(i[0], self.url)
|
||||||
@ -108,16 +109,21 @@ class HLS(VideoRetriever):
|
|||||||
break
|
break
|
||||||
data = data.content
|
data = data.content
|
||||||
if m3u8.encrypted:
|
if m3u8.encrypted:
|
||||||
|
|
||||||
if self.keycookie:
|
if self.keycookie:
|
||||||
keycookies = self.keycookie
|
keycookies = self.keycookie
|
||||||
else:
|
else:
|
||||||
keycookies = cookies
|
keycookies = cookies
|
||||||
|
|
||||||
key = self.http.request("get", i["EXT-X-KEY"]["URI"], cookies=keycookies).content
|
# Update key/decryptor
|
||||||
rand = os.urandom(16)
|
if "EXT-X-KEY" in i[1]:
|
||||||
decryptor = AES.new(key, AES.MODE_CBC, rand)
|
keyurl = _get_full_url(i[1]["EXT-X-KEY"]["URI"], self.url)
|
||||||
data = decryptor.decrypt(data)
|
key = self.http.request("get", keyurl, cookies=keycookies).content
|
||||||
|
decryptor = AES.new(key, AES.MODE_CBC, os.urandom(16))
|
||||||
|
if decryptor:
|
||||||
|
data = decryptor.decrypt(data)
|
||||||
|
else:
|
||||||
|
raise ValueError("No decryptor found for encrypted hls steam.")
|
||||||
|
|
||||||
file_d.write(data)
|
file_d.write(data)
|
||||||
|
|
||||||
file_d.close()
|
file_d.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user