mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
handle favorites on recently played
+ use client side timestamp on track logger
This commit is contained in:
@@ -3,6 +3,7 @@ from app.models.logger import Track as TrackLog
|
||||
|
||||
from app.db.sqlite.logger.tracks import SQLiteTrackLogger as db
|
||||
from app.db.sqlite.playlists import SQLitePlaylistMethods as pdb
|
||||
from app.db.sqlite.favorite import SQLiteFavoriteMethods as fdb
|
||||
|
||||
from app.serializers.track import serialize_track
|
||||
from app.serializers.album import album_serializer
|
||||
@@ -66,19 +67,6 @@ def get_recently_played(limit=7):
|
||||
|
||||
continue
|
||||
|
||||
if entry.type == "track":
|
||||
try:
|
||||
track = TrackStore.get_tracks_by_trackhashes([entry.trackhash])[0]
|
||||
except IndexError:
|
||||
continue
|
||||
|
||||
track = serialize_track(track)
|
||||
track["help_text"] = "track"
|
||||
|
||||
items.append({"type": "track", "item": track})
|
||||
|
||||
continue
|
||||
|
||||
if entry.type == "folder":
|
||||
folder = entry.type_src
|
||||
if not folder:
|
||||
@@ -141,4 +129,26 @@ def get_recently_played(limit=7):
|
||||
}
|
||||
)
|
||||
|
||||
if entry.type == "favorite":
|
||||
items.append(
|
||||
{
|
||||
"type": "favorite_tracks",
|
||||
"item": {
|
||||
"help_text": "playlist",
|
||||
"count": fdb.get_track_count(),
|
||||
},
|
||||
}
|
||||
)
|
||||
continue
|
||||
|
||||
try:
|
||||
track = TrackStore.get_tracks_by_trackhashes([entry.trackhash])[0]
|
||||
except IndexError:
|
||||
continue
|
||||
|
||||
track = serialize_track(track)
|
||||
track["help_text"] = "track"
|
||||
|
||||
items.append({"type": "track", "item": track})
|
||||
|
||||
return items
|
||||
|
||||
@@ -15,7 +15,7 @@ from app.models.playlist import Playlist
|
||||
from app.models.track import Track
|
||||
from app.store.albums import AlbumStore
|
||||
from app.store.tracks import TrackStore
|
||||
from app.utils.dates import create_new_date
|
||||
from app.utils.dates import create_new_date, date_string_to_time_passed
|
||||
|
||||
|
||||
def create_thumbnail(image: Any, img_path: str) -> str:
|
||||
@@ -146,7 +146,7 @@ def get_recently_added_playlist(cutoff: int = 14):
|
||||
|
||||
tracks = get_recent_tracks(cutoff)
|
||||
date = datetime.fromtimestamp(tracks[0].created_date)
|
||||
playlist.last_updated = create_new_date(date)
|
||||
playlist.last_updated = date_string_to_time_passed(create_new_date(date))
|
||||
|
||||
images = get_first_4_images(tracks=tracks)
|
||||
playlist.images = images
|
||||
|
||||
Reference in New Issue
Block a user