commit 336e38dc08b1a0c289edef2a56d3de7a1fb2e2ec Author: Bradley Bickford Date: Sat Oct 11 16:05:06 2025 -0400 Initial Commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..962e769 --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# Sanctuary Commander + +Sanctuary Commander will be the successor to Video Commander. With built in functionality for preparing dynamically submitted content, rather than working from a static configuration file. + +The end goal is to have web based control of TV power, volume, input, and displayed content from a single location, while having the ability to pre-download Youtube video content, upload videos and pictures for display later, and keep the interface as simple as possible for the less technically adept. + +Simple Goal List + +- HomeAssistant Integration for TV Power, Volume, and Input Control +- FFPlay based playback of video and audio +- Ahead of time downloading of Youtube video content +- Ahead of time uploading of pictures and videos from external devices +- USB media awareness/playback \ No newline at end of file diff --git a/pages/home/__init__.py b/pages/home/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/pages/home/resources/home.html b/pages/home/resources/home.html new file mode 100644 index 0000000..e69de29 diff --git a/sc_webserver.py b/sc_webserver.py new file mode 100644 index 0000000..e69de29 diff --git a/utilities/database/database.py b/utilities/database/database.py new file mode 100644 index 0000000..d40b68b --- /dev/null +++ b/utilities/database/database.py @@ -0,0 +1,50 @@ +class Database(): + def __init__(self): + pass + + def query(self, query: str, parameters: list=None) -> tuple[int, list[dict]]: + pass + + def select(self, table: str, columns: list[str]=None, where: list[dict]=None) -> list[dict]: + query_string = "SELECT {columns} FROM {table}{where}".format( + columns = "*" if columns is None else ",".join(columns), + table = table, + where = self.__generate_basic_where_clause(where) if not where is None else "" + ) + + return self.query(query_string, [element["value"] for element in where] if not where is None else None)[1] + + def insert(self, table: str, columns: list[str], values: list) -> int: + query_string = "INSERT INTO {table} ({columns}) VALUES ({values})".format( + table = table, + columns = ",".join(columns), + values = ("?," * len(values))[:-1] + ) + + return self.query(query_string, values)[0] + + def update(self, table: str, columns: list[str], values: list, where: list[dict]=None) -> int: + query_string = "UPDATE {table} SET {set_rules}{where}".format( + table = table, + set_rules = ",".join([element + "=?" for element in columns]), + where = self.__generate_basic_where_clause(where) if not where is None else "" + ) + + return self.query(query_string, values)[0] + + def delete(self, table: str, where: list[dict]=None) -> int: + query_string = "DELETE FROM {table}{where}".format( + table = table, + where = self.__generate_basic_where_clause(where) if not where is None else "" + ) + + return self.query(query_string)[0] + + def __generate_basic_where_clause(self, where: list[dict]): + return " WHERE {clauses}".format( + clauses = "".join([ + element["name"] + " " + element["compare"] + " ?" + (" " + element["boolean_op"] + " " if "boolean_op" in element else "") + for element in where + ]) + ) + diff --git a/utilities/database/mysql.py b/utilities/database/mysql.py new file mode 100644 index 0000000..e69de29 diff --git a/utilities/database/sqlite.py b/utilities/database/sqlite.py new file mode 100644 index 0000000..e69de29