implement backup and restore draft 1

+ add extra fields for backup in favorites and scrobble data
- not yet for the playlist tracks
This commit is contained in:
cwilvx
2024-08-17 12:19:24 +03:00
parent ca31054f48
commit 7852be5e3f
8 changed files with 133 additions and 21 deletions
+5 -1
View File
@@ -7,6 +7,7 @@ from pydantic import BaseModel, Field
from app.api.apischemas import GenericLimitSchema
from app.db.libdata import TrackTable
from app.db.userdata import FavoritesTable
from app.lib.extras import get_extra_info
from app.models import FavType
from app.settings import Defaults
@@ -71,9 +72,12 @@ def toggle_favorite(body: FavoritesAddBody):
"""
Adds a favorite to the database.
"""
extra = get_extra_info(body.hash, body.type)
try:
FavoritesTable.insert_item({"hash": body.hash, "type": body.type})
FavoritesTable.insert_item(
{"hash": body.hash, "type": body.type, "extra": extra}
)
except:
return {"msg": "Failed! An error occured"}, 500