Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Merge branch 'release-0.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Rudloff committed Nov 8, 2015
2 parents 8f199c8 + fed5883 commit 4b12759
Show file tree
Hide file tree
Showing 43 changed files with 1,199 additions and 576 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ templates_c/
ffmpeg.tar.xz
ffmpeg-*/
alltube-release.zip
coverage/
bower_components/
config.yml
17 changes: 11 additions & 6 deletions .htaccess
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]
5 changes: 0 additions & 5 deletions .travis.yml
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/
12 changes: 11 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = function (grunt) {
},
phpcs: {
php: {
src: ['*.php']
src: ['*.php', 'classes/*.php', 'controllers/*.php']
},
tests: {
src: ['tests/*.php']
Expand All @@ -45,6 +45,14 @@ module.exports = function (grunt) {
classes: {
dir: 'tests/'
}
},
compress: {
release: {
options: {
archive: 'alltube-release.zip'
},
src: ['*.php', '!config.yml', 'dist/**', 'fonts/**', '.htaccess', 'img/**', 'js/**', 'LICENSE', 'README.md', 'robots.txt', 'sitemap.xml', 'templates/**', 'templates_c/', 'vendor/**', 'classes/**', 'controllers/**', 'bower_components/**']
}
}
}
);
Expand All @@ -54,8 +62,10 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-phpcs');
grunt.loadNpmTasks('grunt-phpunit');
grunt.loadNpmTasks('grunt-contrib-compress');

grunt.registerTask('default', ['uglify', 'cssmin']);
grunt.registerTask('lint', ['phpcs']);
grunt.registerTask('test', ['phpunit']);
grunt.registerTask('release', ['default', 'compress']);
};
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ You should also ensure that the *templates_c* folder has the right permissions:

If you want to use a custom config, you need to create a config file:

cp config.example.php config.php
cp config.example.yml config.yml


##License
Expand All @@ -33,7 +33,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) and [rtmpdump](http://rtmpdump.mplayerhq.hu/) in order to enable conversions.
If you don't want to enable conversions, you can disable it in *config.php*.
If you don't want to enable conversions, you can disable it in *config.yml*.

On Debian-based systems:

Expand Down
84 changes: 0 additions & 84 deletions api.php

This file was deleted.

6 changes: 6 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "alltube",
"dependencies": {
"opensans-googlefont": "*"
}
}
65 changes: 65 additions & 0 deletions classes/Config.php
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;
}
}
132 changes: 132 additions & 0 deletions classes/VideoDownload.php
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));
}

}
}
Loading

0 comments on commit 4b12759

Please sign in to comment.