Cleanup doc

This commit is contained in:
Pierre Rudloff 2016-08-01 13:29:13 +02:00
parent 2a0fbb5032
commit d414e67d31
5 changed files with 136 additions and 98 deletions

View file

@ -1,41 +1,68 @@
<?php
/**
* Config class
*
* PHP Version 5.3.10
*
* @category Youtube-dl
* @package Youtubedl
* @author Pierre Rudloff <contact@rudloff.pro>
* @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 <contact@rudloff.pro>
* @license GNU General Public License http://www.gnu.org/licenses/gpl.html
* @link http://rudloff.pro
* */
* Manage config parameters
*/
class Config
{
/**
* Singleton instance
* @var Config
*/
private static $instance;
/**
* youtube-dl binary path
* @var string
*/
public $youtubedl = 'vendor/rg3/youtube-dl/youtube_dl/__main__.py';
/**
* python binary path
* @var string
*/
public $python = '/usr/bin/python';
/**
* youtube-dl parameters
* @var array
*/
public $params = array('--no-playlist', '--no-warnings', '-f best[protocol^=http]', '--playlist-end', 1);
/**
* Enable audio conversion
* @var bool
*/
public $convert = false;
/**
* avconv or ffmpeg binary path
* @var string
*/
public $avconv = 'vendor/bin/ffmpeg';
/**
* rtmpdump binary path
* @var string
*/
public $rtmpdump = 'vendor/bin/rtmpdump';
/**
* curl binary path
* @var string
*/
public $curl = '/usr/bin/curl';
/**
* curl parameters
* @var array
*/
public $curl_params = array();
/**
@ -72,6 +99,10 @@ class Config
return self::$instance;
}
/**
* Destroy singleton instance
* @return void
*/
public static function destroyInstance()
{
self::$instance = null;

View file

@ -1,15 +1,7 @@
<?php
/**
* VideoDownload class
*
* PHP Version 5.3.10
*
* @category Youtube-dl
* @package Youtubedl
* @author Pierre Rudloff <contact@rudloff.pro>
* @license GNU General Public License http://www.gnu.org/licenses/gpl.html
* @link http://rudloff.pro
* */
*/
namespace Alltube;
use Symfony\Component\Process\Process;
@ -17,18 +9,14 @@ use Symfony\Component\Process\ProcessBuilder;
use Chain\Chain;
/**
* Main class
*
* PHP Version 5.3.10
*
* @category Youtube-dl
* @package Youtubedl
* @author Pierre Rudloff <contact@rudloff.pro>
* @license GNU General Public License http://www.gnu.org/licenses/gpl.html
* @link http://rudloff.pro
* */
* Extract info about videos
*/
class VideoDownload
{
/**
* VideoDownload constructor
*/
public function __construct()
{
$this->config = Config::getInstance();
@ -44,7 +32,7 @@ class VideoDownload
/**
* List all extractors
*
* @return array Extractors
* @return string[] Extractors
* */
public function listExtractors()
{
@ -114,6 +102,14 @@ class VideoDownload
}
}
/**
* Get filename of video file from URL of page
*
* @param string $url URL of page
* @param string $format Format to use for the video
*
* @return string Filename of extracted video
* */
public function getFilename($url, $format = null)
{
$this->procBuilder->setArguments(
@ -134,6 +130,14 @@ class VideoDownload
}
}
/**
* Get filename of audio from URL of page
*
* @param string $url URL of page
* @param string $format Format to use for the video
*
* @return string Filename of converted audio file
* */
public function getAudioFilename($url, $format = null)
{
return html_entity_decode(
@ -146,6 +150,14 @@ class VideoDownload
);
}
/**
* Get audio stream of converted video
*
* @param string $url URL of page
* @param string $format Format to use for the video
*
* @return resource popen stream
*/
public function getAudioStream($url, $format)
{
if (!shell_exec('which '.$this->config->avconv)) {