Adds support for artist's cover art in subsonic API (#1528)
This commit is contained in:
parent
89b3789c76
commit
44ac313617
4 changed files with 46 additions and 9 deletions
|
|
@ -49,6 +49,7 @@ def get_artist_data(artist_values):
|
|||
"id": artist_values["id"],
|
||||
"name": artist_values["name"],
|
||||
"albumCount": artist_values["_albums_count"],
|
||||
"coverArt": "ar-{}".format(artist_values["id"]),
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -82,6 +83,8 @@ class GetArtistSerializer(serializers.Serializer):
|
|||
"albumCount": len(albums),
|
||||
"album": [],
|
||||
}
|
||||
if artist.attachment_cover_id:
|
||||
payload["coverArt"] = "ar-{}".format(artist.id)
|
||||
for album in albums:
|
||||
album_data = {
|
||||
"id": album.id,
|
||||
|
|
|
|||
|
|
@ -773,6 +773,19 @@ class SubsonicViewSet(viewsets.GenericViewSet):
|
|||
{"error": {"code": 70, "message": "cover art not found."}}
|
||||
)
|
||||
attachment = album.attachment_cover
|
||||
elif id.startswith("ar-"):
|
||||
try:
|
||||
artist_id = int(id.replace("ar-", ""))
|
||||
artist = (
|
||||
music_models.Artist.objects.exclude(attachment_cover=None)
|
||||
.select_related("attachment_cover")
|
||||
.get(pk=artist_id)
|
||||
)
|
||||
except (TypeError, ValueError, music_models.Album.DoesNotExist):
|
||||
return response.Response(
|
||||
{"error": {"code": 70, "message": "cover art not found."}}
|
||||
)
|
||||
attachment = artist.attachment_cover
|
||||
elif id.startswith("at-"):
|
||||
try:
|
||||
attachment_id = id.replace("at-", "")
|
||||
|
|
@ -932,7 +945,7 @@ class SubsonicViewSet(viewsets.GenericViewSet):
|
|||
)
|
||||
uploads_qs = (
|
||||
music_models.Upload.objects.playable_by(request.user.actor)
|
||||
.select_related("track__attachment_cover", "track__description",)
|
||||
.select_related("track__attachment_cover", "track__description")
|
||||
.order_by("-track__creation_date")
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue