From fc04f6f34c0b41f09d3edc623f77c59308dc3557 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Thu, 15 Sep 2016 01:33:17 +0200 Subject: [PATCH 01/43] phpcs update --- composer.json | 2 +- composer.lock | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/composer.json b/composer.json index 7350def..635283f 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ }, "require-dev": { "symfony/var-dumper": "~3.1.0", - "squizlabs/php_codesniffer": "~2.6.2", + "squizlabs/php_codesniffer": "~2.7.0", "phpunit/phpunit": "~5.5.2" }, "extra": { diff --git a/composer.lock b/composer.lock index d782024..cb68ecb 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "a0f80c6bc52ec374622802fb83f64122", - "content-hash": "8d944e2e3dfabcc3c311c954932321f1", + "hash": "02cf80c6d4373a564269fea77fcd50a5", + "content-hash": "efbcfe87c3855d9559551638e85519f3", "packages": [ { "name": "container-interop/container-interop", @@ -759,16 +759,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.5.2", + "version": "1.5.3", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "da8529775f14f4fdae33f916eb0cf65f6afbddbc" + "reference": "94e5ca3e90aa5b34663780393e10914f7438f991" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/da8529775f14f4fdae33f916eb0cf65f6afbddbc", - "reference": "da8529775f14f4fdae33f916eb0cf65f6afbddbc", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/94e5ca3e90aa5b34663780393e10914f7438f991", + "reference": "94e5ca3e90aa5b34663780393e10914f7438f991", "shasum": "" }, "require": { @@ -797,7 +797,7 @@ "object", "object graph" ], - "time": "2016-09-06 16:07:05" + "time": "2016-09-07 15:34:10" }, { "name": "phpdocumentor/reflection-common", @@ -1903,16 +1903,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "2.6.2", + "version": "2.7.0", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "4edb770cb853def6e60c93abb088ad5ac2010c83" + "reference": "571e27b6348e5b3a637b2abc82ac0d01e6d7bbed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/4edb770cb853def6e60c93abb088ad5ac2010c83", - "reference": "4edb770cb853def6e60c93abb088ad5ac2010c83", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/571e27b6348e5b3a637b2abc82ac0d01e6d7bbed", + "reference": "571e27b6348e5b3a637b2abc82ac0d01e6d7bbed", "shasum": "" }, "require": { @@ -1977,7 +1977,7 @@ "phpcs", "standards" ], - "time": "2016-07-13 23:29:13" + "time": "2016-09-01 23:53:02" }, { "name": "symfony/polyfill-mbstring", From acfbef4a0ab9081f9f6ae7f960e285880dfa282e Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Mon, 19 Sep 2016 12:02:14 +0200 Subject: [PATCH 02/43] myclabs/deep-copy update --- composer.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.lock b/composer.lock index cb68ecb..85c84c7 100644 --- a/composer.lock +++ b/composer.lock @@ -759,16 +759,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.5.3", + "version": "1.5.4", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "94e5ca3e90aa5b34663780393e10914f7438f991" + "reference": "ea74994a3dc7f8d2f65a06009348f2d63c81e61f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/94e5ca3e90aa5b34663780393e10914f7438f991", - "reference": "94e5ca3e90aa5b34663780393e10914f7438f991", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/ea74994a3dc7f8d2f65a06009348f2d63c81e61f", + "reference": "ea74994a3dc7f8d2f65a06009348f2d63c81e61f", "shasum": "" }, "require": { @@ -797,7 +797,7 @@ "object", "object graph" ], - "time": "2016-09-07 15:34:10" + "time": "2016-09-16 13:37:59" }, { "name": "phpdocumentor/reflection-common", From 5b2cd81420b5338f15d20c52da2b4990bb3ea340 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Mon, 26 Sep 2016 01:25:00 +0200 Subject: [PATCH 03/43] phpunit update --- composer.lock | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/composer.lock b/composer.lock index 85c84c7..02d9d36 100644 --- a/composer.lock +++ b/composer.lock @@ -1253,24 +1253,24 @@ }, { "name": "phpunit/phpunit", - "version": "5.5.4", + "version": "5.5.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "3e6e88e56c912133de6e99b87728cca7ed70c5f5" + "reference": "a57126dc681b08289fef6ac96a48e30656f84350" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3e6e88e56c912133de6e99b87728cca7ed70c5f5", - "reference": "3e6e88e56c912133de6e99b87728cca7ed70c5f5", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a57126dc681b08289fef6ac96a48e30656f84350", + "reference": "a57126dc681b08289fef6ac96a48e30656f84350", "shasum": "" }, "require": { "ext-dom": "*", "ext-json": "*", - "ext-pcre": "*", - "ext-reflection": "*", - "ext-spl": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", "myclabs/deep-copy": "~1.3", "php": "^5.6 || ^7.0", "phpspec/prophecy": "^1.3.1", @@ -1292,7 +1292,12 @@ "conflict": { "phpdocumentor/reflection-docblock": "3.0.2" }, + "require-dev": { + "ext-pdo": "*" + }, "suggest": { + "ext-tidy": "*", + "ext-xdebug": "*", "phpunit/php-invoker": "~1.1" }, "bin": [ @@ -1327,7 +1332,7 @@ "testing", "xunit" ], - "time": "2016-08-26 07:11:44" + "time": "2016-09-21 14:40:13" }, { "name": "phpunit/phpunit-mock-objects", From 74278c8b29892956c50319d78891e8f1367f224f Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Wed, 5 Oct 2016 01:44:22 +0200 Subject: [PATCH 04/43] Dependencies update --- composer.lock | 60 +++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/composer.lock b/composer.lock index 02d9d36..fb050c7 100644 --- a/composer.lock +++ b/composer.lock @@ -605,16 +605,16 @@ }, { "name": "symfony/process", - "version": "v3.1.4", + "version": "v3.1.5", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "e64e93041c80e77197ace5ab9385dedb5a143697" + "reference": "66de154ae86b1a07001da9fbffd620206e4faf94" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/e64e93041c80e77197ace5ab9385dedb5a143697", - "reference": "e64e93041c80e77197ace5ab9385dedb5a143697", + "url": "https://api.github.com/repos/symfony/process/zipball/66de154ae86b1a07001da9fbffd620206e4faf94", + "reference": "66de154ae86b1a07001da9fbffd620206e4faf94", "shasum": "" }, "require": { @@ -650,20 +650,20 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2016-08-16 14:58:24" + "time": "2016-09-29 14:13:09" }, { "name": "symfony/yaml", - "version": "v3.1.4", + "version": "v3.1.5", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "f291ed25eb1435bddbe8a96caaef16469c2a092d" + "reference": "368b9738d4033c8b93454cb0dbd45d305135a6d3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/f291ed25eb1435bddbe8a96caaef16469c2a092d", - "reference": "f291ed25eb1435bddbe8a96caaef16469c2a092d", + "url": "https://api.github.com/repos/symfony/yaml/zipball/368b9738d4033c8b93454cb0dbd45d305135a6d3", + "reference": "368b9738d4033c8b93454cb0dbd45d305135a6d3", "shasum": "" }, "require": { @@ -699,7 +699,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2016-09-02 02:12:52" + "time": "2016-09-25 08:27:07" } ], "packages-dev": [ @@ -855,16 +855,16 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "3.1.0", + "version": "3.1.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "9270140b940ff02e58ec577c237274e92cd40cdd" + "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/9270140b940ff02e58ec577c237274e92cd40cdd", - "reference": "9270140b940ff02e58ec577c237274e92cd40cdd", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/8331b5efe816ae05461b7ca1e721c01b46bafb3e", + "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e", "shasum": "" }, "require": { @@ -896,7 +896,7 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2016-06-10 09:48:41" + "time": "2016-09-30 07:12:33" }, { "name": "phpdocumentor/type-resolver", @@ -1253,16 +1253,16 @@ }, { "name": "phpunit/phpunit", - "version": "5.5.5", + "version": "5.5.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "a57126dc681b08289fef6ac96a48e30656f84350" + "reference": "146e0fe0bb7f44d1cefade0c93e86fe0b206dd79" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a57126dc681b08289fef6ac96a48e30656f84350", - "reference": "a57126dc681b08289fef6ac96a48e30656f84350", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/146e0fe0bb7f44d1cefade0c93e86fe0b206dd79", + "reference": "146e0fe0bb7f44d1cefade0c93e86fe0b206dd79", "shasum": "" }, "require": { @@ -1332,20 +1332,20 @@ "testing", "xunit" ], - "time": "2016-09-21 14:40:13" + "time": "2016-10-03 07:48:45" }, { "name": "phpunit/phpunit-mock-objects", - "version": "3.2.7", + "version": "3.3.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "546898a2c0c356ef2891b39dd7d07f5d82c8ed0a" + "reference": "03500345483e1e17b52e2e4d34a89c9408ab2902" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/546898a2c0c356ef2891b39dd7d07f5d82c8ed0a", - "reference": "546898a2c0c356ef2891b39dd7d07f5d82c8ed0a", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/03500345483e1e17b52e2e4d34a89c9408ab2902", + "reference": "03500345483e1e17b52e2e4d34a89c9408ab2902", "shasum": "" }, "require": { @@ -1391,7 +1391,7 @@ "mock", "xunit" ], - "time": "2016-09-06 16:07:45" + "time": "2016-10-04 11:03:26" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -2045,16 +2045,16 @@ }, { "name": "symfony/var-dumper", - "version": "v3.1.4", + "version": "v3.1.5", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "62ee73706c421654a4c840028954510277f7dfc8" + "reference": "70bfe927b86ba9999aeebd829715b0bb2cd39a10" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/62ee73706c421654a4c840028954510277f7dfc8", - "reference": "62ee73706c421654a4c840028954510277f7dfc8", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/70bfe927b86ba9999aeebd829715b0bb2cd39a10", + "reference": "70bfe927b86ba9999aeebd829715b0bb2cd39a10", "shasum": "" }, "require": { @@ -2104,7 +2104,7 @@ "debug", "dump" ], - "time": "2016-08-31 09:05:42" + "time": "2016-09-29 14:13:09" }, { "name": "webmozart/assert", From fe6dc616f6b1fda2f7b0450092a8c80555bb1da8 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Wed, 5 Oct 2016 17:08:46 +0200 Subject: [PATCH 05/43] Lint --- FAQ.md | 9 +++++++++ README.md | 20 ++++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/FAQ.md b/FAQ.md index 52c7ed6..4408477 100644 --- a/FAQ.md +++ b/FAQ.md @@ -1,12 +1,17 @@ # Frequently asked questions + + ## My browser plays the video. How do I download it? + Most recent browsers automatically play a video if it is a format they know how to play. You can ususally download the video by doing *File > Save to* or *ctrl + S*. ## How do I change config parameters? + You need to create a YAML file called `config.yml` at the root of your project. Here are the parameters that you can set: + * youtubedl: path to your youtube-dl binary * python: path to your python binary * params: an array of parameters to pass to youtube-dl @@ -18,12 +23,16 @@ Here are the parameters that you can set: See [config.example.yml](config.example.yml) for default values. ## How do I enable audio conversion? + In order to enable audio conversion, you need to add this to your `config.yml` file: + ```yaml convert: true avconv: path/to/avconv ``` + You will also need to install `avconv` and `curl` on your server: + ```bash sudo apt-get install libav-tools curl ``` diff --git a/README.md b/README.md index 483b269..b659c3d 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,21 @@ -Alltube Download -======= +# Alltube Download -HTML GUI for youtube-dl (http://alltubedownload.net/) +HTML GUI for youtube-dl ([alltubedownload.net](http://alltubedownload.net/)) ![Screenshot](img/screenshot.png "Alltube GUI screenshot") ## Setup ### From a release package + You can download the latest release package [here](https://github.com/Rudloff/alltube/releases). You just have to unzip it on your server and it should be ready to use. ### From Git + In order to get AllTube working, you need to use [npm](https://www.npmjs.com/) and [Composer](https://getcomposer.org/): + ```bash npm install composer install @@ -24,6 +26,7 @@ This will download all the required dependencies. (Note that it will download the ffmpeg binary for 64-bits Linux. If you are on another platform, you might want to specify the path to avconv/ffmpeg in your config file.) You should also ensure that the *templates_c* folder has the right permissions: + ```bash chmod 777 templates_c/ ``` @@ -33,19 +36,24 @@ If your web server is Apache, you need to set the `AllowOverride` setting to `Al ## Config If you want to use a custom config, you need to create a config file: + ```bash cp config.example.yml config.yml ``` ## Web server configuration + ### Apache + You will need the following modules: * mod_mime * mod_rewrite ### Nginx + Here is an exemple Nginx configuration: + ```nginx server { server_name localhost; @@ -94,16 +102,20 @@ server { ``` ## License + This software is available under the [GNU General Public License](http://www.gnu.org/licenses/gpl.html). -__Please use a different name and logo if you run it on a public server.__ +Please __use a different name and logo__ if you run it on a public server. ## Other dependencies + You need [avconv](https://libav.org/avconv.html), [rtmpdump](http://rtmpdump.mplayerhq.hu/) and [curl](https://curl.haxx.se/) in order to enable conversions. If you don't want to enable conversions, you can disable it in *config.yml*. On Debian-based systems: + ```bash sudo apt-get install libav-tools rtmpdump curl ``` + You also probably need to edit the *avconv* variable in *config.yml* so that it points to your ffmpeg/avconv binary (*/usr/bin/avconv* on Debian/Ubuntu). From 99c51b6fcc39c79a218073f50d8b731b08c5beb2 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Wed, 5 Oct 2016 17:16:28 +0200 Subject: [PATCH 06/43] Add Heroku instructions to FAQ --- FAQ.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/FAQ.md b/FAQ.md index 4408477..276dfc5 100644 --- a/FAQ.md +++ b/FAQ.md @@ -36,3 +36,12 @@ You will also need to install `avconv` and `curl` on your server: ```bash sudo apt-get install libav-tools curl ``` + +## How do I deploy Alltube on Heroku? + +Create a dyno with the following buildpacks: + +* `heroku/php` +* `https://github.com/heroku/heroku-buildpack-nodejs` + +Then push the code to Heroku and it should work out of the box. From a4eb9ba2fedceb275e775896884d3cdb30661045 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Sun, 9 Oct 2016 11:41:09 +0200 Subject: [PATCH 07/43] Add PHP requirements in README --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index b659c3d..50e5de7 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,15 @@ If you want to use a custom config, you need to create a config file: cp config.example.yml config.yml ``` +## PHP requirements + +You will need PHP 5.5 (or higher) and the following PHP modules: + +* fileinfo +* intl +* mbstring +* curl + ## Web server configuration ### Apache From 4276a3b553b932cf7f4f7cd1030deff4fca8f957 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Mon, 10 Oct 2016 17:05:36 +0200 Subject: [PATCH 08/43] Add info about feature/stream branch in FAQ --- FAQ.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/FAQ.md b/FAQ.md index 276dfc5..1bfb336 100644 --- a/FAQ.md +++ b/FAQ.md @@ -45,3 +45,13 @@ Create a dyno with the following buildpacks: * `https://github.com/heroku/heroku-buildpack-nodejs` Then push the code to Heroku and it should work out of the box. + +## Why can't I download videos from some websites (e.g. Dailymotion) + +Some websites generate an unique video URL for each IP address. When using Alltube, the URL is generated for our server's IP address and your computer is not allowed to use it. + +There are two known workarounds: + +* You can run Alltube locally on your computer. +* You can use the experimental `feature/stream` branch which streams the video through the server in order to bypass IP restrictions. + Please note that this can use a lot of resources on the server (which is why we won't enable it on alltubedownload.net). From 793aa9f5349ad03e0a4b484b179e435165ba1ea5 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Mon, 10 Oct 2016 17:07:19 +0200 Subject: [PATCH 09/43] Add link to FAQ in README Use ` instead of * in markdown --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 50e5de7..63fea97 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ Please __use a different name and logo__ if you run it on a public server. ## Other dependencies You need [avconv](https://libav.org/avconv.html), [rtmpdump](http://rtmpdump.mplayerhq.hu/) and [curl](https://curl.haxx.se/) in order to enable conversions. -If you don't want to enable conversions, you can disable it in *config.yml*. +If you don't want to enable conversions, you can disable it in `config.yml`. On Debian-based systems: @@ -127,4 +127,8 @@ On Debian-based systems: sudo apt-get install libav-tools rtmpdump curl ``` -You also probably need to edit the *avconv* variable in *config.yml* so that it points to your ffmpeg/avconv binary (*/usr/bin/avconv* on Debian/Ubuntu). +You also probably need to edit the `avconv` variable in `config.yml` so that it points to your ffmpeg/avconv binary (`/usr/bin/avconv` on Debian/Ubuntu). + +## FAQ + +Please read the [FAQ](FAQ.md) before reporting any issue. From 1b5054159cec4124da530141902f7143678ab7a3 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Mon, 10 Oct 2016 21:30:07 +0200 Subject: [PATCH 10/43] Cast bool because getenv always returns string --- classes/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/Config.php b/classes/Config.php index 208e85b..674717b 100644 --- a/classes/Config.php +++ b/classes/Config.php @@ -100,7 +100,7 @@ class Config } } if (getenv('CONVERT')) { - $this->convert = getenv('CONVERT'); + $this->convert = (bool) getenv('CONVERT'); } } From 6db29d325ea22f0623bac7eb3d3ab1e667c5eed9 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Mon, 10 Oct 2016 21:32:07 +0200 Subject: [PATCH 11/43] Undeclared class properties --- classes/VideoDownload.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/classes/VideoDownload.php b/classes/VideoDownload.php index e497113..c7aba78 100644 --- a/classes/VideoDownload.php +++ b/classes/VideoDownload.php @@ -12,6 +12,9 @@ use Symfony\Component\Process\ProcessBuilder; */ class VideoDownload { + private $config; + private $procBuilder; + /** * VideoDownload constructor. */ From 7746d7d26a5d2094c3c36c0edbe300fa7f4d8ced Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Mon, 10 Oct 2016 21:34:38 +0200 Subject: [PATCH 12/43] addSlimPlugins is deprecated --- index.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index 0653081..f9fdd7d 100644 --- a/index.php +++ b/index.php @@ -13,7 +13,10 @@ $container = $app->getContainer(); $container['view'] = function ($c) { $view = new \Slim\Views\Smarty(__DIR__.'/templates/'); - $view->addSlimPlugins($c['router'], $c['request']->getUri()); + $smartyPlugins = new \Slim\Views\SmartyPlugins($c['router'], $c['request']->getUri()); + $view->registerPlugin('function', 'path_for', [$smartyPlugins, 'pathFor']); + $view->registerPlugin('function', 'base_url', [$smartyPlugins, 'baseUrl']); + $view->registerPlugin('modifier', 'noscheme', 'Smarty_Modifier_noscheme'); From 98839d277e7ea9efe2ca12555122b003968c84e6 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Thu, 13 Oct 2016 14:41:47 +0200 Subject: [PATCH 13/43] We need npm 3 (see #72) --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index 894e62f..eb8b13b 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,9 @@ "grunt-phpdocumentor": "~0.4.1", "grunt-phpunit": "~0.3.6" }, + "engines": { + "npm": "~3" + }, "homepage": "https://www.alltubedownload.net/", "keywords": [ "alltube", From 5de8e9d8cc9e1f59996fc87d3004b6d34597103f Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Thu, 13 Oct 2016 16:34:57 +0200 Subject: [PATCH 14/43] Use interface instead of concrete classe --- controllers/FrontController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/FrontController.php b/controllers/FrontController.php index 2348db8..5b36dbb 100644 --- a/controllers/FrontController.php +++ b/controllers/FrontController.php @@ -6,7 +6,7 @@ namespace Alltube\Controller; use Alltube\Config; use Alltube\VideoDownload; -use Slim\Container; +use Interop\Container\ContainerInterface; use Slim\Http\Request; use Slim\Http\Response; use Slim\Http\Stream; @@ -42,7 +42,7 @@ class FrontController * * @param Container $container Slim dependency container */ - public function __construct(Container $container) + public function __construct(ContainerInterface $container) { $this->config = Config::getInstance(); $this->download = new VideoDownload(); From 9ad024888ab2273734f71d214e811ad6a2d960d5 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Thu, 13 Oct 2016 16:40:19 +0200 Subject: [PATCH 15/43] Refactor getter classes --- classes/VideoDownload.php | 83 ++++++++++++++------------------------- 1 file changed, 29 insertions(+), 54 deletions(-) diff --git a/classes/VideoDownload.php b/classes/VideoDownload.php index c7aba78..39fa401 100644 --- a/classes/VideoDownload.php +++ b/classes/VideoDownload.php @@ -48,47 +48,11 @@ class VideoDownload return explode(PHP_EOL, trim($process->getOutput())); } - /** - * Get all information about a video. - * - * @param string $url URL of page - * @param string $format Format to use for the video - * - * @return object Decoded JSON - * */ - public function getJSON($url, $format = null) + private function getProp($url, $format = null, $prop = 'dump-json') { $this->procBuilder->setArguments( [ - '--dump-json', - $url, - ] - ); - if (isset($format)) { - $this->procBuilder->add('-f '.$format); - } - $process = $this->procBuilder->getProcess(); - $process->run(); - if (!$process->isSuccessful()) { - throw new \Exception($process->getErrorOutput()); - } else { - return json_decode($process->getOutput()); - } - } - - /** - * Get URL of video from URL of page. - * - * @param string $url URL of page - * @param string $format Format to use for the video - * - * @return string URL of video - * */ - public function getURL($url, $format = null) - { - $this->procBuilder->setArguments( - [ - '--get-url', + '--'.$prop, $url, ] ); @@ -104,6 +68,32 @@ class VideoDownload } } + /** + * Get all information about a video. + * + * @param string $url URL of page + * @param string $format Format to use for the video + * + * @return object Decoded JSON + * */ + public function getJSON($url, $format = null) + { + return json_decode($this->getProp($url, $format, 'dump-json')); + } + + /** + * Get URL of video from URL of page. + * + * @param string $url URL of page + * @param string $format Format to use for the video + * + * @return string URL of video + * */ + public function getURL($url, $format = null) + { + return $this->getProp($url, $format, 'get-url'); + } + /** * Get filename of video file from URL of page. * @@ -114,22 +104,7 @@ class VideoDownload * */ public function getFilename($url, $format = null) { - $this->procBuilder->setArguments( - [ - '--get-filename', - $url, - ] - ); - if (isset($format)) { - $this->procBuilder->add('-f '.$format); - } - $process = $this->procBuilder->getProcess(); - $process->run(); - if (!$process->isSuccessful()) { - throw new \Exception($process->getErrorOutput()); - } else { - return trim($process->getOutput()); - } + return trim($this->getProp($url, $format, 'get-filename')); } /** From 41b9be34c5653a99020c8f6f92f595adb1e85fc8 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Thu, 13 Oct 2016 16:53:23 +0200 Subject: [PATCH 16/43] Wrong class in doc comment --- controllers/FrontController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/FrontController.php b/controllers/FrontController.php index 5b36dbb..0a6bdf1 100644 --- a/controllers/FrontController.php +++ b/controllers/FrontController.php @@ -33,7 +33,7 @@ class FrontController /** * Slim dependency container. * - * @var Container + * @var ContainerInterface */ private $container; From 3a31cc0008f2cf5daa4852c14f287cb78ef44aed Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Thu, 13 Oct 2016 17:02:41 +0200 Subject: [PATCH 17/43] Check that we have a Slim container --- controllers/FrontController.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/controllers/FrontController.php b/controllers/FrontController.php index 0a6bdf1..aabd740 100644 --- a/controllers/FrontController.php +++ b/controllers/FrontController.php @@ -7,6 +7,7 @@ namespace Alltube\Controller; use Alltube\Config; use Alltube\VideoDownload; use Interop\Container\ContainerInterface; +use Slim\Container; use Slim\Http\Request; use Slim\Http\Response; use Slim\Http\Stream; @@ -46,7 +47,9 @@ class FrontController { $this->config = Config::getInstance(); $this->download = new VideoDownload(); - $this->container = $container; + if ($container instanceof Container) { + $this->container = $container; + } } /** From bb1ae6573302ed77cd2de9941fed75f49a9728b5 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Thu, 13 Oct 2016 17:08:51 +0200 Subject: [PATCH 18/43] phpunit update --- composer.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/composer.lock b/composer.lock index fb050c7..541e11f 100644 --- a/composer.lock +++ b/composer.lock @@ -1253,16 +1253,16 @@ }, { "name": "phpunit/phpunit", - "version": "5.5.6", + "version": "5.5.7", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "146e0fe0bb7f44d1cefade0c93e86fe0b206dd79" + "reference": "3f67cee782c9abfaee5e32fd2f57cdd54bc257ba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/146e0fe0bb7f44d1cefade0c93e86fe0b206dd79", - "reference": "146e0fe0bb7f44d1cefade0c93e86fe0b206dd79", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3f67cee782c9abfaee5e32fd2f57cdd54bc257ba", + "reference": "3f67cee782c9abfaee5e32fd2f57cdd54bc257ba", "shasum": "" }, "require": { @@ -1332,20 +1332,20 @@ "testing", "xunit" ], - "time": "2016-10-03 07:48:45" + "time": "2016-10-03 13:04:15" }, { "name": "phpunit/phpunit-mock-objects", - "version": "3.3.1", + "version": "3.4.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "03500345483e1e17b52e2e4d34a89c9408ab2902" + "reference": "238d7a2723bce689c79eeac9c7d5e1d623bb9dc2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/03500345483e1e17b52e2e4d34a89c9408ab2902", - "reference": "03500345483e1e17b52e2e4d34a89c9408ab2902", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/238d7a2723bce689c79eeac9c7d5e1d623bb9dc2", + "reference": "238d7a2723bce689c79eeac9c7d5e1d623bb9dc2", "shasum": "" }, "require": { @@ -1391,7 +1391,7 @@ "mock", "xunit" ], - "time": "2016-10-04 11:03:26" + "time": "2016-10-09 07:01:45" }, { "name": "sebastian/code-unit-reverse-lookup", From 7e33bf29ebc4860250b68c7603bdfa52008e962e Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Thu, 13 Oct 2016 17:16:22 +0200 Subject: [PATCH 19/43] Make sure container has a view property --- controllers/FrontController.php | 90 ++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 42 deletions(-) diff --git a/controllers/FrontController.php b/controllers/FrontController.php index aabd740..2faa080 100644 --- a/controllers/FrontController.php +++ b/controllers/FrontController.php @@ -47,9 +47,7 @@ class FrontController { $this->config = Config::getInstance(); $this->download = new VideoDownload(); - if ($container instanceof Container) { - $this->container = $container; - } + $this->container = $container; } /** @@ -62,15 +60,17 @@ class FrontController */ public function index(Request $request, Response $response) { - $this->container->view->render( - $response, - 'index.tpl', - [ - 'convert' => $this->config->convert, - 'class' => 'index', - 'description' => 'Easily download videos from Youtube, Dailymotion, Vimeo and other websites.', - ] - ); + if ($this->container instanceof Container) { + $this->container->view->render( + $response, + 'index.tpl', + [ + 'convert' => $this->config->convert, + 'class' => 'index', + 'description' => 'Easily download videos from Youtube, Dailymotion, Vimeo and other websites.', + ] + ); + } } /** @@ -83,17 +83,19 @@ class FrontController */ public function extractors(Request $request, Response $response) { - $this->container->view->render( - $response, - 'extractors.tpl', - [ - 'extractors' => $this->download->listExtractors(), - 'class' => 'extractors', - 'title' => 'Supported websites', - 'description' => 'List of all supported websites from which Alltube Download '. - 'can extract video or audio files', - ] - ); + if ($this->container instanceof Container) { + $this->container->view->render( + $response, + 'extractors.tpl', + [ + 'extractors' => $this->download->listExtractors(), + 'class' => 'extractors', + 'title' => 'Supported websites', + 'description' => 'List of all supported websites from which Alltube Download '. + 'can extract video or audio files', + ] + ); + } } /** @@ -131,16 +133,18 @@ class FrontController } } else { $video = $this->download->getJSON($params['url']); - $this->container->view->render( - $response, - 'video.tpl', - [ - 'video' => $video, - 'class' => 'video', - 'title' => $video->title, - 'description' => 'Download "'.$video->title.'" from '.$video->extractor_key, - ] - ); + if ($this->container instanceof Container) { + $this->container->view->render( + $response, + 'video.tpl', + [ + 'video' => $video, + 'class' => 'video', + 'title' => $video->title, + 'description' => 'Download "'.$video->title.'" from '.$video->extractor_key, + ] + ); + } } } else { return $response->withRedirect($this->container->get('router')->pathFor('index')); @@ -158,15 +162,17 @@ class FrontController */ public function error(Request $request, Response $response, \Exception $exception) { - $this->container->view->render( - $response, - 'error.tpl', - [ - 'errors' => $exception->getMessage(), - 'class' => 'video', - 'title' => 'Error', - ] - ); + if ($container instanceof Container) { + $this->container->view->render( + $response, + 'error.tpl', + [ + 'errors' => $exception->getMessage(), + 'class' => 'video', + 'title' => 'Error', + ] + ); + } return $response->withStatus(500); } From 1be7606aa290d7673fe5d5c220f6fac7989cb4ac Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Thu, 13 Oct 2016 17:29:31 +0200 Subject: [PATCH 20/43] Undefined variable --- controllers/FrontController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/FrontController.php b/controllers/FrontController.php index 2faa080..d6b71e6 100644 --- a/controllers/FrontController.php +++ b/controllers/FrontController.php @@ -162,7 +162,7 @@ class FrontController */ public function error(Request $request, Response $response, \Exception $exception) { - if ($container instanceof Container) { + if ($this->container instanceof Container) { $this->container->view->render( $response, 'error.tpl', From 2b0f0a67408fd2c9c94eaa6787adea501cc1e8d4 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Fri, 14 Oct 2016 02:40:33 +0200 Subject: [PATCH 21/43] Missing doc comments --- classes/VideoDownload.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/classes/VideoDownload.php b/classes/VideoDownload.php index 39fa401..1c6e448 100644 --- a/classes/VideoDownload.php +++ b/classes/VideoDownload.php @@ -12,7 +12,16 @@ use Symfony\Component\Process\ProcessBuilder; */ class VideoDownload { + /** + * Config instance + * @var Config + */ private $config; + + /** + * ProcessBuilder instance used to call Python + * @var ProcessBuilder + */ private $procBuilder; /** @@ -48,6 +57,13 @@ class VideoDownload return explode(PHP_EOL, trim($process->getOutput())); } + /** + * Get a property from youtube-dl + * @param string $url URL to parse + * @param string $format Format + * @param string $prop Property + * @return string + */ private function getProp($url, $format = null, $prop = 'dump-json') { $this->procBuilder->setArguments( From 5d9a6873b69a2a52358084a174c7d5f6ce4e478a Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Fri, 14 Oct 2016 00:40:57 +0000 Subject: [PATCH 22/43] Applied fixes from StyleCI --- classes/VideoDownload.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/classes/VideoDownload.php b/classes/VideoDownload.php index 1c6e448..188432d 100644 --- a/classes/VideoDownload.php +++ b/classes/VideoDownload.php @@ -13,13 +13,15 @@ use Symfony\Component\Process\ProcessBuilder; class VideoDownload { /** - * Config instance + * Config instance. + * * @var Config */ private $config; /** - * ProcessBuilder instance used to call Python + * ProcessBuilder instance used to call Python. + * * @var ProcessBuilder */ private $procBuilder; @@ -58,10 +60,12 @@ class VideoDownload } /** - * Get a property from youtube-dl - * @param string $url URL to parse - * @param string $format Format - * @param string $prop Property + * Get a property from youtube-dl. + * + * @param string $url URL to parse + * @param string $format Format + * @param string $prop Property + * * @return string */ private function getProp($url, $format = null, $prop = 'dump-json') From b0cdbd41edcc007c3770aeec241b62972358f243 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Fri, 14 Oct 2016 19:01:51 +0200 Subject: [PATCH 23/43] Refactor code --- classes/VideoDownload.php | 123 ++++++++++++++++++++++---------------- 1 file changed, 71 insertions(+), 52 deletions(-) diff --git a/classes/VideoDownload.php b/classes/VideoDownload.php index 188432d..3eed861 100644 --- a/classes/VideoDownload.php +++ b/classes/VideoDownload.php @@ -147,6 +147,75 @@ class VideoDownload ); } + /** + * Get a process that runs rtmp in order to download a video + * @param object $video Video object returned by youtube-dl + * @return \Symfony\Component\Process\Process Process + */ + private function getRtmpProcess($video) + { + if (!shell_exec('which '.$this->config->rtmpdump)) { + throw(new \Exception('Can\'t find rtmpdump')); + } + $builder = new ProcessBuilder( + [ + $this->config->rtmpdump, + '-q', + '-r', + $video->url, + '--pageUrl', $video->webpage_url, + ] + ); + if (isset($video->player_url)) { + $builder->add('--swfVfy'); + $builder->add($video->player_url); + } + if (isset($video->flash_version)) { + $builder->add('--flashVer'); + $builder->add($video->flash_version); + } + if (isset($video->play_path)) { + $builder->add('--playpath'); + $builder->add($video->play_path); + } + if (isset($video->rtmp_conn)) { + foreach ($video->rtmp_conn as $conn) { + $builder->add('--conn'); + $builder->add($conn); + } + } + if (isset($video->app)) { + $builder->add('--app'); + $builder->add($video->app); + } + return $builder->getProcess(); + } + + /** + * Get a process that runs curl in order to download a video + * @param object $video Video object returned by youtube-dl + * @return \Symfony\Component\Process\Process Process + */ + private function getCurlProcess($video) + { + if (!shell_exec('which '.$this->config->curl)) { + throw(new \Exception('Can\'t find curl')); + } + $builder = ProcessBuilder::create( + array_merge( + [ + $this->config->curl, + '--silent', + '--location', + '--user-agent', $video->http_headers->{'User-Agent'}, + $video->url, + ], + $this->config->curl_params + ) + ); + return $builder->getProcess(); + } + /** * Get audio stream of converted video. * @@ -180,60 +249,10 @@ class VideoDownload ); if (parse_url($video->url, PHP_URL_SCHEME) == 'rtmp') { - if (!shell_exec('which '.$this->config->rtmpdump)) { - throw(new \Exception('Can\'t find rtmpdump')); - } - $builder = new ProcessBuilder( - [ - $this->config->rtmpdump, - '-q', - '-r', - $video->url, - '--pageUrl', $video->webpage_url, - ] - ); - if (isset($video->player_url)) { - $builder->add('--swfVfy'); - $builder->add($video->player_url); - } - if (isset($video->flash_version)) { - $builder->add('--flashVer'); - $builder->add($video->flash_version); - } - if (isset($video->play_path)) { - $builder->add('--playpath'); - $builder->add($video->play_path); - } - if (isset($video->rtmp_conn)) { - foreach ($video->rtmp_conn as $conn) { - $builder->add('--conn'); - $builder->add($conn); - } - } - if (isset($video->app)) { - $builder->add('--app'); - $builder->add($video->app); - } - $chain = new Chain($builder->getProcess()); + $chain = new Chain($this->getRtmpProcess($video)); $chain->add('|', $avconvProc); } else { - if (!shell_exec('which '.$this->config->curl)) { - throw(new \Exception('Can\'t find curl')); - } - $chain = new Chain( - ProcessBuilder::create( - array_merge( - [ - $this->config->curl, - '--silent', - '--location', - '--user-agent', $video->http_headers->{'User-Agent'}, - $video->url, - ], - $this->config->curl_params - ) - ) - ); + $chain = new Chain($this->getCurlProcess($video)); $chain->add('|', $avconvProc); } From fdc746a69d507fcaf26d41ac5d0c7a31b308ed50 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Fri, 14 Oct 2016 17:02:14 +0000 Subject: [PATCH 24/43] Applied fixes from StyleCI --- classes/VideoDownload.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/classes/VideoDownload.php b/classes/VideoDownload.php index 3eed861..a4c589d 100644 --- a/classes/VideoDownload.php +++ b/classes/VideoDownload.php @@ -148,8 +148,10 @@ class VideoDownload } /** - * Get a process that runs rtmp in order to download a video - * @param object $video Video object returned by youtube-dl + * Get a process that runs rtmp in order to download a video. + * + * @param object $video Video object returned by youtube-dl + * * @return \Symfony\Component\Process\Process Process */ private function getRtmpProcess($video) @@ -188,12 +190,15 @@ class VideoDownload $builder->add('--app'); $builder->add($video->app); } + return $builder->getProcess(); } /** - * Get a process that runs curl in order to download a video - * @param object $video Video object returned by youtube-dl + * Get a process that runs curl in order to download a video. + * + * @param object $video Video object returned by youtube-dl + * * @return \Symfony\Component\Process\Process Process */ private function getCurlProcess($video) @@ -213,6 +218,7 @@ class VideoDownload $this->config->curl_params ) ); + return $builder->getProcess(); } From b4d3b9d88b64ab3224accb281daa77e00145aee3 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Fri, 14 Oct 2016 19:16:52 +0200 Subject: [PATCH 25/43] Duplicate code --- classes/VideoDownload.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/classes/VideoDownload.php b/classes/VideoDownload.php index a4c589d..ddc1fa3 100644 --- a/classes/VideoDownload.php +++ b/classes/VideoDownload.php @@ -255,12 +255,12 @@ class VideoDownload ); if (parse_url($video->url, PHP_URL_SCHEME) == 'rtmp') { - $chain = new Chain($this->getRtmpProcess($video)); - $chain->add('|', $avconvProc); + $process = $this->getRtmpProcess($video); } else { - $chain = new Chain($this->getCurlProcess($video)); - $chain->add('|', $avconvProc); + $process = $this->getCurlProcess($video); } + $chain = new Chain($process); + $chain->add('|', $avconvProc); return popen($chain->getProcess()->getCommandLine(), 'r'); } From 7d930d5083015ef70c91c01ea69ff02de6cf4111 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Sat, 15 Oct 2016 16:18:04 +0200 Subject: [PATCH 26/43] Code refactoring --- classes/VideoDownload.php | 48 +++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/classes/VideoDownload.php b/classes/VideoDownload.php index ddc1fa3..5124aca 100644 --- a/classes/VideoDownload.php +++ b/classes/VideoDownload.php @@ -147,6 +147,32 @@ class VideoDownload ); } + /** + * Add options to a process builder running rtmp. + * + * @param ProcessBuilder $builder Process builder + * @param object $video Video object returned by youtube-dl + * + * @return ProcessBuilder + */ + private function addOptionsToRtmpProcess(ProcessBuilder $builder, $video) + { + foreach ([ + 'url' => 'rtmp', + 'webpage_url' => 'pageUrl', + 'player_url' => 'swfVfy', + 'flash_version' => 'flashVer', + 'play_path' => 'playpath', + 'app' => 'app', + ] as $property => $option) { + if (isset($video->{$property})) { + $builder->add('--'.$option); + $builder->add($video->{$property}); + } + } + return $builder; + } + /** * Get a process that runs rtmp in order to download a video. * @@ -162,34 +188,16 @@ class VideoDownload $builder = new ProcessBuilder( [ $this->config->rtmpdump, - '-q', - '-r', - $video->url, - '--pageUrl', $video->webpage_url, + '-q' ] ); - if (isset($video->player_url)) { - $builder->add('--swfVfy'); - $builder->add($video->player_url); - } - if (isset($video->flash_version)) { - $builder->add('--flashVer'); - $builder->add($video->flash_version); - } - if (isset($video->play_path)) { - $builder->add('--playpath'); - $builder->add($video->play_path); - } + $builder = $this->addOptionsToRtmpProcess($builder, $video); if (isset($video->rtmp_conn)) { foreach ($video->rtmp_conn as $conn) { $builder->add('--conn'); $builder->add($conn); } } - if (isset($video->app)) { - $builder->add('--app'); - $builder->add($video->app); - } return $builder->getProcess(); } From 21967b77fbd59094e6af6009039980235de4c06f Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Sat, 15 Oct 2016 14:20:54 +0000 Subject: [PATCH 27/43] Applied fixes from StyleCI --- classes/VideoDownload.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/classes/VideoDownload.php b/classes/VideoDownload.php index 5124aca..498a56b 100644 --- a/classes/VideoDownload.php +++ b/classes/VideoDownload.php @@ -170,6 +170,7 @@ class VideoDownload $builder->add($video->{$property}); } } + return $builder; } @@ -188,7 +189,7 @@ class VideoDownload $builder = new ProcessBuilder( [ $this->config->rtmpdump, - '-q' + '-q', ] ); $builder = $this->addOptionsToRtmpProcess($builder, $video); From eedaa338a94ecc5c5fbe1f385f9930c24911d44c Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Mon, 17 Oct 2016 11:22:53 +0200 Subject: [PATCH 28/43] Add instructions for missing CSS and JS files in FAQ --- FAQ.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/FAQ.md b/FAQ.md index 1bfb336..2a79dbf 100644 --- a/FAQ.md +++ b/FAQ.md @@ -55,3 +55,11 @@ There are two known workarounds: * You can run Alltube locally on your computer. * You can use the experimental `feature/stream` branch which streams the video through the server in order to bypass IP restrictions. Please note that this can use a lot of resources on the server (which is why we won't enable it on alltubedownload.net). + +## CSS and JavaScript files are missing + +You probably don't have the minified files (in the `dist` folder). +You need to either: + +* Use a [release package](https://github.com/Rudloff/alltube/releases) +* Run `npm install` (see detailed instructions in the [README](README.md#from-git)) From 0d2d1cd54836d989b09ea62345a675ff0884501f Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Tue, 18 Oct 2016 09:17:16 +0200 Subject: [PATCH 29/43] ffmpeg and youtube-dl should be dev dependencies as they can be installed from elsewhere --- .travis.yml | 2 +- composer.json | 6 +++--- composer.lock | 52 +++++++++++++++++++++++++-------------------------- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9f514fb..3ffe9d7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: php install: - - composer install --no-dev + - composer install before_install: - composer selfupdate after_success: diff --git a/composer.json b/composer.json index 635283f..b6c5a26 100644 --- a/composer.json +++ b/composer.json @@ -6,20 +6,20 @@ "type": "project", "require": { "smarty/smarty": "~3.1.29", - "rg3/youtube-dl": "~2016.09.08", "slim/slim": "~3.5.0", "mathmarques/smarty-view": "~1.1.0", "symfony/yaml": "~3.1.0", "symfony/process": "~3.1.0", "ptachoire/process-builder-chain": "~1.2.0", - "ffmpeg/ffmpeg": "dev-release", "rudloff/smarty-plugin-noscheme": "~0.1.0", "rudloff/rtmpdump-bin": "~2.3" }, "require-dev": { "symfony/var-dumper": "~3.1.0", "squizlabs/php_codesniffer": "~2.7.0", - "phpunit/phpunit": "~5.5.2" + "phpunit/phpunit": "~5.5.2", + "ffmpeg/ffmpeg": "dev-release", + "rg3/youtube-dl": "~2016.09.08" }, "extra": { "paas": { diff --git a/composer.lock b/composer.lock index 541e11f..70bb48c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "02cf80c6d4373a564269fea77fcd50a5", - "content-hash": "efbcfe87c3855d9559551638e85519f3", + "hash": "186f884cc6378240af71c2f966772e91", + "content-hash": "f247f0e474ec96305a224fdce94e0dae", "packages": [ { "name": "container-interop/container-interop", @@ -34,20 +34,6 @@ "description": "Promoting the interoperability of container objects (DIC, SL, etc.)", "time": "2014-12-30 15:22:37" }, - { - "name": "ffmpeg/ffmpeg", - "version": "dev-release", - "dist": { - "type": "xz", - "url": "http://johnvansickle.com/ffmpeg/releases/ffmpeg-release-64bit-static.tar.xz", - "reference": null, - "shasum": null - }, - "bin": [ - "ffmpeg" - ], - "type": "library" - }, { "name": "jeremykendall/php-domain-parser", "version": "3.0.0", @@ -399,16 +385,6 @@ "description": "Add ability to chain symfony processes", "time": "2016-04-10 08:33:20" }, - { - "name": "rg3/youtube-dl", - "version": "2016.09.08", - "source": { - "type": "git", - "url": "https://github.com/rg3/youtube-dl.git", - "reference": "2016.09.08" - }, - "type": "library" - }, { "name": "rudloff/rtmpdump-bin", "version": "2.3", @@ -757,6 +733,20 @@ ], "time": "2015-06-14 21:17:01" }, + { + "name": "ffmpeg/ffmpeg", + "version": "dev-release", + "dist": { + "type": "xz", + "url": "http://johnvansickle.com/ffmpeg/releases/ffmpeg-release-64bit-static.tar.xz", + "reference": null, + "shasum": null + }, + "bin": [ + "ffmpeg" + ], + "type": "library" + }, { "name": "myclabs/deep-copy", "version": "1.5.4", @@ -1393,6 +1383,16 @@ ], "time": "2016-10-09 07:01:45" }, + { + "name": "rg3/youtube-dl", + "version": "2016.09.08", + "source": { + "type": "git", + "url": "https://github.com/rg3/youtube-dl.git", + "reference": "2016.09.08" + }, + "type": "library" + }, { "name": "sebastian/code-unit-reverse-lookup", "version": "1.0.0", From 5e969733f1bf66597c0a679e9166ee5ad25f6b81 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Tue, 18 Oct 2016 09:19:05 +0200 Subject: [PATCH 30/43] Don't include phpunit and phpcs in release package --- Gruntfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index 6e13bd6..dcc42ff 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -68,7 +68,7 @@ module.exports = function (grunt) { options: { archive: 'alltube-<%= githash.main.tag %>.zip' }, - src: ['*.php', '!config.yml', 'dist/**', '.htaccess', 'img/**', 'LICENSE', 'README.md', 'robots.txt', 'sitemap.xml', 'templates/**', 'templates_c/', 'vendor/**', 'classes/**', 'controllers/**', 'bower_components/**', '!vendor/ffmpeg/**', '!vendor/bin/ffmpeg'] + src: ['*.php', '!config.yml', 'dist/**', '.htaccess', 'img/**', 'LICENSE', 'README.md', 'robots.txt', 'sitemap.xml', 'templates/**', 'templates_c/', 'vendor/**', 'classes/**', 'controllers/**', 'bower_components/**', '!vendor/ffmpeg/**', '!vendor/bin/ffmpeg', '!vendor/phpunit/**', '!vendor/squizlabs/**'] } }, phpdocumentor: { From 13be997ddbcdfe7d2d46dd2ccf2caa2e698577ce Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Tue, 18 Oct 2016 09:27:28 +0200 Subject: [PATCH 31/43] Throw exception if youtube-dl can't be found --- classes/VideoDownload.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/classes/VideoDownload.php b/classes/VideoDownload.php index 498a56b..74b927b 100644 --- a/classes/VideoDownload.php +++ b/classes/VideoDownload.php @@ -33,6 +33,9 @@ class VideoDownload { $this->config = Config::getInstance(); $this->procBuilder = new ProcessBuilder(); + if (!is_file($this->config->youtubedl)) { + throw new \Exception("Can't find youtube-dl at ".$this->config->youtubedl); + } $this->procBuilder->setPrefix( array_merge( [$this->config->python, $this->config->youtubedl], From f549cc8ce3d847fb534d081f82e77074ea6d6945 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Tue, 18 Oct 2016 09:44:45 +0200 Subject: [PATCH 32/43] We need PHP 5.6 on Travis --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 3ffe9d7..a76d3d2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,6 @@ language: php +php: + - 5.6 install: - composer install before_install: From a3dee17b2af37485e620afb23956099fabe98faa Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Tue, 18 Oct 2016 09:54:08 +0200 Subject: [PATCH 33/43] Move YAML parsing to Config::getInstance() Make Config::__construct() public --- classes/Config.php | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/classes/Config.php b/classes/Config.php index 674717b..66e728d 100644 --- a/classes/Config.php +++ b/classes/Config.php @@ -84,18 +84,24 @@ class Config /** * Config constructor. * - * @param string $yamlfile YAML config file path + * Available options: + * * youtubedl: youtube-dl binary path + * * python: Python binary path + * * avconv: avconv or ffmpeg binary path + * * rtmpdump: rtmpdump binary path + * * curl: curl binary path + * * params: Array of youtube-dl parameters + * * curl_params: Array of curl parameters + * * convert: Enable conversion? + * + * @param array $options Options */ - private function __construct($yamlfile) + public function __construct(array $options) { - $this->file = $yamlfile; - if (is_file($yamlfile)) { - $yaml = Yaml::parse(file_get_contents($yamlfile)); - if (isset($yaml) && is_array($yaml)) { - foreach ($yaml as $param => $value) { - if (isset($this->$param) && isset($value)) { - $this->$param = $value; - } + if (isset($options) && is_array($options)) { + foreach ($options as $option => $value) { + if (isset($this->$option) && isset($value)) { + $this->$option = $value; } } } @@ -105,7 +111,7 @@ class Config } /** - * Get singleton instance. + * Get Config singleton instance from YAML config file. * * @param string $yamlfile YAML config file name * @@ -113,9 +119,21 @@ class Config */ public static function getInstance($yamlfile = 'config.yml') { - $yamlfile = __DIR__.'/../'.$yamlfile; + $yamlPath = __DIR__.'/../'.$yamlfile; if (is_null(self::$instance) || self::$instance->file != $yamlfile) { - self::$instance = new self($yamlfile); + if (is_file($yamlfile)) { + $options = Yaml::parse(file_get_contents($yamlPath)); + } elseif ($yamlfile == 'config.yml') { + /* + Allow for the default file to be missing in order to + not surprise users that did not create a config file + */ + $options = []; + } else { + throw new \Exception("Can't find config file at ".$yamlPath); + } + self::$instance = new self($options); + self::$instance->file = $yamlfile; } return self::$instance; From b6f8e585be847ebf4d59c8592e76381ee74cf755 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Tue, 18 Oct 2016 10:03:50 +0200 Subject: [PATCH 34/43] Add a way to pass a Config object to VideoDownload --- classes/VideoDownload.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/classes/VideoDownload.php b/classes/VideoDownload.php index 74b927b..6da3d5b 100644 --- a/classes/VideoDownload.php +++ b/classes/VideoDownload.php @@ -29,9 +29,13 @@ class VideoDownload /** * VideoDownload constructor. */ - public function __construct() + public function __construct(Config $config = null) { - $this->config = Config::getInstance(); + if (isset($config)) { + $this->config = $config; + } else { + $this->config = Config::getInstance(); + } $this->procBuilder = new ProcessBuilder(); if (!is_file($this->config->youtubedl)) { throw new \Exception("Can't find youtube-dl at ".$this->config->youtubedl); From cb7dad19dc39c88c2b2dac04dfd6a82a6720b4b5 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Tue, 18 Oct 2016 10:15:09 +0200 Subject: [PATCH 35/43] Throw exception is Python is missing --- classes/VideoDownload.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/classes/VideoDownload.php b/classes/VideoDownload.php index 6da3d5b..b48c53d 100644 --- a/classes/VideoDownload.php +++ b/classes/VideoDownload.php @@ -39,6 +39,8 @@ class VideoDownload $this->procBuilder = new ProcessBuilder(); if (!is_file($this->config->youtubedl)) { throw new \Exception("Can't find youtube-dl at ".$this->config->youtubedl); + } elseif (!is_file($this->config->python)) { + throw new \Exception("Can't find Python at ".$this->config->python); } $this->procBuilder->setPrefix( array_merge( From 201d7c3376f2c94f18035962dfedacf988b020f0 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Tue, 18 Oct 2016 10:22:06 +0200 Subject: [PATCH 36/43] rtmpdump is not required as it can be installed elsewhere --- composer.json | 6 +++--- composer.lock | 60 +++++++++++++++++++++++++-------------------------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/composer.json b/composer.json index b6c5a26..466cbcc 100644 --- a/composer.json +++ b/composer.json @@ -11,15 +11,15 @@ "symfony/yaml": "~3.1.0", "symfony/process": "~3.1.0", "ptachoire/process-builder-chain": "~1.2.0", - "rudloff/smarty-plugin-noscheme": "~0.1.0", - "rudloff/rtmpdump-bin": "~2.3" + "rudloff/smarty-plugin-noscheme": "~0.1.0" }, "require-dev": { "symfony/var-dumper": "~3.1.0", "squizlabs/php_codesniffer": "~2.7.0", "phpunit/phpunit": "~5.5.2", "ffmpeg/ffmpeg": "dev-release", - "rg3/youtube-dl": "~2016.09.08" + "rg3/youtube-dl": "~2016.09.08", + "rudloff/rtmpdump-bin": "~2.3" }, "extra": { "paas": { diff --git a/composer.lock b/composer.lock index 70bb48c..5426bf6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "186f884cc6378240af71c2f966772e91", - "content-hash": "f247f0e474ec96305a224fdce94e0dae", + "hash": "d0a06c9bc6164cc788eb8ad3d2a9291c", + "content-hash": "91057608d6f29b8de8a9761bb419f19c", "packages": [ { "name": "container-interop/container-interop", @@ -385,34 +385,6 @@ "description": "Add ability to chain symfony processes", "time": "2016-04-10 08:33:20" }, - { - "name": "rudloff/rtmpdump-bin", - "version": "2.3", - "source": { - "type": "git", - "url": "https://github.com/Rudloff/rtmpdump-bin.git", - "reference": "133cdd80e3bab66593e88a5276158596383afd97" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Rudloff/rtmpdump-bin/zipball/133cdd80e3bab66593e88a5276158596383afd97", - "reference": "133cdd80e3bab66593e88a5276158596383afd97", - "shasum": "" - }, - "require-dev": { - "rtmpdump/rtmpdump": "2.3" - }, - "bin": [ - "rtmpdump" - ], - "type": "library", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-2.0" - ], - "description": "rtmpdump binary for Linux 64 bit", - "time": "2016-04-12 19:17:32" - }, { "name": "rudloff/smarty-plugin-noscheme", "version": "0.1.1", @@ -1393,6 +1365,34 @@ }, "type": "library" }, + { + "name": "rudloff/rtmpdump-bin", + "version": "2.3", + "source": { + "type": "git", + "url": "https://github.com/Rudloff/rtmpdump-bin.git", + "reference": "133cdd80e3bab66593e88a5276158596383afd97" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Rudloff/rtmpdump-bin/zipball/133cdd80e3bab66593e88a5276158596383afd97", + "reference": "133cdd80e3bab66593e88a5276158596383afd97", + "shasum": "" + }, + "require-dev": { + "rtmpdump/rtmpdump": "2.3" + }, + "bin": [ + "rtmpdump" + ], + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0" + ], + "description": "rtmpdump binary for Linux 64 bit", + "time": "2016-04-12 19:17:32" + }, { "name": "sebastian/code-unit-reverse-lookup", "version": "1.0.0", From 85fb3a54cd7372c651df4e26458acb8451f27c9a Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Tue, 18 Oct 2016 10:45:16 +0200 Subject: [PATCH 37/43] Test for exceptions when creating config --- tests/ConfigTest.php | 11 +++++++++++ tests/VideoDownloadTest.php | 29 ++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php index 9e7e1d8..da6cdf7 100644 --- a/tests/ConfigTest.php +++ b/tests/ConfigTest.php @@ -42,6 +42,17 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->assertInternalType('string', $this->config->rtmpdump); } + /** + * Test the getInstance function with a missing config file. + * + * @return void + * @expectedException Exception + */ + public function testGetInstanceWithMissingFile() + { + Config::getInstance('foo'); + } + /** * Test the getInstance function with the CONVERT environment variable. * diff --git a/tests/VideoDownloadTest.php b/tests/VideoDownloadTest.php index 8e5d705..55e5915 100644 --- a/tests/VideoDownloadTest.php +++ b/tests/VideoDownloadTest.php @@ -5,6 +5,7 @@ namespace Alltube\Test; use Alltube\VideoDownload; +use Alltube\Config; /** * Unit tests for the VideoDownload class. @@ -31,7 +32,33 @@ class VideoDownloadTest extends \PHPUnit_Framework_TestCase */ protected function tearDown() { - \Alltube\Config::destroyInstance(); + Config::destroyInstance(); + } + + /** + * Test VideoDownload constructor with wrong youtube-dl path. + * + * @return void + * @expectedException Exception + */ + public function testConstructorWithMissingYoutubedl() + { + new VideoDownload( + new Config(['youtubedl'=>'foo']) + ); + } + + /** + * Test VideoDownload constructor with wrong Python path. + * + * @return void + * @expectedException Exception + */ + public function testConstructorWithMissingPython() + { + new VideoDownload( + new Config(['python'=>'foo']) + ); } /** From 18a15a7484c9d5c65958afc6a0995157731605c5 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Tue, 18 Oct 2016 08:45:54 +0000 Subject: [PATCH 38/43] Applied fixes from StyleCI --- tests/VideoDownloadTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/VideoDownloadTest.php b/tests/VideoDownloadTest.php index 55e5915..22aa6c9 100644 --- a/tests/VideoDownloadTest.php +++ b/tests/VideoDownloadTest.php @@ -4,8 +4,8 @@ */ namespace Alltube\Test; -use Alltube\VideoDownload; use Alltube\Config; +use Alltube\VideoDownload; /** * Unit tests for the VideoDownload class. @@ -44,7 +44,7 @@ class VideoDownloadTest extends \PHPUnit_Framework_TestCase public function testConstructorWithMissingYoutubedl() { new VideoDownload( - new Config(['youtubedl'=>'foo']) + new Config(['youtubedl' => 'foo']) ); } @@ -57,7 +57,7 @@ class VideoDownloadTest extends \PHPUnit_Framework_TestCase public function testConstructorWithMissingPython() { new VideoDownload( - new Config(['python'=>'foo']) + new Config(['python' => 'foo']) ); } From 96b961e72cf5771a3659a6cf30adce97856aa6a7 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Wed, 19 Oct 2016 17:17:02 +0200 Subject: [PATCH 39/43] Generate doc with Travis --- .travis.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.travis.yml b/.travis.yml index a76d3d2..bc33f0d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,5 +5,18 @@ install: - composer install before_install: - composer selfupdate + - npm install -g npm@3 after_success: - bash <(curl -s https://codecov.io/bash) +before_deploy: + - npm install + - ./node_modules/.bin/grunt doc +deploy: + provider: surge + project: ./docs/ + domain: alltube.surge.sh + skip_cleanup: true +env: + global: + - SURGE_LOGIN=contact@rudloff.pro + - secure: Icw8UqAilq0+neZsdXn7pny5OrDin1tTN0H3HGPFDBawHWBEffettRsURljnBlm0IcAE8HPvl0DlaGFMedM3ZlYjvp7OqMqe84p7dY22JMvirV4MsMz546FKEYI+g3txawAMDFPCorE+fgkDrL1eUoozGVJxc5c4w4nBVm84QvjxRvCvEKbfevd4giaie1Xuo927lKAwTaVFZryYNotPyJVB2pBBndxfl2EJczJ4DXQc3VczFXkTmuE/QLa2tQVJm5vnVPwOi1xmvgh6g1ChEOw0zAks1Mf5+UvxtVV7qTicVAWK0fVVBL9mHPpNzSNb4pPqHPWQjhAPdCW+WPn6+DhqS5BHeSfQit/OtLMpUWO1IceVDRwU3jkXmMgnKwz1t9yDh6VBZRvGPkXfU3cjQ9SFpmnnu/4JLgwA/zSU2Pzl7/+gsHQBazkXh8HYAbOjF2w1IBXOpZ8Yv7D5axRIDduS/TUQ6oNK3KYmRMBcg8ZzVzIdz+55NchaDtihcp5akaHhKxR7GMPrfi66b+wARSw3OsYmCGLNFF8zj/6zo3/zB02+oVMlXXySOAKKi0A2OvH9xV4W4Jl0TGua/27XOWr9c5btrZrykk3PXfKe5YgT46Q8CtK8yN97bDKbwbAp6gNEyMFFatdHKlEndZYsVDQ16htd0b/303SZfXYMvO0= From 9c35b5177708c05085576cc8a839b5143cbf9c44 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Wed, 19 Oct 2016 18:05:58 +0200 Subject: [PATCH 40/43] Add title to code doc --- phpdoc.xml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 phpdoc.xml diff --git a/phpdoc.xml b/phpdoc.xml new file mode 100644 index 0000000..27bf4a6 --- /dev/null +++ b/phpdoc.xml @@ -0,0 +1,4 @@ + + + Alltube Download library documentation + From 257b7ed9fd4d773b6fd6d9ceb546d3da4882fd5a Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Wed, 19 Oct 2016 18:11:22 +0200 Subject: [PATCH 41/43] We don't need grunt-cli --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index eb8b13b..fc6ec07 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,6 @@ "dependencies": { "bower": "~1.7.1", "grunt": "~1.0.1", - "grunt-cli": "~1.2.0", "grunt-contrib-cssmin": "~1.0.0", "grunt-contrib-uglify": "~2.0.0" }, @@ -39,6 +38,6 @@ "url": "https://github.com/Rudloff/alltube.git" }, "scripts": { - "postinstall": "node node_modules/bower/bin/bower install && node node_modules/grunt-cli/bin/grunt" + "postinstall": "node node_modules/.bin/bower install && node node_modules/.bin/grunt" } } From be92413e3cb18b07490edd05fa931e686d67666f Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Wed, 19 Oct 2016 18:32:13 +0200 Subject: [PATCH 42/43] Add how to use as a library in README --- README.md | 45 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 63fea97..f35d40b 100644 --- a/README.md +++ b/README.md @@ -110,12 +110,6 @@ server { } ``` -## License - -This software is available under the [GNU General Public License](http://www.gnu.org/licenses/gpl.html). - -Please __use a different name and logo__ if you run it on a public server. - ## Other dependencies You need [avconv](https://libav.org/avconv.html), [rtmpdump](http://rtmpdump.mplayerhq.hu/) and [curl](https://curl.haxx.se/) in order to enable conversions. @@ -129,6 +123,45 @@ sudo apt-get install libav-tools rtmpdump curl You also probably need to edit the `avconv` variable in `config.yml` so that it points to your ffmpeg/avconv binary (`/usr/bin/avconv` on Debian/Ubuntu). +## Use as library + +Alltube can also be used as a library to extract a video URL from a webpage. + +You can install it with: + +```bash +composer require rudloff/alltube +``` + +You can then use it in your PHP code: + +```php +use Alltube\Config; +use Alltube\VideoDownload; + +require_once __DIR__.'/vendor/autoload.php'; + +$downloader = new VideoDownload( + new Config( + [ + 'youtubedl' => '/usr/local/bin/youtube-dl', + ] + ) +); + +$downloader->getURL('https://www.youtube.com/watch?v=dQw4w9WgXcQ'); +``` + +The library documentation is available on [alltube.surge.sh](https://alltube.surge.sh/classes/Alltube.VideoDownload.html). + +You can also have a look at this [example project](https://github.com/Rudloff/alltube-example-project). + ## FAQ Please read the [FAQ](FAQ.md) before reporting any issue. + +## License + +This software is available under the [GNU General Public License](http://www.gnu.org/licenses/gpl.html). + +Please __use a different name and logo__ if you run it on a public server. From e575e16e4fc6c2106a7c4d7d9029ee49a2938abf Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Wed, 19 Oct 2016 18:33:45 +0200 Subject: [PATCH 43/43] 0.6.0 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fc6ec07..9606f58 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "alltube", "description": "HTML GUI for youtube-dl", - "version": "0.5.2", + "version": "0.6.0", "author": "Pierre Rudloff", "bugs": "https://github.com/Rudloff/alltube/issues", "dependencies": {