VideoHelp Forum




+ Reply to Thread
Results 1 to 4 of 4
  1. Member
    Join Date
    Aug 2024
    Location
    Indonesia
    Search Comp PM
    Hi, i am trying to decrypt video from youku chinese drama. URL: https://www.youku.tv/v/v_show/id_XNjQzNjczODY5Mg==.html

    I am using this code to get the key:

    Code:
    import os
    import json
    import m3u8
    import base64
    import urllib
    import requests
    from pywidevine.cdm import Cdm
    from pywidevine.device import Device
    from pywidevine.pssh import PSSH
    
    def cbcs(manifest_url, license_api):
        manifest = m3u8.load(manifest_url)
        pssh = None
        fkeys = ""
    
        for key in manifest.keys:
            if key and 'base64' in key.uri:
                pssh = PSSH(key.uri.split(',')[-1])
    
        if pssh is None:
            print('Error getting pssh.')
            return
    
        device = Device.load('device.wvd')
        cdm = Cdm.from_device(device)
        session_id = cdm.open()
        challenge = cdm.get_license_challenge(session_id, pssh)
    
        headers = {'content-type': 'application/x-www-form-urlencoded'}
        license_request_data = license_api.split('?')[1] + '&licenseRequest=' + urllib.parse.quote(base64.b64encode(challenge).decode())
        
        try:
            license_response = requests.post(license_api.split('?')[0], headers=headers, data=license_request_data)
            license_response.raise_for_status()
        except requests.HTTPError as e:
            print(f"Failed to get license: {e}")
            return
    
        license_info = json.loads(license_response.content)['data']
        cdm.parse_license(session_id, license_info)
    
        for key in cdm.get_keys(session_id):
            if key.type != 'SIGNING':
                fkeys += key.kid.hex + ":" + key.key.hex()
                
        cdm.close(session_id)
    
        return fkeys.strip()
    
    def load_config(config_file):
        try:
            with open(config_file, 'r') as file:
                config = json.load(file)
                return config
        except Exception as e:
            print(f"Error loading config file: {e}")
            exit(1)
    
    config_path = input("Enter the path to the config file: ")
    config = load_config(config_path)
    dir_path = os.path.dirname(config_path)
    filename = os.path.basename(os.path.splitext(config_path)[0])
    m3u8_url = config[0]
    
    try:
        manifest = m3u8.load(m3u8_url)
        if not (manifest.media or manifest.segments):
            raise Exception('Stream might be expired.')
        keys = stream_ext = encryptR_server = copyright_key = None
        if config[1].startswith("http"):
            stream_ext = config[1]
        else:
            encryptR_server = config[1]
            copyright_key = config[2]
    
        if stream_ext:
            inner_m3u8 = manifest.media[0].uri if manifest.media else None
            if inner_m3u8:
                license_data = stream_ext.replace('cbcs', 'widevine')
                keys = cbcs(inner_m3u8, license_data)
                print(keys)
            else:
                print("Failed to extract inner m3u8 URL.")
    
        if not keys:
            print("Failed to retrieve decryption keys.")
    
    except Exception as e:
        print(e)

    You can get the resource from running
    Code:
    videoPlayer.context.originResource.stream
    in the console.

    But when i try to get the key, its returning
    Could not parse license_message as a SignedMessage, Error parsing message
    Then i look at the license server, it is says
    {"data":"default error","msg":"create wvpl session error","states":204}
    , instead of
    Image
    [Attachment 84949 - Click to enlarge]


    What is the main reason of this error? How to fix it
    Last edited by Feddryx; 18th Jan 2025 at 04:40.
    Quote Quote  
  2. Feels Good Man 2nHxWW6GkN1l916N3ayz8HQoi's Avatar
    Join Date
    Jan 2024
    Location
    Pepe Island
    Search Comp PM
    Code:
    776364376602168a4981f78f9aa3a5c9:dcd489bdea184d10339d38cb873156b9
    1080p https://www.swisstransfer.com/d/cd43e214-f9af-4d28-b3af-2d311b634a51
    --[----->+<]>.++++++++++++.---.--------.
    [*drm mass downloader: widefrog*]~~~~~~~~~~~[*how to make your own mass downloader: guide*]
    Quote Quote  
  3. Member
    Join Date
    Aug 2024
    Location
    Indonesia
    Search Comp PM
    oh, now i know the problem is. my wvd got revoked bcs i use android studio wvd. i change it into real device and now its work well
    Quote Quote  
  4. Originally Posted by Feddryx View Post
    oh, now i know the problem is. my wvd got revoked bcs i use android studio wvd. i change it into real device and now its work well
    Hi! I recently came across the same problem: Could not parse license_message as a SignedMessage, Error parsing message. However, my issue may be related to the code rather than the WVD.So I tried using the code you provided, but as a programming beginner, I'm stuck on the configfile part. Could you kindly explain what the configfile is and how I should set it up? If possible, an example or some guidance would be incredibly helpful!Thank you so much for your time and assistance.Best regards!
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!