From b1ac3e9a0787366cea611bcebb953f587771f1c9 Mon Sep 17 00:00:00 2001 From: geoffrey45 Date: Fri, 3 Feb 2023 23:13:40 +0300 Subject: [PATCH] check todo at api/folder.py line:60 ~ everything seems to work fine in Windows too + move ProcessArtistColors to Populate --- app/api/folder.py | 12 +++++------- app/functions.py | 2 -- app/lib/populate.py | 4 +++- app/lib/taglib.py | 2 +- app/lib/watchdogg.py | 2 +- app/settings.py | 8 ++++---- manage.py | 22 +++++++++++++++------- 7 files changed, 29 insertions(+), 23 deletions(-) diff --git a/app/api/folder.py b/app/api/folder.py index 36132c7..dd20bbf 100644 --- a/app/api/folder.py +++ b/app/api/folder.py @@ -56,8 +56,9 @@ def get_folder_tree(): } if is_windows(): + # Trailing slash needed when drive letters are passed, + # Remember, the trailing slash is removed in the client. req_dir = req_dir + "/" - # TODO: Test this on Windows else: req_dir = "/" + req_dir + "/" if not req_dir.startswith("/") else req_dir + "/" @@ -96,16 +97,13 @@ def list_folders(): try: req_dir: str = data["folder"] except KeyError: - req_dir = "$home" + req_dir = "$root" - if req_dir == "$home": + if req_dir == "$root": # req_dir = settings.USER_HOME_DIR # if is_win: return { - "folders": [ - {"name": d, "path": d} - for d in get_all_drives(is_win=is_win) - ] + "folders": [{"name": d, "path": d} for d in get_all_drives(is_win=is_win)] } if is_win: diff --git a/app/functions.py b/app/functions.py index 3b039df..e0567d6 100644 --- a/app/functions.py +++ b/app/functions.py @@ -36,6 +36,4 @@ def run_periodic_checks(): "Internet connection lost. Downloading artist images stopped." ) - ProcessArtistColors() - time.sleep(300) diff --git a/app/lib/populate.py b/app/lib/populate.py index 0d77b04..7349021 100644 --- a/app/lib/populate.py +++ b/app/lib/populate.py @@ -6,7 +6,7 @@ from app.db.sqlite.tracks import SQLiteTrackMethods from app.db.sqlite.settings import SettingsSQLMethods as sdb from app.db.sqlite.favorite import SQLiteFavoriteMethods as favdb 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.logger import log @@ -70,6 +70,8 @@ class Populate: ProcessTrackThumbnails() ProcessAlbumColors() + ProcessArtistColors() + @staticmethod def filter_untagged(tracks: list[Track], files: list[str]): diff --git a/app/lib/taglib.py b/app/lib/taglib.py index 39c8064..cb71be9 100644 --- a/app/lib/taglib.py +++ b/app/lib/taglib.py @@ -116,7 +116,7 @@ def get_tags(filepath: str): else: 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"] for prop in to_check: diff --git a/app/lib/watchdogg.py b/app/lib/watchdogg.py index f400339..1fde544 100644 --- a/app/lib/watchdogg.py +++ b/app/lib/watchdogg.py @@ -280,5 +280,5 @@ class Handler(PatternMatchingEventHandler): add_track(path) self.files_to_process_windows.remove(event.src_path) except OSError: - print("File is locked, skipping") + # File is locked, skipping pass diff --git a/app/settings.py b/app/settings.py index 18fa097..1bf459d 100644 --- a/app/settings.py +++ b/app/settings.py @@ -28,13 +28,13 @@ def get_xdg_config_dir(): # ------- HELPER METHODS -------- -APP_VERSION = "Swing v.1.0.0.beta.1" +APP_VERSION = "v.1.1.0.beta" # paths XDG_CONFIG_DIR = get_xdg_config_dir() 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) IMG_PATH = os.path.join(APP_DIR, "images") @@ -90,8 +90,8 @@ Options: EXTRACT_FEAT = True """ -Whether to extract the featured artists from the song title -Changed using the --no-feat flag +Whether to extract the featured artists from the song title. +Changed using the `--no-feat` flag """ diff --git a/manage.py b/manage.py index cfb2d10..3fa65a2 100644 --- a/manage.py +++ b/manage.py @@ -164,31 +164,39 @@ def start_watchdog(): def log_startup_info(): - lines = "---------------------------------------" + lines = "------------------------------" # clears terminal 👇 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(f"{TCOLOR.HEADER}{APP_VERSION} {TCOLOR.ENDC}") - - if not settings.EXTRACT_FEAT: - print(f"{TCOLOR.OKBLUE}Extracting featured artists from track titles: {TCOLOR.FAIL}DISABLED!{TCOLOR.ENDC}") + print(f"{TCOLOR.HEADER}SwingMusic {APP_VERSION} {TCOLOR.ENDC}") adresses = [Variables.FLASK_HOST] if Variables.FLASK_HOST == "0.0.0.0": adresses = ["localhost", get_ip()] + print("Started app on:") for address in adresses: # noinspection HttpUrlsUsage 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("\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__": HandleArgs()