See #195: expose bitrate, size and duration in subsonic API

merge-requests/237/head
Eliot Berriot 2018-05-15 22:35:30 +02:00
rodzic 01cabc705d
commit 3290a15c88
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: DD6965E2476E5C27
2 zmienionych plików z 18 dodań i 4 usunięć

Wyświetl plik

@ -81,6 +81,10 @@ def get_track_data(album, track, tf):
'artistId': album.artist.pk,
'type': 'music',
}
if tf.bitrate:
data['bitrate'] = int(tf.bitrate/1000)
if tf.size:
data['size'] = tf.size
if album.release_date:
data['year'] = album.release_date.year
return data
@ -211,5 +215,9 @@ def get_music_directory_data(artist):
'parent': artist.id,
'type': 'music',
}
if tf.bitrate:
td['bitrate'] = int(tf.bitrate/1000)
if tf.size:
td['size'] = tf.size
data['child'].append(td)
return data

Wyświetl plik

@ -77,7 +77,8 @@ def test_get_album_serializer(factories):
artist = factories['music.Artist']()
album = factories['music.Album'](artist=artist)
track = factories['music.Track'](album=album)
tf = factories['music.TrackFile'](track=track)
tf = factories['music.TrackFile'](
track=track, bitrate=42000, duration=43, size=44)
expected = {
'id': album.pk,
@ -98,7 +99,9 @@ def test_get_album_serializer(factories):
'year': track.album.release_date.year,
'contentType': tf.mimetype,
'suffix': tf.extension or '',
'duration': tf.duration or 0,
'bitrate': 42,
'duration': 43,
'size': 44,
'created': track.creation_date,
'albumId': album.pk,
'artistId': artist.pk,
@ -177,7 +180,8 @@ def test_playlist_detail_serializer(factories):
def test_directory_serializer_artist(factories):
track = factories['music.Track']()
tf = factories['music.TrackFile'](track=track)
tf = factories['music.TrackFile'](
track=track, bitrate=42000, duration=43, size=44)
album = track.album
artist = track.artist
@ -195,7 +199,9 @@ def test_directory_serializer_artist(factories):
'year': track.album.release_date.year,
'contentType': tf.mimetype,
'suffix': tf.extension or '',
'duration': tf.duration or 0,
'bitrate': 42,
'duration': 43,
'size': 44,
'created': track.creation_date,
'albumId': album.pk,
'artistId': artist.pk,