From 5b45a9206c821d1a7647f7ddeaf6aa29638d2d79 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 5 May 2023 16:05:47 +0200 Subject: [PATCH] wait #5919 @0.25 --- .docker/images/php/Dockerfile | 2 +- app/Fluidbook/Link/Link.php | 41 +++++++++- composer.lock | 137 ++++++++++++++++++++++++++++++++-- 3 files changed, 171 insertions(+), 9 deletions(-) diff --git a/.docker/images/php/Dockerfile b/.docker/images/php/Dockerfile index 85aa13198..4b890b474 100644 --- a/.docker/images/php/Dockerfile +++ b/.docker/images/php/Dockerfile @@ -83,7 +83,7 @@ ENV LC_ALL fr_FR.UTF-8 RUN cd /root;wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2;tar xvjf phantomjs-2.1.1-linux-x86_64.tar.bz2;mv phantomjs-2.1.1-linux-x86_64 /usr/local/share;ln -sf /usr/local/share/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin RUN cd /root;wget https://github.com/RazrFalcon/svgcleaner/releases/download/v0.9.5/svgcleaner_linux_x86_64_0.9.5.tar.gz; tar xvzf svgcleaner_linux_x86_64_0.9.5.tar.gz;mv svgcleaner /usr/local/bin -RUN curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp +RUN curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp && chmod 755 /usr/local/bin/yt-dlp RUN apt clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* diff --git a/app/Fluidbook/Link/Link.php b/app/Fluidbook/Link/Link.php index 71bfa13f3..8266f5fb3 100644 --- a/app/Fluidbook/Link/Link.php +++ b/app/Fluidbook/Link/Link.php @@ -19,9 +19,12 @@ use App\Fluidbook\Link\Custom\PierronLink; use App\Fluidbook\Link\Custom\WescoLink; use App\Fluidbook\Link\Custom\WescoSalesLink; use Cubist\Util\ArrayUtil; +use Cubist\Util\Files\Files; +use Cubist\Util\YoutubeDL; use Fluidbook\Tools\Links\CartLink; use Fluidbook\Tools\Links\ZoomProductLink; + class Link extends \Fluidbook\Tools\Links\Link { public static function getInstance($id, $init, &$compiler) @@ -32,7 +35,7 @@ class Link extends \Fluidbook\Tools\Links\Link $init['to'] = self::replaceCustomURL($init['to']); switch ($init['type']) { - case 7: + case Link::CUSTOM: switch ($compiler->getSetting('basketManager')) { case 'Puma': return new PumaCartLink($id, $init, $compiler); @@ -61,7 +64,7 @@ class Link extends \Fluidbook\Tools\Links\Link default : break; } - case 12: // Basket / Cart links + case Link::CART: // Basket / Cart links if ($compiler->getSetting('product_zoom_references', '') !== '') { return new zoomProductLink($id, $init, $compiler); } @@ -86,6 +89,40 @@ class Link extends \Fluidbook\Tools\Links\Link default : break; } + case Link::WEBVIDEO: + if ($compiler->getSetting('webvideoAsLocal', false)) { + switch ($init['video_service']) { + case 'youtube': + $url = 'https://www.youtube.com/watch?v=' . $init['to']; + break; + case 'dailymotion': + $url = 'https://www.dailymotion.com/video/' . $init['to']; + break; + case 'vimeo': + $url = 'https://www.vimeo.com/' . $init['to']; + break; + default: + break; + } + if (isset($url)) { + $file = YoutubeDL::downloadVideo($url, protected_path('youtubedl')); + $file = new \SplFileInfo($file); + } + if (isset($file) && file_exists($file->getPathname())) { + $init['type'] = Link::VIDEO; + $init['to'] = $file->getFilename(); + $init['video_sound_on'] = true; + $init['video_controls'] = true; + $dest = $compiler->getWorkingDir() . $file->getFilename(); + if (file_exists($dest)) { + unlink($dest); + } + symlink($file->getPathname(), $dest); + } + } + return parent::getInstance($id, $init, $compiler); + + default: break; } diff --git a/composer.lock b/composer.lock index 91c235ca7..7735bcf17 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": "405ef5be043ac66b9ba0b0a6f8e5908d", + "content-hash": "5ef081df1bbcadabd9bf56b9561f2d66", "packages": [ { "name": "ahmadshah/lucy", @@ -2098,13 +2098,13 @@ "source": { "type": "git", "url": "git://git.cubedesigners.com/cubist_util.git", - "reference": "18676401c228bfd48a6fc74c24f602e36a143bd2" + "reference": "1580562573f299560f916da3a9999eb29662a78c" }, "dist": { "type": "tar", - "url": "https://composer.cubedesigners.com/dist/cubist/util/cubist-util-dev-master-a551df.tar", - "reference": "18676401c228bfd48a6fc74c24f602e36a143bd2", - "shasum": "675fd965b43b7bf9d3bce9bef535aeaca0224b0a" + "url": "https://composer.cubedesigners.com/dist/cubist/util/cubist-util-dev-master-295bce.tar", + "reference": "1580562573f299560f916da3a9999eb29662a78c", + "shasum": "c808c6f7b74eee23eaafd92df05dd22ec8c70e63" }, "require": { "cubist/net": "dev-master", @@ -2118,6 +2118,7 @@ "ext-simplexml": "*", "ext-sodium": "*", "laravel/framework": "~5.8|^6.0|^7.0|^8.0|^9.0|^10.0", + "norkunas/youtube-dl-php": "^2.2", "php": ">=7.2" }, "default-branch": true, @@ -2137,7 +2138,7 @@ } ], "description": "Utilities class", - "time": "2023-05-04T13:49:10+00:00" + "time": "2023-05-05T13:35:12+00:00" }, { "name": "cviebrock/eloquent-sluggable", @@ -6537,6 +6538,67 @@ ], "time": "2023-01-29T18:53:47+00:00" }, + { + "name": "norkunas/youtube-dl-php", + "version": "v2.2.1", + "source": { + "type": "git", + "url": "https://github.com/norkunas/youtube-dl-php.git", + "reference": "173d5e4528cf55dcb6027869f5b9de8154330474" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/norkunas/youtube-dl-php/zipball/173d5e4528cf55dcb6027869f5b9de8154330474", + "reference": "173d5e4528cf55dcb6027869f5b9de8154330474", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": ">=7.4.0", + "symfony/filesystem": "^4.4|^5.1|^6.0", + "symfony/polyfill-php80": "^1.26", + "symfony/process": "^4.4|^5.1|^6.0" + }, + "require-dev": { + "mikey179/vfsstream": "^1.6.10", + "php-cs-fixer/shim": "^3.9", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-phpunit": "^1.1", + "symfony/phpunit-bridge": "^6.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "psr-4": { + "YoutubeDl\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Tomas Norkūnas", + "email": "norkunas.tom@gmail.com" + } + ], + "description": "youtube-dl / yt-dlp wrapper for php", + "keywords": [ + "youtube", + "youtube-dl", + "yt-dlp" + ], + "support": { + "issues": "https://github.com/norkunas/youtube-dl-php/issues", + "source": "https://github.com/norkunas/youtube-dl-php/tree/v2.2.1" + }, + "time": "2023-04-21T03:50:15+00:00" + }, { "name": "nothingworks/blade-svg", "version": "0.5.1", @@ -10395,6 +10457,69 @@ ], "time": "2023-03-01T10:32:47+00:00" }, + { + "name": "symfony/filesystem", + "version": "v6.2.10", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "fd588debf7d1bc16a2c84b4b3b71145d9946b894" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/fd588debf7d1bc16a2c84b4b3b71145d9946b894", + "reference": "fd588debf7d1bc16a2c84b4b3b71145d9946b894", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-mbstring": "~1.8" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides basic utilities for the filesystem", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/filesystem/tree/v6.2.10" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-04-18T13:46:08+00:00" + }, { "name": "symfony/finder", "version": "v5.4.21", -- 2.39.5