Skip to content
Snippets Groups Projects
Verified Commit 3290a15c authored by Eliot Berriot's avatar Eliot Berriot
Browse files

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

parent 01cabc70
No related branches found
No related tags found
No related merge requests found
......@@ -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
......@@ -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,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment