mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
add route to get all tracks in path
+ add routes to save album and artist as a playlist
This commit is contained in:
+22
-4
@@ -2,16 +2,18 @@
|
||||
Contains all the folder routes.
|
||||
"""
|
||||
import os
|
||||
import psutil
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import psutil
|
||||
from flask import Blueprint, request
|
||||
from showinfm import show_in_file_manager
|
||||
|
||||
from app import settings
|
||||
from app.lib.folderslib import GetFilesAndDirs, get_folders
|
||||
from app.db.sqlite.settings import SettingsSQLMethods as db
|
||||
from app.utils.wintools import win_replace_slash, is_windows
|
||||
from app.lib.folderslib import GetFilesAndDirs, get_folders
|
||||
from app.serializers.track import track_serializer
|
||||
from app.store.tracks import TrackStore as store
|
||||
from app.utils.wintools import is_windows, win_replace_slash
|
||||
|
||||
api = Blueprint("folder", __name__, url_prefix="")
|
||||
|
||||
@@ -129,3 +131,19 @@ def open_in_file_manager():
|
||||
show_in_file_manager(path)
|
||||
|
||||
return {"success": True}
|
||||
|
||||
|
||||
@api.route("/folder/tracks/all")
|
||||
def get_tracks_in_path():
|
||||
path = request.args.get("path")
|
||||
|
||||
if path is None:
|
||||
return {"error": "No path provided."}, 400
|
||||
|
||||
tracks = store.get_tracks_in_path(path)
|
||||
tracks = sorted(tracks, key=lambda i: i.last_mod)
|
||||
tracks = (track_serializer(t) for t in tracks if Path(t.filepath).exists())
|
||||
|
||||
return {
|
||||
"tracks": list(tracks)[:300],
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user