update supported audio files in settings.py

+ add win_replace_slash function to format win path strings
+ misc
This commit is contained in:
geoffrey45
2023-01-30 15:59:28 +03:00
parent 93a04ba041
commit 7e15680f26
15 changed files with 268 additions and 96 deletions
+19 -6
View File
@@ -4,6 +4,8 @@ from concurrent.futures import ThreadPoolExecutor
from app.db.store import Store
from app.models import Folder, Track
from app.settings import SUPPORTED_FILES
from app.logger import log
from app.utils import win_replace_slash
class GetFilesAndDirs:
@@ -26,14 +28,25 @@ class GetFilesAndDirs:
ext = os.path.splitext(entry.name)[1].lower()
if entry.is_dir() and not entry.name.startswith("."):
dirs.append(entry.path)
dirs.append(win_replace_slash(entry.path))
elif entry.is_file() and ext in SUPPORTED_FILES:
files.append(entry.path)
files.append(win_replace_slash(entry.path))
# sort files by modified time
files.sort(
key=lambda f: os.path.getmtime(f) # pylint: disable=unnecessary-lambda
)
files_ = []
for file in files:
try:
files_.append(
{
"path": file,
"time": os.path.getmtime(file),
}
)
except OSError as e:
log.error(e)
files_.sort(key=lambda f: f["time"])
files = [f["path"] for f in files_]
tracks = Store.get_tracks_by_filepaths(files)