Added JSON support

This commit is contained in:
CDM-Project 2024-09-17 01:41:54 -04:00
parent f08a5822fd
commit 84ae841f99
2 changed files with 36 additions and 11 deletions

View File

@ -20,6 +20,7 @@ def load_license_curl():
self.headers = headers
self.cookies = cookies
self.data = data
self.json_data = json_data
try:
with open(f'{os.getcwd()}/License_cURL.py', 'r') as file:
@ -40,6 +41,10 @@ def load_license_curl():
data = local_namespace['data']
else:
data = None
if 'json_data' in local_namespace:
json_data = local_namespace['json_data']
else:
json_data = None
return LicenseCURL()
def check_if_url(string):
@ -57,19 +62,19 @@ def check_if_url(string):
def replace_widevine_challenge(dictionary, challenge):
for key, value in dictionary.items():
if 'widevine' in key.lower():
if 'widevine' in key.lower() or 'license' in key.lower():
dictionary[key] = challenge
elif isinstance(value, dict):
replace_widevine_value(value, challenge_type)
replace_widevine_challenge(value, challenge)
def find_widevine_license(dictionary):
for key, value in dictionary.items():
if 'widevine' in key.lower() or 'license' in key.lower():
license = dictionary[key]
license = dictionary[key].replace("-", "+").replace("_", "/")
return license
elif isinstance(value, dict):
replace_widevine_value(value, challenge_type)
find_widevine_license(value)
def decrypt_local_cdm():
cdm_choice = CDM_Selector.select_local_cdm()
@ -141,17 +146,27 @@ def decrypt_local_cdm():
db_data = challenge
if license_curl.data:
try:
lic_data = replace_widevine_value(license_curl.data, base64.b64encode(challenge).decode())
replace_widevine_challenge(license_curl.data, base64.b64encode(challenge).decode())
lic_data = license_curl.data
except:
pass
else:
lic_data = challenge
lic_data = None
if license_curl.json_data:
try:
replace_widevine_challenge(license_curl.json_data, base64.b64encode(challenge).decode())
json_data = license_curl.json_data
except:
pass
else:
json_data = None
try:
license_response = httpx.post(
url=user_license_url,
headers=license_curl.headers,
cookies=license_curl.cookies,
data=lic_data
json=json_data,
data=challenge if json_data is None and lic_data is None else lic_data
)
except Exception as error:
print(f'{Fore.RED}An error occurred.\n\n{error}')
@ -245,17 +260,27 @@ def decrypt_remote_cdm():
db_data = challenge
if license_curl.data:
try:
lic_data = replace_widevine_value(license_curl.data, base64.b64encode(challenge).decode())
replace_widevine_challenge(license_curl.data, base64.b64encode(challenge).decode())
lic_data = license_curl.data
except:
pass
else:
lic_data = challenge
lic_data = None
if license_curl.json_data:
try:
replace_widevine_challenge(license_curl.json_data, base64.b64encode(challenge).decode())
json_data = license_curl.json_data
except:
pass
else:
json_data = None
try:
license_response = httpx.post(
url=user_license_url,
headers=license_curl.headers,
cookies=license_curl.cookies,
data=lic_data
json=json_data,
data=challenge if json_data is None and lic_data is None else lic_data
)
except Exception as error:
print(f'{Fore.RED}An error occurred.\n\n{error}')

View File

@ -13,7 +13,7 @@ def get_pssh(mpd_or_m3u8_url):
client.headers.update(License_cURL.headers)
if License_cURL.cookies:
client.cookies.update(License_cURL.cookies)
mpd = dash.DASH.from_url(url=mpd_or_m3u8_url,session=client).to_tracks(language="en")
mpd = dash.DASH.from_url(url=mpd_or_m3u8_url, session=client).to_tracks(language="en")
tracks.add(mpd)
PSSH = []
for track in tracks: