mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-22 08:56:17 +00:00
API: stream.view: added support for 'estimateContentLength'
This commit is contained in:
parent
a6b894c586
commit
9eb1bf63d7
@ -110,6 +110,8 @@ def stream_media():
|
||||
|
||||
current_app.logger.info('Transcoding track {0.id} for user {1.id}. Source: {2} at {0.bitrate}kbps. Dest: {3} at {4}kbps'.format(res, request.user, src_suffix, dst_suffix, dst_bitrate))
|
||||
response = Response(transcode(), mimetype = dst_mimetype)
|
||||
if estimateContentLength == 'true':
|
||||
response.headers.add('Content-Length', dst_bitrate * 1000 * res.duration // 8)
|
||||
else:
|
||||
response = send_file(res.path, mimetype = dst_mimetype, conditional=True)
|
||||
|
||||
|
@ -44,7 +44,7 @@ class TranscodingTestCase(ApiTestBase):
|
||||
self._make_request('stream', { 'id': self.trackid, 'format': 'wat' }, error = 0)
|
||||
|
||||
def test_direct_transcode(self):
|
||||
rv = self._stream(maxBitRate = 96)
|
||||
rv = self._stream(maxBitRate = 96, estimateContentLength = 'true')
|
||||
self.assertIn('tests/assets/folder/silence.mp3', rv.data)
|
||||
self.assertTrue(rv.data.endswith('96'))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user