mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
update mix api endpoint payload shape
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user