mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
put back default track sort order
+ ignore src files in scans
This commit is contained in:
@@ -95,7 +95,6 @@ def get_files_and_dirs(
|
||||
elif entry.is_file() and ext in SUPPORTED_FILES:
|
||||
files.append(entry)
|
||||
|
||||
"""
|
||||
# sort files by most recent
|
||||
# TODO: rework if realy needed.
|
||||
files_with_mtime = []
|
||||
@@ -112,7 +111,6 @@ def get_files_and_dirs(
|
||||
|
||||
files_with_mtime.sort(key=lambda f: f["time"])
|
||||
files = [f["path"] for f in files_with_mtime]
|
||||
"""
|
||||
|
||||
# if supported files were found
|
||||
# convert files to tracks
|
||||
|
||||
@@ -69,14 +69,14 @@ def start_swingmusic(host: str, port: int):
|
||||
:param port: The port number to run the server on
|
||||
"""
|
||||
|
||||
port_manager = PortManager(host)
|
||||
# port_manager = PortManager(host)
|
||||
|
||||
# Try starting a server on port 1970
|
||||
# If it fails, exit with error
|
||||
if not port_manager.test_port(port):
|
||||
print(f"Error 48: Port {port} already in use.")
|
||||
print("Please specify a different port using the --port argument.")
|
||||
sys.exit(1)
|
||||
# if not port_manager.test_port(port):
|
||||
# print(f"Error 48: Port {port} already in use.")
|
||||
# print("Please specify a different port using the --port argument.")
|
||||
# sys.exit(1)
|
||||
|
||||
# Example: Setting up dirs, database, and loading stuff into memory.
|
||||
# TIP: Be careful with the order of the setup functions.
|
||||
|
||||
@@ -1,11 +1,31 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
import importlib.resources as imres
|
||||
|
||||
|
||||
FILES = ["flac", "mp3", "wav", "m4a", "ogg", "wma", "opus", "alac", "aiff"]
|
||||
SUPPORTED_FILES = tuple(f".{file}" for file in FILES)
|
||||
|
||||
# TODO: Move this to config
|
||||
# INFO: Skip these paths when scanning
|
||||
IGNORE_PATH_ENDSWITH = {
|
||||
"node_modules",
|
||||
"site-packages",
|
||||
"postgres",
|
||||
"__pycache__",
|
||||
"/src",
|
||||
"/learnrs",
|
||||
"/venv",
|
||||
"/code",
|
||||
"/dist",
|
||||
"/demos",
|
||||
"/temp",
|
||||
}
|
||||
|
||||
|
||||
IGNORE_PATH_CONTAINS = {
|
||||
"Photos Library",
|
||||
}
|
||||
|
||||
|
||||
def run_fast_scandir(path: str, full=False) -> tuple[list[str], list[str]]:
|
||||
"""
|
||||
@@ -24,13 +44,17 @@ def run_fast_scandir(path: str, full=False) -> tuple[list[str], list[str]]:
|
||||
if path == "":
|
||||
return [], []
|
||||
|
||||
path = Path(path).resolve()
|
||||
path: Path = Path(path).resolve()
|
||||
|
||||
if "node_modules" in path.as_posix():
|
||||
if any(
|
||||
path.as_posix().endswith(ignore_path) for ignore_path in IGNORE_PATH_ENDSWITH
|
||||
):
|
||||
return [], []
|
||||
|
||||
if any(ignore_path in path.as_posix() for ignore_path in IGNORE_PATH_CONTAINS):
|
||||
return [], []
|
||||
|
||||
# if on mac, ignore Library folder and its children
|
||||
# TODO: test on real mac
|
||||
if os.name == "posix":
|
||||
library_path = (Path.home() / "Library").resolve()
|
||||
if path == library_path or str(path).startswith(str(library_path)):
|
||||
|
||||
Reference in New Issue
Block a user