Fix for DSNP incorrect kid
This commit is contained in:
parent
11108223bc
commit
e1aeee8d36
Binary file not shown.
@ -11,7 +11,7 @@ authors = []
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.9"
|
||||
appdirs = "^1.4.4"
|
||||
beautifulsoup4 = "~4.11.2"
|
||||
beautifulsoup4 = "^4.8.2"
|
||||
click = "^8.0.1"
|
||||
cffi = "^1.16.0"
|
||||
coloredlogs = "^15.0"
|
||||
|
||||
@ -10,7 +10,7 @@ repository = "https://github.com/vevv/subby"
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.8"
|
||||
pymp4 = "~1.4.0"
|
||||
beautifulsoup4 = "^4.11.2"
|
||||
beautifulsoup4 = "^4.8.2"
|
||||
tinycss = "^0.4"
|
||||
click = "^8.1.3"
|
||||
srt = "^3.5.3"
|
||||
|
||||
Binary file not shown.
@ -8,6 +8,7 @@ import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import uuid
|
||||
import xmltodict
|
||||
from collections import defaultdict
|
||||
from enum import Enum
|
||||
from io import BytesIO, TextIOWrapper
|
||||
@ -187,6 +188,7 @@ class Track:
|
||||
break
|
||||
# Below converts PlayReady PSSH to WideVine PSSH
|
||||
try:
|
||||
if self.psshPR:
|
||||
xml_str = base64.b64decode(self.psshPR).decode("utf-16-le", "ignore")
|
||||
xml_str = xml_str[xml_str.index("<"):]
|
||||
xml = load_xml(xml_str).find("DATA") # root: WRMHEADER
|
||||
@ -197,14 +199,14 @@ class Track:
|
||||
if not kid: # v4.3.0.0
|
||||
kid = next(iter(xml.xpath("PROTECTINFO/KIDS/KID/@VALUE")), None) # can be multiple?
|
||||
self.kid = uuid.UUID(base64.b64decode(self.kid).hex()).bytes_le.hex()
|
||||
if not track.psshWV:
|
||||
self.psshWV = Box.parse(Box.build(dict(
|
||||
type=b"pssh",
|
||||
version=0,
|
||||
flags=0,
|
||||
system_ID="9a04f079-9840-4286-ab92-e65be0885f95",
|
||||
init_data=b"\x12\x10" + base64.b64decode(kid)
|
||||
)))
|
||||
#if not track.psshWV:
|
||||
# self.psshWV = Box.parse(Box.build(dict(
|
||||
# type=b"pssh",
|
||||
# version=0,
|
||||
# flags=0,
|
||||
# system_ID="9a04f079-9840-4286-ab92-e65be0885f95",
|
||||
# init_data=b"\x12\x10" + base64.b64decode(kid)
|
||||
# )))
|
||||
return True
|
||||
except: pass
|
||||
|
||||
@ -223,20 +225,19 @@ class Track:
|
||||
automatically.
|
||||
"""
|
||||
if self.encrypted and self.source == "DSNP":
|
||||
try:
|
||||
log = logging.getLogger("Tracks")
|
||||
log.info("+ Replacing KID with correct track KID (DSNP workaround)")
|
||||
if self.descriptor == self.Descriptor.M3U:
|
||||
# if an m3u, try get from playlist
|
||||
master = m3u8.loads((requests or session).get(as_list(self.url)[0]).text, uri=self.url)
|
||||
for x in master.session_keys:
|
||||
if x and x.keyformat.lower == "com.microsoft.playready" and not self.psshPR:
|
||||
self.psshPR = x.uri.split(",")[-1]
|
||||
break
|
||||
for x in master.keys:
|
||||
if x and "com.microsoft.playready" in str(x) and not self.psshPR:
|
||||
self.psshPR = str(x).split("\"")[1].split(",")[-1]
|
||||
break
|
||||
xml_str = base64.b64decode(self.psshPR).decode("utf-16-le", "ignore")
|
||||
xml_str = xml_str[xml_str.index("<"):]
|
||||
kids = [uuid.UUID(base64.b64decode(kid_xml['@VALUE']).hex()).bytes_le.hex() for kid_xml in xmltodict.parse(xml_str)['WRMHEADER']['DATA']['CUSTOMATTRIBUTES']['KIDS']['KID']]
|
||||
if self.kid:
|
||||
kids.remove(self.kid)
|
||||
self.kid = kids[-1]
|
||||
except:
|
||||
raise log.exit("Failed To Replace Correct KID for DSNP")
|
||||
|
||||
elif self.source != "DSNP" and self.psshPR:
|
||||
xml_str = base64.b64decode(self.psshPR).decode("utf-16-le", "ignore")
|
||||
xml_str = xml_str[xml_str.index("<"):]
|
||||
xml = load_xml(xml_str).find("DATA") # root: WRMHEADER
|
||||
@ -246,6 +247,8 @@ class Track:
|
||||
self.kid = next(iter(xml.xpath("PROTECTINFO/KID/@VALUE")), None)
|
||||
if not self.kid: # v4.3.0.0
|
||||
self.kid = next(iter(xml.xpath("PROTECTINFO/KIDS/KID/@VALUE")), None) # can be multiple?
|
||||
if not self.kid:
|
||||
raise
|
||||
|
||||
self.kid = uuid.UUID(base64.b64decode(self.kid).hex()).bytes_le.hex()
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user