mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 20:43:04 +00:00
fix watchdoge.py add_track()
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import urllib
|
||||
from typing import List
|
||||
from app import models, functions, helpers
|
||||
from app import trackslib, api
|
||||
@@ -44,6 +45,37 @@ def get_album_image(album: list) -> str:
|
||||
return functions.use_defaults()
|
||||
|
||||
|
||||
def get_album_tracks(album: str, artist: str) -> List:
|
||||
return [
|
||||
track
|
||||
for track in api.DB_TRACKS
|
||||
if track["album"] == album and track["albumartist"] == artist
|
||||
]
|
||||
|
||||
|
||||
def create_album(track) -> models.Album:
|
||||
"""
|
||||
Generates and returns an album object from a track object.
|
||||
"""
|
||||
album = {
|
||||
"album": track["album"],
|
||||
"artist": track["albumartist"],
|
||||
}
|
||||
|
||||
album_tracks = get_album_tracks(album["album"], album["artist"])
|
||||
|
||||
album["count"] = len(album_tracks)
|
||||
album["duration"] = get_album_duration(album_tracks)
|
||||
album["date"] = album_tracks[0]["date"]
|
||||
album["artistimage"] = urllib.parse.quote_plus(
|
||||
album_tracks[0]["albumartist"] + ".webp"
|
||||
)
|
||||
|
||||
album["image"] = get_album_image(album_tracks)
|
||||
|
||||
return models.Album(album)
|
||||
|
||||
|
||||
def find_album(albumtitle, artist):
|
||||
for album in api.ALBUMS:
|
||||
if album.album == albumtitle and album.artist == artist:
|
||||
|
||||
Reference in New Issue
Block a user