VideoHelp Forum




+ Reply to Thread
Results 1 to 5 of 5
  1. Member
    Join Date
    Apr 2021
    Location
    Dominican Republic
    Search Comp PM
    Hi guys, I've been trying to create a sqlite3 database to save the data fetched by wks-keys, I managed to create the table but I can't get it to save the data fetched by wks, can anyone help me? please...

    import base64, requests, sys, xmltodict
    import headers
    from pywidevine.L3.cdm import cdm, deviceconfig
    from base64 import b64encode
    from pywidevine.L3.getPSSH import get_pssh
    from pywidevine.L3.decrypt.wvdecryptcustom import WvDecrypt
    import sqlite3

    pssh = input('\nPSSH: ')
    lic_url = input('License URL: ')

    def WV_Function(pssh, lic_url, cert_b64=None):
    wvdecrypt = WvDecrypt(init_data_b64=pssh, cert_data_b64=cert_b64, device=deviceconfig.device_android_generic)
    widevine_license = requests.post(url=lic_url, data=wvdecrypt.get_challenge(), headers=headers.headers)
    license_b64 = b64encode(widevine_license.content)
    wvdecrypt.update_license(license_b64)
    Correct, keyswvdecrypt = wvdecrypt.start_process()
    if Correct:
    return Correct, keyswvdecrypt
    correct, keys = WV_Function(pssh, lic_url)

    def insert_table(pssh, keys, lic_url):
    conn = sqlite3.connect('Widevine.db')
    cursor = conn.cursor()
    cursor.execute(
    f"INSERT INTO TBL_KEYS(PSSH,KEYS,LICENSE_URL) VALUES ('{pssh}','{keys}','{lic_url}')")
    conn.commit()
    conn.close()

    print()
    for key in keys:
    print('--key ' + key)
    Quote Quote  
  2. you havent actually said what the issue is other than "i cant get it to work".....
    next time try to add some more detail, like what youre expecting to happen and any errors you get when running the script.


    im assuming that when you run the script, you get the keys printed out but then nothing appears in the db.
    is that correct?

    if so, you havent called the insert_table function in your python script.

    you need to add this under the "for key in keys:" line
    Code:
        insert_table(pssh, key, lic_url)
    Image
    [Attachment 69204 - Click to enlarge]
    Quote Quote  
  3. Member
    Join Date
    Apr 2021
    Location
    Dominican Republic
    Search Comp PM
    Originally Posted by ElCap View Post
    you havent actually said what the issue is other than "i cant get it to work".....
    next time try to add some more detail, like what youre expecting to happen and any errors you get when running the script.


    im assuming that when you run the script, you get the keys printed out but then nothing appears in the db.
    is that correct?

    if so, you havent called the insert_table function in your python script.

    you need to add this under the "for key in keys:" line
    Code:
        insert_table(pssh, key, lic_url)
    Image
    [Attachment 69204 - Click to enlarge]
    im assuming that when you run the script, you get the keys printed out but then nothing appears in the db.
    is that correct?
    yes that's my problem. When I insert this insert_table(pssh, key, lic_url) gives me this error NameError: name 'insert_table' is not defined...
    Quote Quote  
  4. can you upload a screenshot of your full script?
    the one you pasted above has no indentation


    Update: script is fixed, it had an extra parameter in the insert_table function.
    Last edited by ElCap; 14th Feb 2023 at 23:27.
    Quote Quote  
  5. BTW, instead of splicing strings into SQL queries like this

    Code:
     f"INSERT INTO TBL_KEYS(PSSH,KEYS,LICENSE_URL) VALUES ('{pssh}','{keys}','{lic_url}')")
    you should use placeholders to bind the values, something like

    Code:
    cur.execute("insert into test(d, ts) values (?, ?)", (today, now))
    More secure/robust.
    Quote Quote  



Similar Threads

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