30 lines
876 B
Python
30 lines
876 B
Python
import os
|
|
import sqlite3
|
|
|
|
|
|
def upsert_key(PSSH, MPD, KID, KEY, License_URL, Headers, Cookies, Data):
|
|
# Connect to the SQLite database
|
|
conn = sqlite3.connect(f'{os.getcwd()}/Keys.db')
|
|
cursor = conn.cursor()
|
|
|
|
# Create the SQL command for upserting
|
|
sql = '''
|
|
INSERT INTO keys (PSSH, MPD, KID, KEY, License_URL, Headers, Cookies, Data)
|
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
ON CONFLICT(KID)
|
|
DO UPDATE SET
|
|
PSSH = excluded.PSSH,
|
|
MPD = excluded.MPD,
|
|
KEY = excluded.KEY,
|
|
License_URL = excluded.License_URL,
|
|
Headers = excluded.Headers,
|
|
Cookies = excluded.Cookies,
|
|
Data = excluded.Data;
|
|
'''
|
|
|
|
# Execute the SQL command
|
|
cursor.execute(sql, (PSSH, MPD, KID, KEY, License_URL, Headers, Cookies, Data))
|
|
|
|
# Commit the transaction and close the connection
|
|
conn.commit()
|
|
conn.close() |