mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 04:53:01 +00:00
update mix api endpoint payload shape
This commit is contained in:
@@ -79,7 +79,8 @@ class MixesPlugin(Plugin):
|
|||||||
"""
|
"""
|
||||||
queries = [
|
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,
|
"album": track.og_album,
|
||||||
"with_help": with_help,
|
"with_help": with_help,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
# from tqdm import tqdm
|
# from tqdm import tqdm
|
||||||
|
|
||||||
import itertools
|
import itertools
|
||||||
|
import json
|
||||||
from typing import Callable, Iterable
|
from typing import Callable, Iterable
|
||||||
from app.db.libdata import TrackTable
|
from app.db.libdata import TrackTable
|
||||||
|
|
||||||
@@ -313,3 +314,18 @@ class TrackStore:
|
|||||||
def get_recently_played(cls, limit: int):
|
def get_recently_played(cls, limit: int):
|
||||||
tracks = cls.get_flat_list()
|
tracks = cls.get_flat_list()
|
||||||
return sorted(tracks, key=lambda x: x.lastplayed, reverse=True)[:limit]
|
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)
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ from app.plugins.register import register_plugins
|
|||||||
from app.settings import FLASKVARS, TCOLOR, Info
|
from app.settings import FLASKVARS, TCOLOR, Info
|
||||||
from app.setup import load_into_mem, run_setup
|
from app.setup import load_into_mem, run_setup
|
||||||
from app.start_info_logger import log_startup_info
|
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.filesystem import get_home_res_path
|
||||||
from app.utils.paths import getClientFilesExtensions
|
from app.utils.paths import getClientFilesExtensions
|
||||||
from app.utils.threading import background
|
from app.utils.threading import background
|
||||||
@@ -227,6 +228,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
load_into_mem()
|
load_into_mem()
|
||||||
run_swingmusic()
|
run_swingmusic()
|
||||||
|
TrackStore.export()
|
||||||
|
|
||||||
host = FLASKVARS.get_flask_host()
|
host = FLASKVARS.get_flask_host()
|
||||||
port = FLASKVARS.get_flask_port()
|
port = FLASKVARS.get_flask_port()
|
||||||
|
|||||||
Reference in New Issue
Block a user