diff --git a/app/api/__init__.py b/app/api/__init__.py index 2fb0e1c5..4319499d 100644 --- a/app/api/__init__.py +++ b/app/api/__init__.py @@ -23,7 +23,6 @@ from app.api import ( imgserver, playlist, search, - send_file, settings, lyrics, plugins, @@ -31,6 +30,7 @@ from app.api import ( home, getall, auth, + stream, ) # TODO: Move this description to a separate file @@ -96,7 +96,7 @@ def create_api(): with app.app_context(): app.register_api(album.api) app.register_api(artist.api) - app.register_api(send_file.api) + app.register_api(stream.api) app.register_api(search.api) app.register_api(folder.api) app.register_api(playlist.api) diff --git a/app/api/send_file.py b/app/api/stream.py similarity index 97% rename from app/api/send_file.py rename to app/api/stream.py index 74d1b88d..714c3599 100644 --- a/app/api/send_file.py +++ b/app/api/stream.py @@ -3,11 +3,13 @@ Contains all the track routes. """ import os +import time from flask import Blueprint, send_file, request, Response from flask_openapi3 import APIBlueprint, Tag from pydantic import BaseModel, Field from app.api.apischemas import TrackHashSchema +from app.lib.pydub.pydub.audio_segment import AudioSegment from app.lib.trackslib import get_silence_paddings from app.store.tracks import TrackStore @@ -70,7 +72,7 @@ def send_file_as_chunks(filepath: str, audio_type: str) -> Response: """ # NOTE: +1 makes sure the last byte is included in the range. # NOTE: -1 is used to convert the end index to a 0-based index. - chunk_size = 1024 * 512 + chunk_size = 1024 * 360 # 360 KB # Get file size file_size = os.path.getsize(filepath)