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:
|
elif entry.is_file() and ext in SUPPORTED_FILES:
|
||||||
files.append(entry)
|
files.append(entry)
|
||||||
|
|
||||||
"""
|
|
||||||
# sort files by most recent
|
# sort files by most recent
|
||||||
# TODO: rework if realy needed.
|
# TODO: rework if realy needed.
|
||||||
files_with_mtime = []
|
files_with_mtime = []
|
||||||
@@ -112,7 +111,6 @@ def get_files_and_dirs(
|
|||||||
|
|
||||||
files_with_mtime.sort(key=lambda f: f["time"])
|
files_with_mtime.sort(key=lambda f: f["time"])
|
||||||
files = [f["path"] for f in files_with_mtime]
|
files = [f["path"] for f in files_with_mtime]
|
||||||
"""
|
|
||||||
|
|
||||||
# if supported files were found
|
# if supported files were found
|
||||||
# convert files to tracks
|
# 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
|
: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
|
# Try starting a server on port 1970
|
||||||
# If it fails, exit with error
|
# If it fails, exit with error
|
||||||
if not port_manager.test_port(port):
|
# if not port_manager.test_port(port):
|
||||||
print(f"Error 48: Port {port} already in use.")
|
# print(f"Error 48: Port {port} already in use.")
|
||||||
print("Please specify a different port using the --port argument.")
|
# print("Please specify a different port using the --port argument.")
|
||||||
sys.exit(1)
|
# sys.exit(1)
|
||||||
|
|
||||||
# Example: Setting up dirs, database, and loading stuff into memory.
|
# Example: Setting up dirs, database, and loading stuff into memory.
|
||||||
# TIP: Be careful with the order of the setup functions.
|
# TIP: Be careful with the order of the setup functions.
|
||||||
|
|||||||
@@ -1,11 +1,31 @@
|
|||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import importlib.resources as imres
|
|
||||||
|
|
||||||
|
|
||||||
FILES = ["flac", "mp3", "wav", "m4a", "ogg", "wma", "opus", "alac", "aiff"]
|
FILES = ["flac", "mp3", "wav", "m4a", "ogg", "wma", "opus", "alac", "aiff"]
|
||||||
SUPPORTED_FILES = tuple(f".{file}" for file in FILES)
|
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]]:
|
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 == "":
|
if path == "":
|
||||||
return [], []
|
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 [], []
|
return [], []
|
||||||
|
|
||||||
# if on mac, ignore Library folder and its children
|
# if on mac, ignore Library folder and its children
|
||||||
# TODO: test on real mac
|
|
||||||
if os.name == "posix":
|
if os.name == "posix":
|
||||||
library_path = (Path.home() / "Library").resolve()
|
library_path = (Path.home() / "Library").resolve()
|
||||||
if path == library_path or str(path).startswith(str(library_path)):
|
if path == library_path or str(path).startswith(str(library_path)):
|
||||||
|
|||||||
Reference in New Issue
Block a user