Initial Commit
This commit is contained in:
commit
336e38dc08
13
README.md
Normal file
13
README.md
Normal file
@ -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
|
||||||
0
pages/home/__init__.py
Normal file
0
pages/home/__init__.py
Normal file
0
pages/home/resources/home.html
Normal file
0
pages/home/resources/home.html
Normal file
0
sc_webserver.py
Normal file
0
sc_webserver.py
Normal file
50
utilities/database/database.py
Normal file
50
utilities/database/database.py
Normal file
@ -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
|
||||||
|
])
|
||||||
|
)
|
||||||
|
|
||||||
0
utilities/database/mysql.py
Normal file
0
utilities/database/mysql.py
Normal file
0
utilities/database/sqlite.py
Normal file
0
utilities/database/sqlite.py
Normal file
Loading…
Reference in New Issue
Block a user