check todo at api/folder.py line:60

~ everything seems to work fine in Windows too
+ move ProcessArtistColors to Populate
This commit is contained in:
geoffrey45 2023-02-03 23:13:40 +03:00
parent 7b9f5fdb13
commit b1ac3e9a07
7 changed files with 29 additions and 23 deletions

View File

@ -56,8 +56,9 @@ def get_folder_tree():
} }
if is_windows(): if is_windows():
# Trailing slash needed when drive letters are passed,
# Remember, the trailing slash is removed in the client.
req_dir = req_dir + "/" req_dir = req_dir + "/"
# TODO: Test this on Windows
else: else:
req_dir = "/" + req_dir + "/" if not req_dir.startswith("/") else req_dir + "/" req_dir = "/" + req_dir + "/" if not req_dir.startswith("/") else req_dir + "/"
@ -96,16 +97,13 @@ def list_folders():
try: try:
req_dir: str = data["folder"] req_dir: str = data["folder"]
except KeyError: except KeyError:
req_dir = "$home" req_dir = "$root"
if req_dir == "$home": if req_dir == "$root":
# req_dir = settings.USER_HOME_DIR # req_dir = settings.USER_HOME_DIR
# if is_win: # if is_win:
return { return {
"folders": [ "folders": [{"name": d, "path": d} for d in get_all_drives(is_win=is_win)]
{"name": d, "path": d}
for d in get_all_drives(is_win=is_win)
]
} }
if is_win: if is_win:

View File

@ -36,6 +36,4 @@ def run_periodic_checks():
"Internet connection lost. Downloading artist images stopped." "Internet connection lost. Downloading artist images stopped."
) )
ProcessArtistColors()
time.sleep(300) time.sleep(300)

View File

@ -6,7 +6,7 @@ from app.db.sqlite.tracks import SQLiteTrackMethods
from app.db.sqlite.settings import SettingsSQLMethods as sdb from app.db.sqlite.settings import SettingsSQLMethods as sdb
from app.db.sqlite.favorite import SQLiteFavoriteMethods as favdb from app.db.sqlite.favorite import SQLiteFavoriteMethods as favdb
from app.db.store import Store from app.db.store import Store
from app.lib.colorlib import ProcessAlbumColors from app.lib.colorlib import ProcessAlbumColors, ProcessArtistColors
from app.lib.taglib import extract_thumb, get_tags from app.lib.taglib import extract_thumb, get_tags
from app.logger import log from app.logger import log
@ -70,6 +70,8 @@ class Populate:
ProcessTrackThumbnails() ProcessTrackThumbnails()
ProcessAlbumColors() ProcessAlbumColors()
ProcessArtistColors()
@staticmethod @staticmethod
def filter_untagged(tracks: list[Track], files: list[str]): def filter_untagged(tracks: list[Track], files: list[str]):

View File

@ -116,7 +116,7 @@ def get_tags(filepath: str):
else: else:
setattr(tags, tag, "Unknown") setattr(tags, tag, "Unknown")
# TODO: Move parsing title, album and artist to startup. # TODO: Move parsing title, album and artist to startup. (Maybe!)
to_check = ["album", "year", "albumartist"] to_check = ["album", "year", "albumartist"]
for prop in to_check: for prop in to_check:

View File

@ -280,5 +280,5 @@ class Handler(PatternMatchingEventHandler):
add_track(path) add_track(path)
self.files_to_process_windows.remove(event.src_path) self.files_to_process_windows.remove(event.src_path)
except OSError: except OSError:
print("File is locked, skipping") # File is locked, skipping
pass pass

View File

@ -28,13 +28,13 @@ def get_xdg_config_dir():
# ------- HELPER METHODS -------- # ------- HELPER METHODS --------
APP_VERSION = "Swing v.1.0.0.beta.1" APP_VERSION = "v.1.1.0.beta"
# paths # paths
XDG_CONFIG_DIR = get_xdg_config_dir() XDG_CONFIG_DIR = get_xdg_config_dir()
USER_HOME_DIR = os.path.expanduser("~") USER_HOME_DIR = os.path.expanduser("~")
CONFIG_FOLDER = "swing" if XDG_CONFIG_DIR != USER_HOME_DIR else ".swing" CONFIG_FOLDER = "swingmusic" if XDG_CONFIG_DIR != USER_HOME_DIR else ".swingmusic"
APP_DIR = os.path.join(XDG_CONFIG_DIR, CONFIG_FOLDER) APP_DIR = os.path.join(XDG_CONFIG_DIR, CONFIG_FOLDER)
IMG_PATH = os.path.join(APP_DIR, "images") IMG_PATH = os.path.join(APP_DIR, "images")
@ -90,8 +90,8 @@ Options:
EXTRACT_FEAT = True EXTRACT_FEAT = True
""" """
Whether to extract the featured artists from the song title Whether to extract the featured artists from the song title.
Changed using the --no-feat flag Changed using the `--no-feat` flag
""" """

View File

@ -164,31 +164,39 @@ def start_watchdog():
def log_startup_info(): def log_startup_info():
lines = "---------------------------------------" lines = "------------------------------"
# clears terminal 👇 # clears terminal 👇
os.system("cls" if os.name == "nt" else "echo -e \\\\033c") os.system("cls" if os.name == "nt" else "echo -e \\\\033c")
# TODO: Check whether the line above breaks Windows terminal's CTRL D
print(lines) print(lines)
print(f"{TCOLOR.HEADER}{APP_VERSION} {TCOLOR.ENDC}") print(f"{TCOLOR.HEADER}SwingMusic {APP_VERSION} {TCOLOR.ENDC}")
if not settings.EXTRACT_FEAT:
print(f"{TCOLOR.OKBLUE}Extracting featured artists from track titles: {TCOLOR.FAIL}DISABLED!{TCOLOR.ENDC}")
adresses = [Variables.FLASK_HOST] adresses = [Variables.FLASK_HOST]
if Variables.FLASK_HOST == "0.0.0.0": if Variables.FLASK_HOST == "0.0.0.0":
adresses = ["localhost", get_ip()] adresses = ["localhost", get_ip()]
print("Started app on:")
for address in adresses: for address in adresses:
# noinspection HttpUrlsUsage # noinspection HttpUrlsUsage
print( print(
f"Started app on: {TCOLOR.OKGREEN}http://{address}:{Variables.FLASK_PORT}{TCOLOR.ENDC}" f" {TCOLOR.OKGREEN}http://{address}:{Variables.FLASK_PORT}{TCOLOR.ENDC}"
) )
print(lines) print(lines)
print("\n") print("\n")
if not settings.EXTRACT_FEAT:
print(
f"{TCOLOR.OKBLUE}Extracting featured artists from track titles: {TCOLOR.FAIL}DISABLED!{TCOLOR.ENDC}"
)
print(
f"{TCOLOR.OKBLUE}App data folder: {settings.APP_DIR}{TCOLOR.OKGREEN}{TCOLOR.ENDC}"
)
print("\n")
if __name__ == "__main__": if __name__ == "__main__":
HandleArgs() HandleArgs()