From 8bd91534f8af1db244a7f6cc4616bb0dca9fbdd7 Mon Sep 17 00:00:00 2001 From: Sasuke-Duck UwU <95662926+SASUKE-DUCK@users.noreply.github.com> Date: Fri, 17 Nov 2023 14:46:51 -0500 Subject: [PATCH] Add files via upload cdrm api added --- cdm/wks.py | 11 +++++++++++ cdrm_api.py | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 cdrm_api.py diff --git a/cdm/wks.py b/cdm/wks.py index feda0f8..8f68a19 100644 --- a/cdm/wks.py +++ b/cdm/wks.py @@ -829,3 +829,14 @@ def extract_pssh_m3u8(content): # If the regex match fails, return None or raise an exception as needed return None + +def get_keys_cdrm_api(headers_license, license_url, pssh_value): + api_url = "https://cdrm-project.com/api" + + r = requests.post(api_url, headers=headers_license, json={"license": license_url, "pssh": pssh_value}) + data = r.json() + + # Extract keys from the response + keys = [key["key"] for key in data.get("keys", [])] + + return keys \ No newline at end of file diff --git a/cdrm_api.py b/cdrm_api.py new file mode 100644 index 0000000..92578e1 --- /dev/null +++ b/cdrm_api.py @@ -0,0 +1,56 @@ +import requests +from cdm.wks import PsshExtractor, get_keys_cdrm_api +# HBOMAX Test +def parse_command_line_arguments(): + """Parse command line arguments.""" + parser = __import__('argparse').ArgumentParser(description="Decrypt Widevine content using MPD URL and License URL") + parser.add_argument("-mpd", required=True, help="URL of the MPD manifest") + parser.add_argument("-lic", required=True, help="URL of the license server") + return parser.parse_args() + +def get_mpd_response(mpd_url): + """Get MPD manifest response.""" + mpd_headers = { + 'origin': 'https://play.hbomax.com', + 'referer': 'https://play.hbomax.com/', + } + return requests.get(mpd_url, headers=mpd_headers) + +def get_license_headers(token): + """Get headers for the license server request.""" + return { + 'accept': "*/*", # no delet + 'content-length': "316", # no delet + 'Connection': 'keep-alive', # no delet + 'authorization': f'Bearer {token}', + 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (Ktesttemp, like Gecko) Chrome/90.0.4430.85 Safari/537.36' + } + +def main(): + # Parse command line arguments + args = parse_command_line_arguments() + mpd_url, license_url = args.mpd, args.lic + + # Get MPD response + mpd_response = get_mpd_response(mpd_url) + + # Extract PSSH value from MPD response + pssh_extractor = PsshExtractor(mpd_response.text) + pssh_value = pssh_extractor.extract_pssh() + + print("PSSH value:", pssh_value) + + # Get headers for the license server request + token = "" + # Update with your actual token + license_headers = get_license_headers(token) + + # Call the function in keys.py to get the keys + keys = get_keys_cdrm_api(license_headers, license_url, pssh_value) + + # Process each key + for key in keys: + print(f'KEY: {key}') + +if __name__ == "__main__": + main()