Subsonic: Actually implement getArtistInfo2 endpoint
Part-of: <https://dev.funkwhale.audio/funkwhale/funkwhale/-/merge_requests/2695>
This commit is contained in:
parent
81401075aa
commit
0fab0470c2
|
@ -269,7 +269,20 @@ class SubsonicViewSet(viewsets.GenericViewSet):
|
||||||
)
|
)
|
||||||
@find_object(music_models.Artist.objects.all(), filter_playable=True)
|
@find_object(music_models.Artist.objects.all(), filter_playable=True)
|
||||||
def get_artist_info2(self, request, *args, **kwargs):
|
def get_artist_info2(self, request, *args, **kwargs):
|
||||||
payload = {"artist-info2": {}}
|
artist = kwargs.pop("obj")
|
||||||
|
artist_info = {}
|
||||||
|
if artist.mbid:
|
||||||
|
artist_info["musicBrainzId"] = [str(artist.mbid)]
|
||||||
|
if artist.attachment_cover:
|
||||||
|
artist_info["mediumImageUrl"] = [
|
||||||
|
artist.attachment_cover.download_url_medium_square_crop
|
||||||
|
]
|
||||||
|
artist_info["largeImageUrl"] = [
|
||||||
|
artist.attachment_cover.download_url_large_square_crop
|
||||||
|
]
|
||||||
|
if artist.description:
|
||||||
|
artist_info["biography"] = [artist.description.rendered]
|
||||||
|
payload = {"artistInfo2": artist_info}
|
||||||
|
|
||||||
return response.Response(payload, status=200)
|
return response.Response(payload, status=200)
|
||||||
|
|
||||||
|
|
|
@ -166,7 +166,11 @@ def test_get_artist_info2(
|
||||||
artist = factories["music.Artist"](playable=True)
|
artist = factories["music.Artist"](playable=True)
|
||||||
playable_by = mocker.spy(music_models.ArtistQuerySet, "playable_by")
|
playable_by = mocker.spy(music_models.ArtistQuerySet, "playable_by")
|
||||||
|
|
||||||
expected = {"artist-info2": {}}
|
expected = {
|
||||||
|
"artistInfo2": {
|
||||||
|
"musicBrainzId": [artist.mbid],
|
||||||
|
}
|
||||||
|
}
|
||||||
response = logged_in_api_client.get(url, {"id": artist.pk})
|
response = logged_in_api_client.get(url, {"id": artist.pk})
|
||||||
|
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Implement Subsonic getArtistInfo2 response
|
Loading…
Reference in New Issue