mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 20:43:04 +00:00
update supported audio files in settings.py
+ add win_replace_slash function to format win path strings + misc
This commit is contained in:
+19
-6
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user