Added extension support
This commit is contained in:
parent
55f1bd9d9b
commit
920d39807c
@ -7,6 +7,8 @@ from pyplayready import PSSH as PlayReadyPSSH
|
|||||||
from pyplayready.exceptions import (InvalidSession, TooManySessions, InvalidLicense, InvalidPssh)
|
from pyplayready.exceptions import (InvalidSession, TooManySessions, InvalidLicense, InvalidPssh)
|
||||||
from custom_functions.database.user_db import fetch_username_by_api_key
|
from custom_functions.database.user_db import fetch_username_by_api_key
|
||||||
from custom_functions.user_checks.device_allowed import user_allowed_to_use_device
|
from custom_functions.user_checks.device_allowed import user_allowed_to_use_device
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -37,7 +39,22 @@ def remote_cdm_playready_deviceinfo():
|
|||||||
'security_level': cdm.security_level,
|
'security_level': cdm.security_level,
|
||||||
'host': f'{config["fqdn"]}/remotecdm/playready',
|
'host': f'{config["fqdn"]}/remotecdm/playready',
|
||||||
'secret': f'{config["remote_cdm_secret"]}',
|
'secret': f'{config["remote_cdm_secret"]}',
|
||||||
'device_name': f'{base_name}'
|
'device_name': Path(base_name).stem
|
||||||
|
})
|
||||||
|
|
||||||
|
@remotecdm_pr_bp.route('/remotecdm/playready/deviceinfo/<device>', methods=['GET'])
|
||||||
|
def remote_cdm_playready_deviceinfo_specific(device):
|
||||||
|
if request.method == 'GET':
|
||||||
|
base_name = Path(device).with_suffix('.prd').name
|
||||||
|
api_key = request.headers['X-Secret-Key']
|
||||||
|
username = fetch_username_by_api_key(api_key)
|
||||||
|
device = PlayReadyDevice.load(f'{os.getcwd()}/configs/CDMs/{username}/PR/{base_name}')
|
||||||
|
cdm = PlayReadyCDM.from_device(device)
|
||||||
|
return jsonify({
|
||||||
|
'security_level': cdm.security_level,
|
||||||
|
'host': f'{config["fqdn"]}/remotecdm/widevine',
|
||||||
|
'secret': f'{api_key}',
|
||||||
|
'device_name': Path(base_name).stem
|
||||||
})
|
})
|
||||||
|
|
||||||
@remotecdm_pr_bp.route('/remotecdm/playready/<device>/open', methods=['GET'])
|
@remotecdm_pr_bp.route('/remotecdm/playready/<device>/open', methods=['GET'])
|
||||||
|
@ -13,6 +13,7 @@ from pywidevine.exceptions import (InvalidContext, InvalidInitData, InvalidLicen
|
|||||||
import yaml
|
import yaml
|
||||||
from custom_functions.database.user_db import fetch_api_key, fetch_username_by_api_key
|
from custom_functions.database.user_db import fetch_api_key, fetch_username_by_api_key
|
||||||
from custom_functions.user_checks.device_allowed import user_allowed_to_use_device
|
from custom_functions.user_checks.device_allowed import user_allowed_to_use_device
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
remotecdm_wv_bp = Blueprint('remotecdm_wv', __name__)
|
remotecdm_wv_bp = Blueprint('remotecdm_wv', __name__)
|
||||||
with open(f'{os.getcwd()}/configs/config.yaml', 'r') as file:
|
with open(f'{os.getcwd()}/configs/config.yaml', 'r') as file:
|
||||||
@ -35,8 +36,8 @@ def remote_cdm_widevine_deviceinfo():
|
|||||||
if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
base_name = config["default_wv_cdm"]
|
base_name = config["default_wv_cdm"]
|
||||||
if not base_name.endswith(".wvd"):
|
if not base_name.endswith(".wvd"):
|
||||||
full_file_name = (base_name + ".wvd")
|
base_name = (base_name + ".wvd")
|
||||||
device = widevineDevice.load(f'{os.getcwd()}/configs/CDMs/WV/{full_file_name}')
|
device = widevineDevice.load(f'{os.getcwd()}/configs/CDMs/WV/{base_name}')
|
||||||
cdm = widevineCDM.from_device(device)
|
cdm = widevineCDM.from_device(device)
|
||||||
return jsonify({
|
return jsonify({
|
||||||
'device_type': cdm.device_type.name,
|
'device_type': cdm.device_type.name,
|
||||||
@ -44,7 +45,24 @@ def remote_cdm_widevine_deviceinfo():
|
|||||||
'security_level': cdm.security_level,
|
'security_level': cdm.security_level,
|
||||||
'host': f'{config["fqdn"]}/remotecdm/widevine',
|
'host': f'{config["fqdn"]}/remotecdm/widevine',
|
||||||
'secret': f'{config["remote_cdm_secret"]}',
|
'secret': f'{config["remote_cdm_secret"]}',
|
||||||
'device_name': f'{base_name}'
|
'device_name': Path(base_name).stem
|
||||||
|
})
|
||||||
|
|
||||||
|
@remotecdm_wv_bp.route('/remotecdm/widevine/deviceinfo/<device>', methods=['GET'])
|
||||||
|
def remote_cdm_widevine_deviceinfo_specific(device):
|
||||||
|
if request.method == 'GET':
|
||||||
|
base_name = Path(device).with_suffix('.wvd').name
|
||||||
|
api_key = request.headers['X-Secret-Key']
|
||||||
|
username = fetch_username_by_api_key(api_key)
|
||||||
|
device = widevineDevice.load(f'{os.getcwd()}/configs/CDMs/{username}/WV/{base_name}')
|
||||||
|
cdm = widevineCDM.from_device(device)
|
||||||
|
return jsonify({
|
||||||
|
'device_type': cdm.device_type.name,
|
||||||
|
'system_id': cdm.system_id,
|
||||||
|
'security_level': cdm.security_level,
|
||||||
|
'host': f'{config["fqdn"]}/remotecdm/widevine',
|
||||||
|
'secret': f'{api_key}',
|
||||||
|
'device_name': Path(base_name).stem
|
||||||
})
|
})
|
||||||
|
|
||||||
@remotecdm_wv_bp.route('/remotecdm/widevine/<device>/open', methods=['GET'])
|
@remotecdm_wv_bp.route('/remotecdm/widevine/<device>/open', methods=['GET'])
|
||||||
|
@ -2,7 +2,7 @@ from flask import Blueprint, request, jsonify, session
|
|||||||
import os
|
import os
|
||||||
import glob
|
import glob
|
||||||
import logging
|
import logging
|
||||||
from custom_functions.database.user_db import fetch_api_key, fetch_styled_username
|
from custom_functions.database.user_db import fetch_api_key, fetch_styled_username, fetch_username_by_api_key
|
||||||
|
|
||||||
user_info_bp = Blueprint('user_info_bp', __name__)
|
user_info_bp = Blueprint('user_info_bp', __name__)
|
||||||
|
|
||||||
@ -10,6 +10,11 @@ user_info_bp = Blueprint('user_info_bp', __name__)
|
|||||||
def user_info():
|
def user_info():
|
||||||
username = session.get('username')
|
username = session.get('username')
|
||||||
if not username:
|
if not username:
|
||||||
|
try:
|
||||||
|
headers = request.headers
|
||||||
|
api_key = headers['Api-Key']
|
||||||
|
username = fetch_username_by_api_key(api_key)
|
||||||
|
except:
|
||||||
return jsonify({'message': 'False'}), 400
|
return jsonify({'message': 'False'}), 400
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user