mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
modify last updated date of a playlist on track added
This commit is contained in:
@@ -97,6 +97,7 @@ def add_track_to_playlist(playlist_id: str):
|
||||
return {"error": "Track already exists in playlist"}, 409
|
||||
|
||||
add_artist_to_playlist(int(playlist_id), trackhash)
|
||||
PL.update_last_updated(playlist_id)
|
||||
|
||||
return {"msg": "Done"}, 200
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ from collections import OrderedDict
|
||||
from app.db.sqlite.tracks import SQLiteTrackMethods
|
||||
from app.db.sqlite.utils import SQLiteManager, tuple_to_playlist, tuples_to_playlists
|
||||
from app.models import Artist
|
||||
from app.utils import background
|
||||
from app.utils import background, create_new_date
|
||||
|
||||
|
||||
class SQLitePlaylistMethods:
|
||||
@@ -156,7 +156,7 @@ class SQLitePlaylistMethods:
|
||||
del playlist["id"]
|
||||
del playlist["trackhashes"]
|
||||
del playlist["artisthashes"]
|
||||
del playlist['banner_pos']
|
||||
del playlist["banner_pos"]
|
||||
|
||||
playlist = OrderedDict(sorted(playlist.items()))
|
||||
params = (*playlist.values(), playlist_id)
|
||||
@@ -164,6 +164,14 @@ class SQLitePlaylistMethods:
|
||||
with SQLiteManager(userdata_db=True) as cur:
|
||||
cur.execute(sql, params)
|
||||
|
||||
@staticmethod
|
||||
def update_last_updated(playlist_id: int, date=create_new_date()):
|
||||
"""Updates the last updated date of a playlist."""
|
||||
sql = """UPDATE playlists SET last_updated = ? WHERE id = ?"""
|
||||
|
||||
with SQLiteManager(userdata_db=True) as cur:
|
||||
cur.execute(sql, (date, playlist_id))
|
||||
|
||||
@staticmethod
|
||||
def delete_playlist(pid: str):
|
||||
sql = "DELETE FROM playlists WHERE id = ?"
|
||||
|
||||
Reference in New Issue
Block a user