fix playlists

This commit is contained in:
cwilvx
2024-07-27 22:23:02 +03:00
parent b0e904c84f
commit 881e1d6581
5 changed files with 31 additions and 101 deletions
+2 -4
View File
@@ -1,13 +1,12 @@
from datetime import datetime
import os
from app.db.userdata import FavoritesTable, ScrobbleTable
from app.db.userdata import FavoritesTable, PlaylistTable, ScrobbleTable
from app.models.playlist import Playlist
from app.serializers.track import serialize_track
from app.serializers.album import album_serializer
from app.lib.playlistlib import get_first_4_images
from app.store.folder import FolderStore
from app.store.playlists import PlaylistStore
from app.utils.dates import (
create_new_date,
date_string_to_time_passed,
@@ -148,8 +147,7 @@ def get_recently_played(limit=7):
)
continue
# playlist = pdb.get_playlist_by_id(entry.type_src)
playlist = PlaylistStore.get_playlist_by_id(entry.type_src)
playlist = PlaylistTable.get_by_id(entry.type_src)
if playlist is None:
continue
+9 -2
View File
@@ -13,6 +13,8 @@ from app import settings
from app.db.libdata import TrackTable
from app.models.track import Track
from app.store.albums import AlbumStore
from app.store.tracks import TrackStore
def create_thumbnail(image: Any, img_path: str) -> str:
"""
@@ -103,9 +105,14 @@ def duplicate_images(images: list):
def get_first_4_images(
tracks: list[Track] = [], trackhashes: list[str] = []
) -> list[dict["str", str]]:
"""
Returns images of the first 4 albums that appear in the track list.
When tracks are not passed, trackhashes need to be passed.
Tracks are then resolved from the store.
"""
if len(trackhashes) > 0:
# tracks = TrackStore.get_tracks_by_trackhashes(trackhashes)
tracks = TrackTable.get_tracks_by_trackhashes(trackhashes)
tracks = TrackStore.get_tracks_by_trackhashes(trackhashes)
albums = []