CDRM-Keys/CDRM_Modules/Database.py
CDM-Project 89bcd55f6f Update 3.0.1 - alpha
- Added MPD / HLS PSSH Parser
- Added Caching via KID
2024-09-16 20:16:14 -04:00

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()