forked from tpd94/CDRM-Project
		
	Compare commits
	
		
			4 Commits
		
	
	
		
			5f217f2995
			...
			c82e493ef1
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					c82e493ef1 | ||
| 
						 | 
					29be40ab95 | ||
| 
						 | 
					1ef842978a | ||
| 
						 | 
					e66e32ef0a | 
@ -1,3 +1,5 @@
 | 
			
		||||
"""Icon links module for social media links."""
 | 
			
		||||
 | 
			
		||||
data = {
 | 
			
		||||
    "discord": "https://discord.cdrm-project.com/",
 | 
			
		||||
    "telegram": "https://telegram.cdrm-project.com/",
 | 
			
		||||
 | 
			
		||||
@ -1,3 +1,5 @@
 | 
			
		||||
"""Index tags module for the index page."""
 | 
			
		||||
 | 
			
		||||
tags = {
 | 
			
		||||
    "index": {
 | 
			
		||||
        "description": "Decrypt Widevine and PlayReady protected content",
 | 
			
		||||
 | 
			
		||||
@ -1,9 +1,12 @@
 | 
			
		||||
"""Module to manage the user database."""
 | 
			
		||||
 | 
			
		||||
import sqlite3
 | 
			
		||||
import os
 | 
			
		||||
import bcrypt
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def create_user_database():
 | 
			
		||||
    """Create the user database."""
 | 
			
		||||
    os.makedirs(f"{os.getcwd()}/databases/sql", exist_ok=True)
 | 
			
		||||
 | 
			
		||||
    with sqlite3.connect(f"{os.getcwd()}/databases/sql/users.db") as conn:
 | 
			
		||||
@ -21,6 +24,7 @@ def create_user_database():
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def add_user(username, password, api_key):
 | 
			
		||||
    """Add a user to the database."""
 | 
			
		||||
    hashed_pw = bcrypt.hashpw(password.encode("utf-8"), bcrypt.gensalt())
 | 
			
		||||
 | 
			
		||||
    with sqlite3.connect(f"{os.getcwd()}/databases/sql/users.db") as conn:
 | 
			
		||||
@ -37,6 +41,7 @@ def add_user(username, password, api_key):
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def verify_user(username, password):
 | 
			
		||||
    """Verify a user."""
 | 
			
		||||
    with sqlite3.connect(f"{os.getcwd()}/databases/sql/users.db") as conn:
 | 
			
		||||
        cursor = conn.cursor()
 | 
			
		||||
        cursor.execute(
 | 
			
		||||
@ -55,6 +60,7 @@ def verify_user(username, password):
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def fetch_api_key(username):
 | 
			
		||||
    """Fetch the API key for a user."""
 | 
			
		||||
    with sqlite3.connect(f"{os.getcwd()}/databases/sql/users.db") as conn:
 | 
			
		||||
        cursor = conn.cursor()
 | 
			
		||||
        cursor.execute(
 | 
			
		||||
@ -69,7 +75,7 @@ def fetch_api_key(username):
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def change_password(username, new_password):
 | 
			
		||||
 | 
			
		||||
    """Change the password for a user."""
 | 
			
		||||
    # Hash the new password
 | 
			
		||||
    new_hashed_pw = bcrypt.hashpw(new_password.encode("utf-8"), bcrypt.gensalt())
 | 
			
		||||
 | 
			
		||||
@ -85,6 +91,7 @@ def change_password(username, new_password):
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def change_api_key(username, new_api_key):
 | 
			
		||||
    """Change the API key for a user."""
 | 
			
		||||
    # Update the API key in the database
 | 
			
		||||
    with sqlite3.connect(f"{os.getcwd()}/databases/sql/users.db") as conn:
 | 
			
		||||
        cursor = conn.cursor()
 | 
			
		||||
@ -97,6 +104,7 @@ def change_api_key(username, new_api_key):
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def fetch_styled_username(username):
 | 
			
		||||
    """Fetch the styled username for a user."""
 | 
			
		||||
    with sqlite3.connect(f"{os.getcwd()}/databases/sql/users.db") as conn:
 | 
			
		||||
        cursor = conn.cursor()
 | 
			
		||||
        cursor.execute(
 | 
			
		||||
@ -112,6 +120,7 @@ def fetch_styled_username(username):
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
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:
 | 
			
		||||
        cursor = conn.cursor()
 | 
			
		||||
        cursor.execute("SELECT Username FROM user_info WHERE API_Key = ?", (api_key,))
 | 
			
		||||
 | 
			
		||||
@ -1,11 +1,13 @@
 | 
			
		||||
"""Module to check for the config file."""
 | 
			
		||||
 | 
			
		||||
import os
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def check_for_config_file():
 | 
			
		||||
    if os.path.exists(f"{os.getcwd()}/configs/config.yaml"):
 | 
			
		||||
    """Check for the config file."""
 | 
			
		||||
    if os.path.exists(os.path.join(os.getcwd(), "configs", "config.yaml")):
 | 
			
		||||
        return
 | 
			
		||||
    else:
 | 
			
		||||
        default_config = """\
 | 
			
		||||
    default_config = """
 | 
			
		||||
default_wv_cdm: ''
 | 
			
		||||
default_pr_cdm: ''
 | 
			
		||||
secret_key_flask: 'secretkey'
 | 
			
		||||
@ -22,6 +24,8 @@ remote_cdm_secret: ''
 | 
			
		||||
#  port: ''
 | 
			
		||||
#  database: ''
 | 
			
		||||
"""
 | 
			
		||||
    with open(f"{os.getcwd()}/configs/config.yaml", "w") as f:
 | 
			
		||||
    with open(
 | 
			
		||||
        os.path.join(os.getcwd(), "configs", "config.yaml"), "w", encoding="utf-8"
 | 
			
		||||
    ) as f:
 | 
			
		||||
        f.write(default_config)
 | 
			
		||||
        return
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										21
									
								
								main.py
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								main.py
									
									
									
									
									
								
							@ -1,11 +1,10 @@
 | 
			
		||||
from custom_functions.prechecks.python_checks import run_python_checks
 | 
			
		||||
"""Main module to run the application."""
 | 
			
		||||
 | 
			
		||||
run_python_checks()
 | 
			
		||||
from custom_functions.prechecks.precheck import run_precheck
 | 
			
		||||
 | 
			
		||||
run_precheck()
 | 
			
		||||
import os
 | 
			
		||||
import yaml
 | 
			
		||||
from flask import Flask
 | 
			
		||||
from flask_cors import CORS
 | 
			
		||||
 | 
			
		||||
from routes.react import react_bp
 | 
			
		||||
from routes.api import api_bp
 | 
			
		||||
from routes.remote_device_wv import remotecdm_wv_bp
 | 
			
		||||
@ -15,11 +14,17 @@ from routes.user_info import user_info_bp
 | 
			
		||||
from routes.register import register_bp
 | 
			
		||||
from routes.login import login_bp
 | 
			
		||||
from routes.user_changes import user_change_bp
 | 
			
		||||
import os
 | 
			
		||||
import yaml
 | 
			
		||||
from custom_functions.prechecks.python_checks import run_python_checks
 | 
			
		||||
from custom_functions.prechecks.precheck import run_precheck
 | 
			
		||||
 | 
			
		||||
run_python_checks()
 | 
			
		||||
run_precheck()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
app = Flask(__name__)
 | 
			
		||||
with open(f"{os.getcwd()}/configs/config.yaml", "r") as file:
 | 
			
		||||
with open(
 | 
			
		||||
    os.path.join(os.getcwd(), "configs", "config.yaml"), "r", encoding="utf-8"
 | 
			
		||||
) as file:
 | 
			
		||||
    config = yaml.safe_load(file)
 | 
			
		||||
app.secret_key = config["secret_key_flask"]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user