mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 04:23:01 +00:00
print local and remote app urls when app host is set to "0.0.0.0"
+ update app version in settings.py
This commit is contained in:
@@ -20,6 +20,12 @@ CREATE TABLE IF NOT EXISTS favorites (
|
||||
hash text not null,
|
||||
type text not null
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS settings (
|
||||
id integer PRIMARY KEY,
|
||||
root_dirs text NOT NULL,
|
||||
exclude_dirs text
|
||||
)
|
||||
"""
|
||||
|
||||
CREATE_APPDB_TABLES = """
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
import json
|
||||
from app.db.sqlite.utils import SQLiteManager
|
||||
|
||||
|
||||
class SettingsSQLMethods:
|
||||
"""
|
||||
Methods for interacting with the settings table.
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def update_root_dirs(dirs: list[str]):
|
||||
"""
|
||||
Updates custom root directories in the database.
|
||||
"""
|
||||
|
||||
sql = "UPDATE settings SET root_dirs = ?"
|
||||
dirs_str = json.dumps(dirs)
|
||||
|
||||
with SQLiteManager(userdata_db=True) as cur:
|
||||
cur.execute(sql, (dirs_str,))
|
||||
|
||||
@staticmethod
|
||||
def get_root_dirs() -> list[str]:
|
||||
"""
|
||||
Gets custom root directories from the database.
|
||||
"""
|
||||
|
||||
sql = "SELECT value FROM settings"
|
||||
|
||||
with SQLiteManager(userdata_db=True) as cur:
|
||||
cur.execute(sql)
|
||||
|
||||
data = cur.fetchone()
|
||||
|
||||
if data is not None:
|
||||
return json.loads(data[0])
|
||||
|
||||
return []
|
||||
|
||||
@staticmethod
|
||||
def update_exclude_dirs(dirs: list[str]):
|
||||
"""
|
||||
Updates excluded directories in the database.
|
||||
"""
|
||||
|
||||
sql = "UPDATE settings SET exclude_dirs = ?"
|
||||
dirs_str = json.dumps(dirs)
|
||||
|
||||
with SQLiteManager(userdata_db=True) as cur:
|
||||
cur.execute(sql, (dirs_str,))
|
||||
+1
-1
@@ -4,7 +4,7 @@ Contains default configs
|
||||
import multiprocessing
|
||||
import os
|
||||
|
||||
APP_VERSION = "Swing v0.0.1.alpha"
|
||||
APP_VERSION = "Swing v.1.0.0.beta.1"
|
||||
|
||||
# paths
|
||||
CONFIG_FOLDER = ".swing"
|
||||
|
||||
+14
-1
@@ -4,6 +4,7 @@ Contains the functions to prepare the server for use.
|
||||
import os
|
||||
import shutil
|
||||
from configparser import ConfigParser
|
||||
import caribou # pylint: disable=import-error
|
||||
|
||||
from app import settings
|
||||
from app.db.sqlite import create_connection, create_tables, queries
|
||||
@@ -11,7 +12,6 @@ from app.db.store import Store
|
||||
from app.settings import APP_DB_PATH, USERDATA_DB_PATH
|
||||
from app.utils import get_home_res_path
|
||||
|
||||
|
||||
config = ConfigParser()
|
||||
|
||||
config_path = get_home_res_path("pyinstaller.config.ini")
|
||||
@@ -114,6 +114,19 @@ def setup_sqlite():
|
||||
create_tables(app_db_conn, queries.CREATE_APPDB_TABLES)
|
||||
create_tables(playlist_db_conn, queries.CREATE_USERDATA_TABLES)
|
||||
|
||||
userdb_migrations = get_home_res_path("app") / "migrations" / "userdata"
|
||||
maindb_migrations = get_home_res_path("app") / "migrations" / "main"
|
||||
|
||||
caribou.upgrade(
|
||||
APP_DB_PATH,
|
||||
maindb_migrations,
|
||||
)
|
||||
|
||||
caribou.upgrade(
|
||||
str(USERDATA_DB_PATH),
|
||||
str(userdb_migrations),
|
||||
)
|
||||
|
||||
app_db_conn.close()
|
||||
playlist_db_conn.close()
|
||||
|
||||
|
||||
+19
-4
@@ -1,14 +1,17 @@
|
||||
"""
|
||||
This module contains mini functions for the server.
|
||||
"""
|
||||
import os
|
||||
import hashlib
|
||||
from pathlib import Path
|
||||
import threading
|
||||
from datetime import datetime
|
||||
from unidecode import unidecode
|
||||
|
||||
import os
|
||||
import socket as Socket
|
||||
import hashlib
|
||||
import threading
|
||||
import requests
|
||||
|
||||
from unidecode import unidecode
|
||||
|
||||
from app import models
|
||||
from app.settings import SUPPORTED_FILES
|
||||
|
||||
@@ -224,3 +227,15 @@ def get_home_res_path(filename: str):
|
||||
Returns a path to resources in the home directory of this project. Used to resolve resources in builds.
|
||||
"""
|
||||
return (CWD / ".." / filename).resolve()
|
||||
|
||||
|
||||
def get_ip():
|
||||
"""
|
||||
Returns the IP address of this device.
|
||||
"""
|
||||
soc = Socket.socket(Socket.AF_INET, Socket.SOCK_DGRAM)
|
||||
soc.connect(("8.8.8.8", 80))
|
||||
ip_address = str(soc.getsockname()[0])
|
||||
soc.close()
|
||||
|
||||
return ip_address
|
||||
|
||||
Reference in New Issue
Block a user