Compare commits

..

No commits in common. "c82e493ef1e5179f9285e40245de0017b7be8391" and "5f217f299591d384582042c68285344d7dedcf6d" have entirely different histories.

5 changed files with 13 additions and 35 deletions

View File

@ -1,5 +1,3 @@
"""Icon links module for social media links."""
data = { data = {
"discord": "https://discord.cdrm-project.com/", "discord": "https://discord.cdrm-project.com/",
"telegram": "https://telegram.cdrm-project.com/", "telegram": "https://telegram.cdrm-project.com/",

View File

@ -1,5 +1,3 @@
"""Index tags module for the index page."""
tags = { tags = {
"index": { "index": {
"description": "Decrypt Widevine and PlayReady protected content", "description": "Decrypt Widevine and PlayReady protected content",

View File

@ -1,12 +1,9 @@
"""Module to manage the user database."""
import sqlite3 import sqlite3
import os import os
import bcrypt import bcrypt
def create_user_database(): def create_user_database():
"""Create the user database."""
os.makedirs(f"{os.getcwd()}/databases/sql", exist_ok=True) os.makedirs(f"{os.getcwd()}/databases/sql", exist_ok=True)
with sqlite3.connect(f"{os.getcwd()}/databases/sql/users.db") as conn: with sqlite3.connect(f"{os.getcwd()}/databases/sql/users.db") as conn:
@ -24,7 +21,6 @@ def create_user_database():
def add_user(username, password, api_key): def add_user(username, password, api_key):
"""Add a user to the database."""
hashed_pw = bcrypt.hashpw(password.encode("utf-8"), bcrypt.gensalt()) hashed_pw = bcrypt.hashpw(password.encode("utf-8"), bcrypt.gensalt())
with sqlite3.connect(f"{os.getcwd()}/databases/sql/users.db") as conn: with sqlite3.connect(f"{os.getcwd()}/databases/sql/users.db") as conn:
@ -41,7 +37,6 @@ def add_user(username, password, api_key):
def verify_user(username, password): def verify_user(username, password):
"""Verify a user."""
with sqlite3.connect(f"{os.getcwd()}/databases/sql/users.db") as conn: with sqlite3.connect(f"{os.getcwd()}/databases/sql/users.db") as conn:
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute( cursor.execute(
@ -60,7 +55,6 @@ def verify_user(username, password):
def fetch_api_key(username): def fetch_api_key(username):
"""Fetch the API key for a user."""
with sqlite3.connect(f"{os.getcwd()}/databases/sql/users.db") as conn: with sqlite3.connect(f"{os.getcwd()}/databases/sql/users.db") as conn:
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute( cursor.execute(
@ -75,7 +69,7 @@ def fetch_api_key(username):
def change_password(username, new_password): def change_password(username, new_password):
"""Change the password for a user."""
# Hash the new password # Hash the new password
new_hashed_pw = bcrypt.hashpw(new_password.encode("utf-8"), bcrypt.gensalt()) new_hashed_pw = bcrypt.hashpw(new_password.encode("utf-8"), bcrypt.gensalt())
@ -91,7 +85,6 @@ def change_password(username, new_password):
def change_api_key(username, new_api_key): def change_api_key(username, new_api_key):
"""Change the API key for a user."""
# Update the API key in the database # Update the API key in the database
with sqlite3.connect(f"{os.getcwd()}/databases/sql/users.db") as conn: with sqlite3.connect(f"{os.getcwd()}/databases/sql/users.db") as conn:
cursor = conn.cursor() cursor = conn.cursor()
@ -104,7 +97,6 @@ def change_api_key(username, new_api_key):
def fetch_styled_username(username): def fetch_styled_username(username):
"""Fetch the styled username for a user."""
with sqlite3.connect(f"{os.getcwd()}/databases/sql/users.db") as conn: with sqlite3.connect(f"{os.getcwd()}/databases/sql/users.db") as conn:
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute( cursor.execute(
@ -120,7 +112,6 @@ def fetch_styled_username(username):
def fetch_username_by_api_key(api_key): def fetch_username_by_api_key(api_key):
"""Fetch the username for a user by API key."""
with sqlite3.connect(f"{os.getcwd()}/databases/sql/users.db") as conn: with sqlite3.connect(f"{os.getcwd()}/databases/sql/users.db") as conn:
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute("SELECT Username FROM user_info WHERE API_Key = ?", (api_key,)) cursor.execute("SELECT Username FROM user_info WHERE API_Key = ?", (api_key,))

View File

@ -1,13 +1,11 @@
"""Module to check for the config file."""
import os import os
def check_for_config_file(): def check_for_config_file():
"""Check for the config file.""" if os.path.exists(f"{os.getcwd()}/configs/config.yaml"):
if os.path.exists(os.path.join(os.getcwd(), "configs", "config.yaml")):
return return
default_config = """ else:
default_config = """\
default_wv_cdm: '' default_wv_cdm: ''
default_pr_cdm: '' default_pr_cdm: ''
secret_key_flask: 'secretkey' secret_key_flask: 'secretkey'
@ -24,8 +22,6 @@ remote_cdm_secret: ''
# port: '' # port: ''
# database: '' # database: ''
""" """
with open( with open(f"{os.getcwd()}/configs/config.yaml", "w") as f:
os.path.join(os.getcwd(), "configs", "config.yaml"), "w", encoding="utf-8"
) as f:
f.write(default_config) f.write(default_config)
return return

21
main.py
View File

@ -1,10 +1,11 @@
"""Main module to run the application.""" from custom_functions.prechecks.python_checks import run_python_checks
import os run_python_checks()
import yaml from custom_functions.prechecks.precheck import run_precheck
run_precheck()
from flask import Flask from flask import Flask
from flask_cors import CORS from flask_cors import CORS
from routes.react import react_bp from routes.react import react_bp
from routes.api import api_bp from routes.api import api_bp
from routes.remote_device_wv import remotecdm_wv_bp from routes.remote_device_wv import remotecdm_wv_bp
@ -14,17 +15,11 @@ from routes.user_info import user_info_bp
from routes.register import register_bp from routes.register import register_bp
from routes.login import login_bp from routes.login import login_bp
from routes.user_changes import user_change_bp from routes.user_changes import user_change_bp
from custom_functions.prechecks.python_checks import run_python_checks import os
from custom_functions.prechecks.precheck import run_precheck import yaml
run_python_checks()
run_precheck()
app = Flask(__name__) app = Flask(__name__)
with open( with open(f"{os.getcwd()}/configs/config.yaml", "r") as file:
os.path.join(os.getcwd(), "configs", "config.yaml"), "r", encoding="utf-8"
) as file:
config = yaml.safe_load(file) config = yaml.safe_load(file)
app.secret_key = config["secret_key_flask"] app.secret_key = config["secret_key_flask"]