From 7bfe55fff64badc0687f82a99fe26d2023a2cdfa Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Sat, 11 Mar 2023 14:37:28 +0100 Subject: [PATCH 1/6] "git describe" needs to be non-interactive so we can get its output --- classes/Robo/Plugin/Commands/ReleaseCommand.php | 1 + 1 file changed, 1 insertion(+) diff --git a/classes/Robo/Plugin/Commands/ReleaseCommand.php b/classes/Robo/Plugin/Commands/ReleaseCommand.php index c355718..837ac78 100644 --- a/classes/Robo/Plugin/Commands/ReleaseCommand.php +++ b/classes/Robo/Plugin/Commands/ReleaseCommand.php @@ -26,6 +26,7 @@ class ReleaseCommand extends Tasks $gitTask = $this->taskExec('git'); $result = $gitTask ->arg('describe') + ->interactive(false) ->run(); $tmpDir = $this->_tmpDir(); From b52a58253917d8d0898a13fb88d756c5efc5fe6a Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Tue, 21 Mar 2023 19:54:58 +0100 Subject: [PATCH 2/6] Stop supporting PHP 7.3 (#430) It is unmaintained --- .github/workflows/ci.yml | 3 ++- Dockerfile | 3 +-- composer.json | 6 +++--- composer.lock | 23 +++++++++++------------ 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d9a62ad..4167d5b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,8 +9,9 @@ jobs: strategy: matrix: php-version: - - '7.3' - '7.4' + - '8.0' + - '8.1' steps: - uses: actions/checkout@v2 - name: Use PHP ${{ matrix.php-version }} diff --git a/Dockerfile b/Dockerfile index c0017b0..d7b0cb1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,6 @@ -FROM php:7.3-apache +FROM php:7.4-apache RUN apt-get update RUN apt-get install -y libicu-dev xz-utils git python libgmp-dev unzip ffmpeg -RUN docker-php-ext-install mbstring RUN docker-php-ext-install intl RUN docker-php-ext-install gmp RUN a2enmod rewrite diff --git a/composer.json b/composer.json index dfe87f5..aab1f1f 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ } ], "require": { - "php": ">=7.3", + "php": ">=7.4", "ext-intl": "*", "ext-json": "*", "aura/session": "^2.1", @@ -31,7 +31,7 @@ "mathmarques/smarty-view": "^1.2", "oomphinc/composer-installers-extender": "^2.0", "paragonie/csp-builder": "^2.5", - "rinvex/countries": "^6.1", + "rinvex/countries": "^7.3", "rudloff/alltube-library": "^0.1.3", "symfony/finder": "^5.4", "symfony/translation": "^4.0", @@ -92,7 +92,7 @@ "phpro/grumphp": true }, "platform": { - "php": "7.3.11" + "php": "7.4.33" }, "sort-packages": true }, diff --git a/composer.lock b/composer.lock index e2084e5..3a61904 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "6f7b900aafa876f17e0815ca6fa044a5", + "content-hash": "454753ac2a4d31f21bf2e197b7ce24d1", "packages": [ { "name": "aura/session", @@ -2042,25 +2042,24 @@ }, { "name": "rinvex/countries", - "version": "v6.1.2", + "version": "v7.3.2", "source": { "type": "git", "url": "https://github.com/rinvex/countries.git", - "reference": "0dd9da817c1faa33429fe56b8ba059fdabe6e0fe" + "reference": "4696d23976e27d6cedf7e55db3fa24e11924b727" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/rinvex/countries/zipball/0dd9da817c1faa33429fe56b8ba059fdabe6e0fe", - "reference": "0dd9da817c1faa33429fe56b8ba059fdabe6e0fe", + "url": "https://api.github.com/repos/rinvex/countries/zipball/4696d23976e27d6cedf7e55db3fa24e11924b727", + "reference": "4696d23976e27d6cedf7e55db3fa24e11924b727", "shasum": "" }, "require": { - "php": "^7.2.0" + "php": "^7.4.0 || ^8.0.0" }, "require-dev": { - "codedungeon/phpunit-result-printer": "^0.26.0", - "laravel/helpers": "^1.1.0", - "phpunit/phpunit": "^8.3.0" + "codedungeon/phpunit-result-printer": "^0.30.0", + "phpunit/phpunit": "^9.5.0" }, "type": "library", "extra": { @@ -2122,7 +2121,7 @@ "issues": "https://github.com/rinvex/countries/issues", "source": "https://github.com/rinvex/countries" }, - "time": "2020-03-13T18:04:45+00:00" + "time": "2020-12-25T01:36:24+00:00" }, { "name": "rudloff/alltube-library", @@ -9359,13 +9358,13 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=7.3", + "php": ">=7.4", "ext-intl": "*", "ext-json": "*" }, "platform-dev": [], "platform-overrides": { - "php": "7.3.11" + "php": "7.4.33" }, "plugin-api-version": "2.2.0" } From b23ce88be8ba8a1f32b3f2d400504ebb172d7fac Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Tue, 21 Mar 2023 20:07:31 +0100 Subject: [PATCH 3/6] fixup! fix dockerfile permission issue (#426) --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index d7b0cb1..b6be73e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,4 +11,5 @@ RUN php composer.phar check-platform-reqs --no-dev RUN php composer.phar install --prefer-dist --no-progress --no-dev --optimize-autoloader RUN mkdir /var/www/html/templates_c/ RUN chmod 770 -R /var/www/html/templates_c/ +RUN chown www-data -R /var/www/html/templates_c/ ENV CONVERT=1 From 71647158d385349a86b87393a916bae9652d9a94 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Tue, 21 Mar 2023 20:18:21 +0100 Subject: [PATCH 4/6] Stronger typying now that we target PHP 7.4 --- classes/Config.php | 38 +++++++++++++----------- classes/Controller/BaseController.php | 6 ++-- classes/LocaleManager.php | 6 ++-- classes/Stream/PlaylistArchiveStream.php | 8 ++--- classes/Stream/YoutubeChunkStream.php | 2 +- 5 files changed, 31 insertions(+), 29 deletions(-) diff --git a/classes/Config.php b/classes/Config.php index 919e1b4..5358564 100644 --- a/classes/Config.php +++ b/classes/Config.php @@ -24,84 +24,86 @@ class Config * * @var string */ - public $youtubedl = 'vendor/ytdl-org/youtube-dl/youtube_dl/__main__.py'; + public string $youtubedl = 'vendor/ytdl-org/youtube-dl/youtube_dl/__main__.py'; /** * python binary path. * * @var string */ - public $python = '/usr/bin/python'; + public string $python = '/usr/bin/python'; /** * youtube-dl parameters. * * @var string[] */ - public $params = ['--no-warnings', '--ignore-errors', '--flat-playlist', '--restrict-filenames', '--no-playlist']; + public array $params = [ + '--no-warnings', '--ignore-errors', '--flat-playlist', '--restrict-filenames', '--no-playlist' + ]; /** * Enable audio conversion. * * @var bool */ - public $convert = false; + public bool $convert = false; /** * Enable advanced conversion mode. * * @var bool */ - public $convertAdvanced = false; + public bool $convertAdvanced = false; /** * List of formats available in advanced conversion mode. * * @var string[] */ - public $convertAdvancedFormats = ['mp3', 'avi', 'flv', 'wav']; + public array $convertAdvancedFormats = ['mp3', 'avi', 'flv', 'wav']; /** * ffmpeg binary path. * * @var string */ - public $ffmpeg = '/usr/bin/ffmpeg'; + public string $ffmpeg = '/usr/bin/ffmpeg'; /** * Path to the directory that contains the phantomjs binary. * * @var string */ - public $phantomjsDir = '/usr/bin/'; + public string $phantomjsDir = '/usr/bin/'; /** * Disable URL rewriting. * * @var bool */ - public $uglyUrls = false; + public bool $uglyUrls = false; /** * Stream downloaded files trough server? * * @var bool */ - public $stream = false; + public bool $stream = false; /** * Allow to remux video + audio? * * @var bool */ - public $remux = false; + public bool $remux = false; /** * MP3 bitrate when converting (in kbit/s). * * @var int */ - public $audioBitrate = 128; + public int $audioBitrate = 128; /** * ffmpeg logging level. @@ -109,21 +111,21 @@ class Config * * @var string */ - public $ffmpegVerbosity = 'error'; + public string $ffmpegVerbosity = 'error'; /** * App name. * * @var string */ - public $appName = 'AllTube Download'; + public string $appName = 'AllTube Download'; /** * Generic formats supported by youtube-dl. * * @var string[] */ - public $genericFormats = [ + public array $genericFormats = [ 'best/bestvideo' => 'Best', 'bestvideo+bestaudio' => 'Remux best video with best audio', 'worst/worstvideo' => 'Worst', @@ -134,21 +136,21 @@ class Config * * @var bool */ - public $debug = false; + public bool $debug = false; /** * Default to audio. * * @var bool */ - public $defaultAudio = false; + public bool $defaultAudio = false; /** * Disable audio conversion from/to seeker. * * @var bool */ - public $convertSeek = true; + public bool $convertSeek = true; /** * Config constructor. diff --git a/classes/Controller/BaseController.php b/classes/Controller/BaseController.php index 9562bc3..ee16653 100644 --- a/classes/Controller/BaseController.php +++ b/classes/Controller/BaseController.php @@ -30,21 +30,21 @@ abstract class BaseController * * @var Video */ - protected $video; + protected Video $video; /** * Default youtube-dl format. * * @var string */ - protected $defaultFormat = 'best/bestvideo'; + protected string $defaultFormat = 'best/bestvideo'; /** * Slim dependency container. * * @var ContainerInterface */ - protected $container; + protected ContainerInterface $container; /** * Config instance. diff --git a/classes/LocaleManager.php b/classes/LocaleManager.php index 0b4c9a2..c8aff44 100644 --- a/classes/LocaleManager.php +++ b/classes/LocaleManager.php @@ -27,14 +27,14 @@ class LocaleManager * * @var Locale|null */ - private $curLocale; + private ?Locale $curLocale = null; /** * Session segment used to store session variables. * * @var Segment */ - private $sessionSegment; + private Segment $sessionSegment; /** * Default locale. @@ -48,7 +48,7 @@ class LocaleManager * * @var Translator */ - private $translator; + private Translator $translator; /** * LocaleManager constructor. diff --git a/classes/Stream/PlaylistArchiveStream.php b/classes/Stream/PlaylistArchiveStream.php index 58c052f..7f57ecf 100644 --- a/classes/Stream/PlaylistArchiveStream.php +++ b/classes/Stream/PlaylistArchiveStream.php @@ -24,7 +24,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface * * @var Video[] */ - private $videos = []; + private array $videos = []; /** * Stream used to store data before it is sent to the browser. @@ -38,21 +38,21 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface * * @var StreamInterface */ - protected $curVideoStream; + protected StreamInterface $curVideoStream; /** * True if the archive is complete. * * @var bool */ - private $isComplete = false; + private bool $isComplete = false; /** * Downloader object. * * @var Downloader */ - protected $downloader; + protected Downloader $downloader; /** * PlaylistArchiveStream constructor. diff --git a/classes/Stream/YoutubeChunkStream.php b/classes/Stream/YoutubeChunkStream.php index 6632eb2..950afae 100644 --- a/classes/Stream/YoutubeChunkStream.php +++ b/classes/Stream/YoutubeChunkStream.php @@ -20,7 +20,7 @@ class YoutubeChunkStream implements StreamInterface * * @var ResponseInterface */ - private $response; + private ResponseInterface $response; /** * YoutubeChunkStream constructor. From 9564764633c049f3971e9d5474c7186243e62b7e Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Tue, 21 Mar 2023 20:25:47 +0100 Subject: [PATCH 5/6] ucfirst Smarty modifier is deprecated See https://github.com/smarty-php/smarty/issues/813 --- classes/Locale.php | 2 +- templates/inc/header.tpl | 2 +- tests/LocaleTest.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/classes/Locale.php b/classes/Locale.php index bacfc9d..2510ede 100644 --- a/classes/Locale.php +++ b/classes/Locale.php @@ -60,7 +60,7 @@ class Locale */ public function getFullName(): string { - return PHPLocale::getDisplayName($this->getIso15897(), $this->getIso15897()); + return mb_convert_case(PHPLocale::getDisplayName($this->getIso15897(), $this->getIso15897()), MB_CASE_TITLE); } /** diff --git a/templates/inc/header.tpl b/templates/inc/header.tpl index c93f4d3..bd318e3 100644 --- a/templates/inc/header.tpl +++ b/templates/inc/header.tpl @@ -18,7 +18,7 @@ {if $supportedLocale->getCountry()} {$supportedLocale->getCountry()->getEmoji()} {/if} - {$supportedLocale->getFullName()|ucfirst} + {$supportedLocale->getFullName()} {/if} diff --git a/tests/LocaleTest.php b/tests/LocaleTest.php index e5949d4..0e0167f 100644 --- a/tests/LocaleTest.php +++ b/tests/LocaleTest.php @@ -54,7 +54,7 @@ class LocaleTest extends ContainerTest */ public function testGetFullName() { - $this->assertEquals('français (France)', $this->localeObject->getFullName()); + $this->assertEquals('Français (France)', $this->localeObject->getFullName()); } /** From 3e45f19682222343b5d1a668b56dcd96484fe226 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Thu, 30 Mar 2023 21:41:08 +0200 Subject: [PATCH 6/6] Switch to yt-dlp (fixes #432) youtube-dl has no new release since 2021 --- classes/Config.php | 10 ++++++++-- composer.json | 14 +++++--------- composer.lock | 8 ++++---- config/config.example.yml | 4 +++- patches/youtube-dl-disable-generic.diff | 12 ------------ 5 files changed, 20 insertions(+), 28 deletions(-) delete mode 100644 patches/youtube-dl-disable-generic.diff diff --git a/classes/Config.php b/classes/Config.php index 5358564..8cd612b 100644 --- a/classes/Config.php +++ b/classes/Config.php @@ -24,7 +24,7 @@ class Config * * @var string */ - public string $youtubedl = 'vendor/ytdl-org/youtube-dl/youtube_dl/__main__.py'; + public string $youtubedl = 'vendor/yt-dlp/yt-dlp/yt_dlp/__main__.py'; /** * python binary path. @@ -39,7 +39,13 @@ class Config * @var string[] */ public array $params = [ - '--no-warnings', '--ignore-errors', '--flat-playlist', '--restrict-filenames', '--no-playlist' + '--no-warnings', + '--ignore-errors', + '--flat-playlist', + '--restrict-filenames', + '--no-playlist', + '--use-extractors', + 'default,-generic', ]; /** diff --git a/composer.json b/composer.json index aab1f1f..c15082c 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,7 @@ "symfony/translation": "^4.0", "symfony/yaml": "^4.0", "webfontkit/open-sans": "^1.0", - "ytdl-org/youtube-dl": "^2021.12", + "yt-dlp/yt-dlp": "^2023.03", "zonuexe/http-accept-language": "^0.4.1" }, "require-dev": { @@ -62,11 +62,11 @@ { "type": "package", "package": { - "name": "ytdl-org/youtube-dl", - "version": "2021.12.17", + "name": "yt-dlp/yt-dlp", + "version": "2023.03.04", "dist": { "type": "tar", - "url": "https://yt-dl.org/downloads/2021.12.17/youtube-dl-2021.12.17.tar.gz" + "url": "https://github.com/yt-dlp/yt-dlp/releases/download/2023.03.04/yt-dlp.tar.gz" } } } @@ -108,11 +108,7 @@ "installer-types": [ "library" ], - "patches": { - "ytdl-org/youtube-dl": { - "Disable the generic extractor": "patches/youtube-dl-disable-generic.diff" - } - } + "patches": {} }, "scripts": { "lint": "grumphp run --ansi", diff --git a/composer.lock b/composer.lock index 3a61904..b10aadf 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "454753ac2a4d31f21bf2e197b7ce24d1", + "content-hash": "02f288a60af3784e20ca7e1ba9afac4a", "packages": [ { "name": "aura/session", @@ -3772,11 +3772,11 @@ "time": "2014-08-20T20:43:34+00:00" }, { - "name": "ytdl-org/youtube-dl", - "version": "2021.12.17", + "name": "yt-dlp/yt-dlp", + "version": "2023.03.04", "dist": { "type": "tar", - "url": "https://yt-dl.org/downloads/2021.12.17/youtube-dl-2021.12.17.tar.gz" + "url": "https://github.com/yt-dlp/yt-dlp/releases/download/2023.03.04/yt-dlp.tar.gz" }, "type": "library" }, diff --git a/config/config.example.yml b/config/config.example.yml index 3ce5614..1ecfbba 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -1,6 +1,6 @@ --- # Path to your youtube-dl binary -youtubedl: vendor/ytdl-org/youtube-dl/youtube_dl/__main__.py +youtubedl: vendor/yt-dlp/yt-dlp/yt_dlp/__main__.py # Path to your python binary python: /usr/bin/python @@ -12,6 +12,8 @@ params: - --flat-playlist - --restrict-filenames - --no-playlist + - --use-extractors + - default,-generic # True to enable audio conversion convert: false diff --git a/patches/youtube-dl-disable-generic.diff b/patches/youtube-dl-disable-generic.diff deleted file mode 100644 index f02f6d4..0000000 --- a/patches/youtube-dl-disable-generic.diff +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py -index 18d8dbcd6..4d3edfac3 100644 ---- a/youtube_dl/extractor/__init__.py -+++ b/youtube_dl/extractor/__init__.py -@@ -13,7 +13,6 @@ except ImportError: - for name, klass in globals().items() - if name.endswith('IE') and name != 'GenericIE' - ] -- _ALL_CLASSES.append(GenericIE) - - - def gen_extractor_classes():