update mix api endpoint payload shape

This commit is contained in:
cwilvx
2024-12-08 16:20:58 +03:00
parent 37374d6c82
commit 8ff283cbcb
4 changed files with 21 additions and 2 deletions
+2 -1
View File
@@ -79,7 +79,8 @@ class MixesPlugin(Plugin):
"""
queries = [
{
"query": f"{track.title} - {','.join(a['name'] for a in track.artists)}",
"title": track.title,
"artists": [a["name"] for a in track.artists],
"album": track.og_album,
"with_help": with_help,
}
+16
View File
@@ -1,6 +1,7 @@
# from tqdm import tqdm
import itertools
import json
from typing import Callable, Iterable
from app.db.libdata import TrackTable
@@ -313,3 +314,18 @@ class TrackStore:
def get_recently_played(cls, limit: int):
tracks = cls.get_flat_list()
return sorted(tracks, key=lambda x: x.lastplayed, reverse=True)[:limit]
@classmethod
def export(cls):
path = "tracks.json"
with open(path, "w") as f:
data = [
{
"title": t.title,
"album": t.album,
"artists": [a["name"] for a in t.artists],
}
for t in cls.get_flat_list()
]
json.dump(data, f)
+2
View File
@@ -27,6 +27,7 @@ from app.plugins.register import register_plugins
from app.settings import FLASKVARS, TCOLOR, Info
from app.setup import load_into_mem, run_setup
from app.start_info_logger import log_startup_info
from app.store.tracks import TrackStore
from app.utils.filesystem import get_home_res_path
from app.utils.paths import getClientFilesExtensions
from app.utils.threading import background
@@ -227,6 +228,7 @@ if __name__ == "__main__":
load_into_mem()
run_swingmusic()
TrackStore.export()
host = FLASKVARS.get_flask_host()
port = FLASKVARS.get_flask_port()