See #195: expose bitrate, size and duration in subsonic API
This commit is contained in:
parent
01cabc705d
commit
3290a15c88
|
@ -81,6 +81,10 @@ def get_track_data(album, track, tf):
|
||||||
'artistId': album.artist.pk,
|
'artistId': album.artist.pk,
|
||||||
'type': 'music',
|
'type': 'music',
|
||||||
}
|
}
|
||||||
|
if tf.bitrate:
|
||||||
|
data['bitrate'] = int(tf.bitrate/1000)
|
||||||
|
if tf.size:
|
||||||
|
data['size'] = tf.size
|
||||||
if album.release_date:
|
if album.release_date:
|
||||||
data['year'] = album.release_date.year
|
data['year'] = album.release_date.year
|
||||||
return data
|
return data
|
||||||
|
@ -211,5 +215,9 @@ def get_music_directory_data(artist):
|
||||||
'parent': artist.id,
|
'parent': artist.id,
|
||||||
'type': 'music',
|
'type': 'music',
|
||||||
}
|
}
|
||||||
|
if tf.bitrate:
|
||||||
|
td['bitrate'] = int(tf.bitrate/1000)
|
||||||
|
if tf.size:
|
||||||
|
td['size'] = tf.size
|
||||||
data['child'].append(td)
|
data['child'].append(td)
|
||||||
return data
|
return data
|
||||||
|
|
|
@ -77,7 +77,8 @@ def test_get_album_serializer(factories):
|
||||||
artist = factories['music.Artist']()
|
artist = factories['music.Artist']()
|
||||||
album = factories['music.Album'](artist=artist)
|
album = factories['music.Album'](artist=artist)
|
||||||
track = factories['music.Track'](album=album)
|
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 = {
|
expected = {
|
||||||
'id': album.pk,
|
'id': album.pk,
|
||||||
|
@ -98,7 +99,9 @@ def test_get_album_serializer(factories):
|
||||||
'year': track.album.release_date.year,
|
'year': track.album.release_date.year,
|
||||||
'contentType': tf.mimetype,
|
'contentType': tf.mimetype,
|
||||||
'suffix': tf.extension or '',
|
'suffix': tf.extension or '',
|
||||||
'duration': tf.duration or 0,
|
'bitrate': 42,
|
||||||
|
'duration': 43,
|
||||||
|
'size': 44,
|
||||||
'created': track.creation_date,
|
'created': track.creation_date,
|
||||||
'albumId': album.pk,
|
'albumId': album.pk,
|
||||||
'artistId': artist.pk,
|
'artistId': artist.pk,
|
||||||
|
@ -177,7 +180,8 @@ def test_playlist_detail_serializer(factories):
|
||||||
|
|
||||||
def test_directory_serializer_artist(factories):
|
def test_directory_serializer_artist(factories):
|
||||||
track = factories['music.Track']()
|
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
|
album = track.album
|
||||||
artist = track.artist
|
artist = track.artist
|
||||||
|
|
||||||
|
@ -195,7 +199,9 @@ def test_directory_serializer_artist(factories):
|
||||||
'year': track.album.release_date.year,
|
'year': track.album.release_date.year,
|
||||||
'contentType': tf.mimetype,
|
'contentType': tf.mimetype,
|
||||||
'suffix': tf.extension or '',
|
'suffix': tf.extension or '',
|
||||||
'duration': tf.duration or 0,
|
'bitrate': 42,
|
||||||
|
'duration': 43,
|
||||||
|
'size': 44,
|
||||||
'created': track.creation_date,
|
'created': track.creation_date,
|
||||||
'albumId': album.pk,
|
'albumId': album.pk,
|
||||||
'artistId': artist.pk,
|
'artistId': artist.pk,
|
||||||
|
|
Loading…
Reference in New Issue