VideoHelp Forum



Support our site by donate $5 directly to us Thanks!!!

Try StreamFab Downloader and download streaming video from Netflix, Amazon!



+ Reply to Thread
Results 1 to 13 of 13
  1. hi there,

    how to edit old l3.py for WKS-KEYS to work with newest pywidevine, latest python 3.12 and new cdm device.wvd ?
    now required downgrade protobuf 3.19.5 or use venv ...
    here on attach the old l3.py (but i think you all already have it)
    Image Attached Files
    • File Type: zip l3.zip (564 Bytes, 28 views)
    Quote Quote  
  2. Member aqzs's Avatar
    Join Date
    Mar 2024
    Location
    Paris
    Search Comp PM
    Use a script like this one :
    HTML Code:
     import logging
    from pywidevine.cdm import Cdm
    from pywidevine.device import Device
    from pywidevine.pssh import PSSH
    import httpx
    
    logging.basicConfig(level=logging.DEBUG)
    logger = logging.getLogger(__name__)
    
    WVD_PATH = "/home/angela/Programming/WKS-KEYS/device.wvd"
    from headers import headers
    
    def get_key(pssh, license_url):
        logger.debug("Loading device...")
        device = Device.load(WVD_PATH)
        cdm = Cdm.from_device(device)
        session_id = cdm.open()
        logger.debug("Session opened...")
    
        challenge = cdm.get_license_challenge(session_id, PSSH(pssh))
        response = httpx.post(license_url, data=challenge, headers=headers)
        cdm.parse_license(session_id, response.content)
    
        keys = []
        logger.debug("Retrieving keys...")
        for key in cdm.get_keys(session_id):
            logger.debug(f"Key found: {key.kid.hex}:{key.key.hex()}, Type: {key.type}")
            if key.type == 'CONTENT':
                keys.append(f"--key {key.kid.hex}:{key.key.hex()}")
    
        cdm.close(session_id)
        logger.debug("Session closed...")
        return "\n".join(keys)
    
    if __name__ == "__main__":
        pssh_str = input("PSSH? ")
        lic_url = input("License URL? ")
        result = get_key(pssh_str, lic_url)
        logger.debug("Result:")
        print(result) 
    Source : https://forum.videohelp.com/threads/404994-Decryption-and-the-Temple-of-Doom#post2650297
    Quote Quote  
  3. Member
    Join Date
    Feb 2022
    Location
    Search the forum first!
    Search PM
    And https://forum.videohelp.com/threads/411862-Beyond-WKS-KEYS has more information about making the transition together with an updated L3.py. But plain old L3 is now replaced by allhell3.py see my signature.
    Noob Starter Pack. Just download every Widevine mpd! Not kidding!.
    https://files.videohelp.com/u/301890/hellyes6.zip
    Quote Quote  
  4. thanks aqzs for your edited script version. i can try soon

    @Angela
    yes i know allhell3.py your script work fine. but need copy from lic url as curl bash value, so need to play video on browser
    the old l3.py only is more convenient when someone share data only like pssh and lic url
    i know your thread, and i also posted some comments (now all work fine!)

    now i can test the new edited l3.py
    Quote Quote  
  5. oh yes aqzs, your edited version work fine! wonderful

    this only: how to hide (not print) debug information ? but key only, like old l3.py
    Quote Quote  
  6. solved

    replace level=logging.WARNING instead level=logging.DEBUG
    Quote Quote  
  7. ok guys now i need to take a step forward
    from some link like that https://mediasetinfinity.mediaset.it/movie/benvenutialsud/benvenuti-al-sud_F301623001000101
    the pssh is inside the mpd from <cenc>. so, instead of manually searching pssh from mpd is there a way to have the script search for it ?

    my goal is have an l3_edited.py script v2 to add lic url only for those sites (like the link above) that have a pssh contained on mpd
    Quote Quote  
  8. Sure. In my old script I have these two functions:
    Code:
    def filter_pssh(pssh_list: list, systemid: PSSH.SystemId):
        for item in pssh_list:
            pssh = PSSH(item)
            if pssh.system_id == systemid:
                return pssh
        return None
    
    def get_pssh(mpd_url, headers):
        r = requests.get(url=mpd_url, headers=headers)
        r.raise_for_status()
        pssh_list = re.findall(
            r'<cenc:pssh\b[^>]*>(.*?)</cenc:pssh>',
            r.text)
        return filter_pssh(pssh_list, PSSH.SystemId.Widevine)
    Quote Quote  
  9. Member
    Join Date
    Feb 2022
    Location
    Search the forum first!
    Search PM
    Originally Posted by whs912km View Post
    ok guys now i need to take a step forward
    ...
    the pssh is inside the mpd from <cenc>. so, instead of manually searching pssh from mpd is there a way to have the script search for it ?
    ....
    Did you ever consider that the scripts you use for downloading and decrypting, already will have methods inside to find the pssh and the license URL? Just read what you have, and see how others have found solutions.
    Noob Starter Pack. Just download every Widevine mpd! Not kidding!.
    https://files.videohelp.com/u/301890/hellyes6.zip
    Quote Quote  
  10. thanks Obo for your tip. i can try soon

    @Angela
    i don't you understand ... from script above (with DEBUG infos) the pssh is required at script start ... i think need to be add lines as suggested by Obo in the script
    Quote Quote  
  11. Member
    Join Date
    Feb 2022
    Location
    Search the forum first!
    Search PM
    Originally Posted by whs912km View Post
    thanks Obo for your tip. i can try soon

    @Angela
    i don't you understand ... from script above (with DEBUG infos) the pssh is required at script start ... i think need to be add lines as suggested by Obo in the script
    You are trying to do something which has been done already by people before you. Look at their work. Find an all in one downloader and load the script into a text editor and read it. See how others capture a pssh.

    What's not to to understand? Or use Obo's method if you wish - without doing any thinking.

    But what will you next be asking for help capturing? The license?

    Strive to be an independent learner by using what is already around you. You'll have no need to use VH as a live AI engine to question, if you look through published solutions instead. Use your head is the message!
    Noob Starter Pack. Just download every Widevine mpd! Not kidding!.
    https://files.videohelp.com/u/301890/hellyes6.zip
    Quote Quote  
  12. Member aqzs's Avatar
    Join Date
    Mar 2024
    Location
    Paris
    Search Comp PM
    Originally Posted by whs912km
    now I would like another version that requires mpd and lic url (and get pssh from mpd) like my request here
    https://forum.videohelp.com/threads/415422-edit-old-l3-py-for-new-pywidevine#post2744695
    Use a script like this one :

    HTML Code:
    from pywidevine.cdm import Cdm
    from pywidevine.device import Device
    from pywidevine.pssh import PSSH
    import requests
    import xml.etree.ElementTree as ET
    
    def getpssh(url_mpd):
        psshs = []
        response = requests.get(url_mpd)
        root = ET.fromstring(response.content)
        for i in range(20):
            for j in range(20):
                for k in range(20):
                    for l in range(20):
                        try:
                            if root[i][j][k][l].text not in psshs and len(root[i][j][k][l].text) > 70 and len(root[i][j][k][l].text) < 190:
                                psshs.append(root[i][j][k][l].text)
                        except:
                            pass
        for pssh in psshs:
            return pssh
        
    #
    # enter special header values here  in the form  'token':  ' value',   each on one line -  remember the quotes and the comma!
    headers = {
        'Accept': '*/*',
    }
    
    # prepare pssh
    mpd_url = input("MPD URL? ")
    pssh = getpssh(mpd_url)
    pssh = PSSH(pssh)
    lic_url = input("License URL? ")
    
    # load device
    # for example
    #device = Device.load(r"/home/angela/Programming/WKS-KEYS/pywidevine/L3/cdm/devices/emulator_1/WVD/google_aosp_on_ia_emulator_14.0.0_xxxxxc_4464_l3.wvd")
    device = Device.load(r"<enter your path to the wvd file you have created, here>")
    
    # load cdm
    cdm = Cdm.from_device(device)
    
    # open cdm session
    session_id = cdm.open()
    
    # get license challenge
    challenge = cdm.get_license_challenge(session_id, pssh)
    
    # send license challenge (assuming a generic license server SDK with no API front)
    licence = requests.post(lic_url, headers = headers, data=challenge)
    licence.raise_for_status()
    
    # parse license challenge
    cdm.parse_license(session_id, licence.content)
    
    # print keys
    for key in cdm.get_keys(session_id):
    
        if key.type=='CONTENT':
            print(f"\n--key {key.kid.hex}:{key.key.hex()}")
    
    # close session, disposes of session data
    cdm.close(session_id)
    Quote Quote  
  13. thanks a lot aqzs, i can test now your script

    edit: wonderful, your script work fine. thanks again for your help aqzs
    Last edited by whs912km; 28th Jul 2024 at 12:27.
    Quote Quote  



Similar Threads

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