feat: Split Youtube downloads in smaller chunks

Fixes #217
This commit is contained in:
Pierre Rudloff 2019-04-22 20:20:04 +02:00
parent bba2087a55
commit 1a6ff90eac
4 changed files with 256 additions and 5 deletions

View file

@ -10,6 +10,7 @@ use Alltube\EmptyUrlException;
use Alltube\PasswordException;
use Alltube\PlaylistArchiveStream;
use Alltube\Video;
use Alltube\YoutubeStream;
use Exception;
use Slim\Http\Request;
use Slim\Http\Response;
@ -172,7 +173,13 @@ class DownloadController extends BaseController
if ($stream->getStatusCode() == 206) {
$response = $response->withStatus(206);
}
$body = $stream->getBody();
if (isset($this->video->downloader_options->http_chunk_size)) {
// Workaround for Youtube throttling the download speed.
$body = new YoutubeStream($this->video);
} else {
$body = $stream->getBody();
}
}
if ($request->isGet()) {
$response = $response->withBody($body);