kopia lustrzana https://dev.funkwhale.audio/funkwhale/funkwhale
See #195: expose bitrate, size and duration in subsonic API
rodzic
01cabc705d
commit
3290a15c88
|
@ -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,
|
||||
|
|
Ładowanie…
Reference in New Issue