Add files via upload

added m3u8 option
main
Sasuke-Duck UwU 2023-11-16 03:04:24 -05:00 committed by GitHub
parent 36ab05dbee
commit b4ee29379f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 53 additions and 0 deletions

View File

@ -887,3 +887,14 @@ def print_keys_cdrm_project(response):
print(f'KEY: {key}')
else:
print(f"Error: {response.status_code}")
def extract_pssh_m3u8(content):
# Use regular expression to extract the Base64-encoded PSSH value
pssh_match = re.search(r'URI="data:text/plain;base64,([^"]+)"', content)
if pssh_match:
pssh_base64 = pssh_match.group(1)
return pssh_base64
# If the regex match fails, return None or raise an exception as needed
return None

42
main_m3u8.py Normal file
View File

@ -0,0 +1,42 @@
from cdm.wks import WvDecrypt, device_android_generic, extract_pssh_m3u8, KeyExtractor
import argparse
import requests
def get_keys_license(m3u8_url, license_url):
response = requests.get(m3u8_url)
pssh_value = extract_pssh_m3u8(response.text)
print("PSSH value:", pssh_value)
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36',
}
cert_b64 = None
key_extractor = KeyExtractor(pssh_value, cert_b64, license_url, headers)
keys = key_extractor.get_keys()
wvdecrypt = WvDecrypt(init_data_b64=pssh_value, cert_data_b64=cert_b64, device=device_android_generic)
raw_challenge = wvdecrypt.get_challenge()
data = raw_challenge
return keys
def main():
parser = argparse.ArgumentParser(description="Decrypt Widevine content using M3U8 URL and License URL")
parser.add_argument("-m3u8", required=True, help="URL of the M3U8 manifest")
parser.add_argument("-lic", required=True, help="URL of the license server")
args = parser.parse_args()
m3u8_url = args.m3u8
license_url = args.lic
keys = get_keys_license(m3u8_url, license_url)
for key in keys:
if isinstance(key, list):
if key:
for key_str in key:
print(f"KEY: {key_str}")
if __name__ == "__main__":
main()