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)