Fix typing and casting of `type_` in get_license_challenge
This commit is contained in:
parent
797799a5aa
commit
2d8163f76d
|
@ -263,7 +263,7 @@ class Cdm:
|
||||||
self,
|
self,
|
||||||
session_id: bytes,
|
session_id: bytes,
|
||||||
pssh: PSSH,
|
pssh: PSSH,
|
||||||
type_: Union[int, str] = LicenseType.STREAMING,
|
type_: Union[int, str] = LicenseType.Value("STREAMING"),
|
||||||
privacy_mode: bool = True
|
privacy_mode: bool = True
|
||||||
) -> bytes:
|
) -> bytes:
|
||||||
"""
|
"""
|
||||||
|
@ -297,12 +297,10 @@ class Cdm:
|
||||||
raise InvalidInitData(f"Expected pssh to be a {PSSH}, not {pssh!r}")
|
raise InvalidInitData(f"Expected pssh to be a {PSSH}, not {pssh!r}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if isinstance(type_, int):
|
if isinstance(type_, str):
|
||||||
LicenseType.Name(int(type_))
|
|
||||||
elif isinstance(type_, str):
|
|
||||||
type_ = LicenseType.Value(type_)
|
type_ = LicenseType.Value(type_)
|
||||||
elif not isinstance(type_, LicenseType):
|
elif not isinstance(type_, int):
|
||||||
raise InvalidLicenseType()
|
raise ValueError()
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise InvalidLicenseType(f"License Type {type_!r} is invalid")
|
raise InvalidLicenseType(f"License Type {type_!r} is invalid")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue