This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 588
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
1,199 additions
and
576 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,6 @@ templates_c/ | |
ffmpeg.tar.xz | ||
ffmpeg-*/ | ||
alltube-release.zip | ||
coverage/ | ||
bower_components/ | ||
config.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
AddType application/x-web-app-manifest+json .webapp | ||
ExpiresActive On | ||
ExpiresByType application/javascript "access plus 1 week" | ||
ExpiresByType text/css "access plus 1 week" | ||
ExpiresByType image/png "access plus 1 week" | ||
ExpiresByType image/jpeg "access plus 1 week" | ||
ExpiresByType image/svg+xml "access plus 1 week" | ||
<ifmodule mod_expires.c> | ||
ExpiresActive On | ||
ExpiresByType application/javascript "access plus 1 week" | ||
ExpiresByType text/css "access plus 1 week" | ||
ExpiresByType image/png "access plus 1 week" | ||
ExpiresByType image/jpeg "access plus 1 week" | ||
ExpiresByType image/svg+xml "access plus 1 week" | ||
</ifmodule> | ||
FileETag None | ||
RewriteEngine On | ||
RewriteCond %{REQUEST_FILENAME} !-f | ||
RewriteRule ^ index.php [QSA,L] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,4 @@ | ||
language: php | ||
php: | ||
- 5.4 | ||
- 5.5 | ||
- 5.6 | ||
install: | ||
- composer install | ||
- npm install | ||
script: phpunit tests/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "alltube", | ||
"dependencies": { | ||
"opensans-googlefont": "*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
/** | ||
* Config class | ||
* | ||
* PHP Version 5.3.10 | ||
* | ||
* @category Youtube-dl | ||
* @package Youtubedl | ||
* @author Pierre Rudloff <[email protected]> | ||
* @license GNU General Public License http://www.gnu.org/licenses/gpl.html | ||
* @link http://rudloff.pro | ||
* */ | ||
namespace Alltube; | ||
use Symfony\Component\Yaml\Yaml; | ||
/** | ||
* Class to manage config parameters | ||
* | ||
* PHP Version 5.3.10 | ||
* | ||
* @category Youtube-dl | ||
* @package Youtubedl | ||
* @author Pierre Rudloff <[email protected]> | ||
* @license GNU General Public License http://www.gnu.org/licenses/gpl.html | ||
* @link http://rudloff.pro | ||
* */ | ||
Class Config | ||
{ | ||
private static $_instance; | ||
|
||
public $youtubedl = 'vendor/rg3/youtube-dl/youtube_dl/__main__.py'; | ||
public $python = '/usr/bin/python'; | ||
public $params = '--no-playlist --no-warnings -f best'; | ||
public $convert = false; | ||
public $avconv = 'ffmpeg/ffmpeg'; | ||
|
||
/** | ||
* Config constructor | ||
*/ | ||
private function __construct() | ||
{ | ||
$yaml = Yaml::parse(__DIR__.'/../config.yml'); | ||
if (isset($yaml) && is_array($yaml)) { | ||
foreach ($yaml as $param=>$value) { | ||
if (isset($this->$param)) { | ||
$this->$param = $value; | ||
} | ||
} | ||
} | ||
if (getenv('CONVERT')) { | ||
$this->convert = getenv('CONVERT'); | ||
} | ||
} | ||
|
||
/** | ||
* Get singleton instance | ||
* @return Config | ||
*/ | ||
public static function getInstance() | ||
{ | ||
if (is_null(self::$_instance)) { | ||
self::$_instance = new Config(); | ||
} | ||
return self::$_instance; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
<?php | ||
/** | ||
* VideoDownload class | ||
* | ||
* PHP Version 5.3.10 | ||
* | ||
* @category Youtube-dl | ||
* @package Youtubedl | ||
* @author Pierre Rudloff <[email protected]> | ||
* @license GNU General Public License http://www.gnu.org/licenses/gpl.html | ||
* @link http://rudloff.pro | ||
* */ | ||
namespace Alltube; | ||
/** | ||
* Main class | ||
* | ||
* PHP Version 5.3.10 | ||
* | ||
* @category Youtube-dl | ||
* @package Youtubedl | ||
* @author Pierre Rudloff <[email protected]> | ||
* @license GNU General Public License http://www.gnu.org/licenses/gpl.html | ||
* @link http://rudloff.pro | ||
* */ | ||
Class VideoDownload | ||
{ | ||
/** | ||
* Get the user agent used youtube-dl | ||
* | ||
* @return string UA | ||
* */ | ||
static function getUA() | ||
{ | ||
$config = Config::getInstance(); | ||
exec( | ||
$config->python.' '.$config->youtubedl.' --dump-user-agent', | ||
$version | ||
); | ||
return $version[0]; | ||
} | ||
|
||
/** | ||
* List all extractors | ||
* | ||
* @return array Extractors | ||
* */ | ||
static function listExtractors() | ||
{ | ||
$config = Config::getInstance(); | ||
exec( | ||
$config->python.' '.$config->youtubedl.' --list-extractors', | ||
$extractors | ||
); | ||
return $extractors; | ||
} | ||
|
||
/** | ||
* Get filename of video | ||
* | ||
* @param string $url URL of page | ||
* @param string $format Format to use for the video | ||
* | ||
* @return string Filename | ||
* */ | ||
static function getFilename($url, $format=null) | ||
{ | ||
$config = Config::getInstance(); | ||
$cmd=$config->python.' '.$config->youtubedl; | ||
if (isset($format)) { | ||
$cmd .= ' -f '.escapeshellarg($format); | ||
} | ||
$cmd .=' --get-filename '.escapeshellarg($url)." 2>&1"; | ||
exec( | ||
$cmd, | ||
$filename | ||
); | ||
return end($filename); | ||
} | ||
|
||
/** | ||
* Get all information about a video | ||
* | ||
* @param string $url URL of page | ||
* @param string $format Format to use for the video | ||
* | ||
* @return string JSON | ||
* */ | ||
static function getJSON($url, $format=null) | ||
{ | ||
$config = Config::getInstance(); | ||
$cmd=$config->python.' '.$config->youtubedl.' '.$config->params; | ||
if (isset($format)) { | ||
$cmd .= ' -f '.escapeshellarg($format); | ||
} | ||
$cmd .=' --dump-json '.escapeshellarg($url)." 2>&1"; | ||
exec( | ||
$cmd, $result, $code | ||
); | ||
if ($code>0) { | ||
throw new \Exception(implode(PHP_EOL, $result)); | ||
} else { | ||
return json_decode($result[0]); | ||
} | ||
} | ||
|
||
/** | ||
* 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 | ||
* */ | ||
static function getURL($url, $format=null) | ||
{ | ||
$config = Config::getInstance(); | ||
$cmd=$config->python.' '.$config->youtubedl.' '.$config->params; | ||
if (isset($format)) { | ||
$cmd .= ' -f '.escapeshellarg($format); | ||
} | ||
$cmd .=' -g '.escapeshellarg($url)." 2>&1"; | ||
exec( | ||
$cmd, $result, $code | ||
); | ||
if ($code>0) { | ||
throw new \Exception(implode(PHP_EOL, $result)); | ||
} else { | ||
return array('success'=>true, 'url'=>end($result)); | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.