From e93ab7ed139f90c8198bb50873ca6ad173590fe5 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Sun, 21 Apr 2019 22:34:45 +0200 Subject: [PATCH] feat: Use ZIP files for playlist archives It is more widely supported and could be later used for #194 --- classes/PlaylistArchiveStream.php | 6 +++--- controllers/FrontController.php | 4 ++-- phpstan.neon | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/classes/PlaylistArchiveStream.php b/classes/PlaylistArchiveStream.php index 3675595..78f716d 100644 --- a/classes/PlaylistArchiveStream.php +++ b/classes/PlaylistArchiveStream.php @@ -5,16 +5,16 @@ namespace Alltube; -use Barracuda\ArchiveStream\TarArchive; +use Barracuda\ArchiveStream\ZipArchive; use GuzzleHttp\Psr7\Stream; use Psr\Http\Message\StreamInterface; /** - * Class used to create a Tar archive from playlists and stream it to the browser. + * Class used to create a Zip archive from playlists and stream it to the browser. * * @link https://github.com/php-fig/http-message/blob/master/src/StreamInterface.php */ -class PlaylistArchiveStream extends TarArchive implements StreamInterface +class PlaylistArchiveStream extends ZipArchive implements StreamInterface { /** * videos to add in the archive. diff --git a/controllers/FrontController.php b/controllers/FrontController.php index 4af49fd..8b1758e 100644 --- a/controllers/FrontController.php +++ b/controllers/FrontController.php @@ -380,10 +380,10 @@ class FrontController { if (isset($this->video->entries)) { $stream = new PlaylistArchiveStream($this->video); - $response = $response->withHeader('Content-Type', 'application/x-tar'); + $response = $response->withHeader('Content-Type', 'application/zip'); $response = $response->withHeader( 'Content-Disposition', - 'attachment; filename="'.$this->video->title.'.tar"' + 'attachment; filename="'.$this->video->title.'.zip"' ); return $response->withBody($stream); diff --git a/phpstan.neon b/phpstan.neon index e7225f9..0f1af62 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,4 +1,4 @@ parameters: ignoreErrors: # The Archive constructor messes up the output buffering. - - '#Alltube\\PlaylistArchiveStream::__construct\(\) does not call parent constructor from Barracuda\\ArchiveStream\\TarArchive\.#' + - '#Alltube\\PlaylistArchiveStream::__construct\(\) does not call parent constructor from Barracuda\\ArchiveStream\\ZipArchive\.#'