2014-03-13 19:07:56 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2016-09-07 22:28:28 +00:00
|
|
|
* VideoDownload class.
|
2016-08-01 11:29:13 +00:00
|
|
|
*/
|
2016-12-05 12:12:27 +00:00
|
|
|
|
2015-10-29 19:43:43 +00:00
|
|
|
namespace Alltube;
|
2016-03-29 23:49:08 +00:00
|
|
|
|
2016-07-29 22:15:17 +00:00
|
|
|
use Chain\Chain;
|
2016-09-07 22:28:28 +00:00
|
|
|
use Symfony\Component\Process\ProcessBuilder;
|
2016-03-31 22:42:28 +00:00
|
|
|
|
2014-03-13 19:07:56 +00:00
|
|
|
/**
|
2016-09-07 22:28:28 +00:00
|
|
|
* Extract info about videos.
|
2016-08-01 11:29:13 +00:00
|
|
|
*/
|
2016-03-29 23:49:08 +00:00
|
|
|
class VideoDownload
|
2014-03-13 19:07:56 +00:00
|
|
|
{
|
2016-10-14 00:40:33 +00:00
|
|
|
/**
|
2016-10-14 00:40:57 +00:00
|
|
|
* Config instance.
|
|
|
|
*
|
2016-10-14 00:40:33 +00:00
|
|
|
* @var Config
|
|
|
|
*/
|
2016-10-10 19:32:07 +00:00
|
|
|
private $config;
|
2016-10-14 00:40:33 +00:00
|
|
|
|
|
|
|
/**
|
2016-10-14 00:40:57 +00:00
|
|
|
* ProcessBuilder instance used to call Python.
|
|
|
|
*
|
2016-10-14 00:40:33 +00:00
|
|
|
* @var ProcessBuilder
|
|
|
|
*/
|
2016-10-10 19:32:07 +00:00
|
|
|
private $procBuilder;
|
|
|
|
|
2016-08-01 11:29:13 +00:00
|
|
|
/**
|
2016-09-07 22:28:28 +00:00
|
|
|
* VideoDownload constructor.
|
2016-08-01 11:29:13 +00:00
|
|
|
*/
|
2016-10-18 08:03:50 +00:00
|
|
|
public function __construct(Config $config = null)
|
2016-04-08 17:06:41 +00:00
|
|
|
{
|
2016-10-18 08:03:50 +00:00
|
|
|
if (isset($config)) {
|
|
|
|
$this->config = $config;
|
|
|
|
} else {
|
|
|
|
$this->config = Config::getInstance();
|
|
|
|
}
|
2016-04-08 17:37:59 +00:00
|
|
|
$this->procBuilder = new ProcessBuilder();
|
2016-10-18 07:27:28 +00:00
|
|
|
if (!is_file($this->config->youtubedl)) {
|
|
|
|
throw new \Exception("Can't find youtube-dl at ".$this->config->youtubedl);
|
2016-10-18 08:15:09 +00:00
|
|
|
} elseif (!is_file($this->config->python)) {
|
|
|
|
throw new \Exception("Can't find Python at ".$this->config->python);
|
2016-10-18 07:27:28 +00:00
|
|
|
}
|
2016-04-08 17:37:59 +00:00
|
|
|
$this->procBuilder->setPrefix(
|
|
|
|
array_merge(
|
2016-09-07 22:28:28 +00:00
|
|
|
[$this->config->python, $this->config->youtubedl],
|
2016-04-08 17:37:59 +00:00
|
|
|
$this->config->params
|
|
|
|
)
|
|
|
|
);
|
2016-04-08 17:06:41 +00:00
|
|
|
}
|
|
|
|
|
2014-03-13 19:07:56 +00:00
|
|
|
/**
|
2016-09-07 22:28:28 +00:00
|
|
|
* List all extractors.
|
2015-09-04 20:45:55 +00:00
|
|
|
*
|
2016-08-01 11:29:13 +00:00
|
|
|
* @return string[] Extractors
|
2014-03-13 19:07:56 +00:00
|
|
|
* */
|
2016-04-08 17:06:41 +00:00
|
|
|
public function listExtractors()
|
2014-03-13 19:07:56 +00:00
|
|
|
{
|
2016-10-26 23:27:55 +00:00
|
|
|
return explode(PHP_EOL, trim($this->getProp(null, null, 'list-extractors')));
|
2014-03-13 19:07:56 +00:00
|
|
|
}
|
2015-09-04 20:45:55 +00:00
|
|
|
|
2016-10-14 00:40:33 +00:00
|
|
|
/**
|
2016-10-14 00:40:57 +00:00
|
|
|
* Get a property from youtube-dl.
|
|
|
|
*
|
2016-10-20 21:01:31 +00:00
|
|
|
* @param string $url URL to parse
|
|
|
|
* @param string $format Format
|
|
|
|
* @param string $prop Property
|
|
|
|
* @param string $password Video password
|
2016-10-14 00:40:57 +00:00
|
|
|
*
|
2016-10-14 00:40:33 +00:00
|
|
|
* @return string
|
|
|
|
*/
|
2016-10-20 21:01:31 +00:00
|
|
|
private function getProp($url, $format = null, $prop = 'dump-json', $password = null)
|
2014-03-13 19:07:56 +00:00
|
|
|
{
|
2016-04-08 17:37:59 +00:00
|
|
|
$this->procBuilder->setArguments(
|
2016-09-07 22:28:28 +00:00
|
|
|
[
|
2016-10-13 14:40:19 +00:00
|
|
|
'--'.$prop,
|
2016-09-07 22:28:28 +00:00
|
|
|
$url,
|
|
|
|
]
|
2016-02-28 22:04:53 +00:00
|
|
|
);
|
2014-03-13 19:07:56 +00:00
|
|
|
if (isset($format)) {
|
2016-04-08 17:37:59 +00:00
|
|
|
$this->procBuilder->add('-f '.$format);
|
2014-03-13 19:07:56 +00:00
|
|
|
}
|
2016-10-20 21:01:31 +00:00
|
|
|
if (isset($password)) {
|
|
|
|
$this->procBuilder->add('--video-password');
|
|
|
|
$this->procBuilder->add($password);
|
|
|
|
}
|
2017-11-01 22:02:19 +00:00
|
|
|
|
|
|
|
//This is needed by the openload extractor because it runs PhantomJS
|
|
|
|
$this->procBuilder->setEnv('QT_QPA_PLATFORM', 'offscreen');
|
|
|
|
|
2016-04-08 17:37:59 +00:00
|
|
|
$process = $this->procBuilder->getProcess();
|
2016-03-31 22:42:28 +00:00
|
|
|
$process->run();
|
|
|
|
if (!$process->isSuccessful()) {
|
2016-10-20 21:01:31 +00:00
|
|
|
$errorOutput = trim($process->getErrorOutput());
|
|
|
|
if ($errorOutput == 'ERROR: This video is protected by a password, use the --video-password option') {
|
|
|
|
throw new PasswordException($errorOutput);
|
|
|
|
} elseif (substr($errorOutput, 0, 21) == 'ERROR: Wrong password') {
|
|
|
|
throw new \Exception('Wrong password');
|
|
|
|
} else {
|
|
|
|
throw new \Exception($errorOutput);
|
|
|
|
}
|
2014-03-18 14:08:16 +00:00
|
|
|
} else {
|
2017-04-24 17:16:38 +00:00
|
|
|
return trim($process->getOutput());
|
2014-03-18 14:08:16 +00:00
|
|
|
}
|
2014-03-13 19:07:56 +00:00
|
|
|
}
|
|
|
|
|
2016-10-13 14:40:19 +00:00
|
|
|
/**
|
|
|
|
* Get all information about a video.
|
|
|
|
*
|
2016-10-20 21:01:31 +00:00
|
|
|
* @param string $url URL of page
|
|
|
|
* @param string $format Format to use for the video
|
|
|
|
* @param string $password Video password
|
2016-10-13 14:40:19 +00:00
|
|
|
*
|
|
|
|
* @return object Decoded JSON
|
|
|
|
* */
|
2016-10-20 21:01:31 +00:00
|
|
|
public function getJSON($url, $format = null, $password = null)
|
2016-10-13 14:40:19 +00:00
|
|
|
{
|
2017-04-24 23:53:38 +00:00
|
|
|
return json_decode($this->getProp($url, $format, 'dump-single-json', $password));
|
2016-10-13 14:40:19 +00:00
|
|
|
}
|
|
|
|
|
2014-03-13 19:07:56 +00:00
|
|
|
/**
|
2016-09-07 22:28:28 +00:00
|
|
|
* Get URL of video from URL of page.
|
2015-09-04 20:45:55 +00:00
|
|
|
*
|
2017-04-24 22:40:24 +00:00
|
|
|
* It generally returns only one URL.
|
|
|
|
* But it can return two URLs when multiple formats are specified
|
|
|
|
* (eg. bestvideo+bestaudio).
|
|
|
|
*
|
2016-10-20 21:01:31 +00:00
|
|
|
* @param string $url URL of page
|
|
|
|
* @param string $format Format to use for the video
|
|
|
|
* @param string $password Video password
|
2015-09-04 20:45:55 +00:00
|
|
|
*
|
2017-04-25 12:55:21 +00:00
|
|
|
* @return string[] URLs of video
|
2014-03-13 19:07:56 +00:00
|
|
|
* */
|
2016-10-20 21:01:31 +00:00
|
|
|
public function getURL($url, $format = null, $password = null)
|
2014-03-13 19:07:56 +00:00
|
|
|
{
|
2017-04-24 22:40:24 +00:00
|
|
|
return explode(PHP_EOL, $this->getProp($url, $format, 'get-url', $password));
|
2014-03-13 19:07:56 +00:00
|
|
|
}
|
2016-07-29 22:15:17 +00:00
|
|
|
|
2016-08-01 11:29:13 +00:00
|
|
|
/**
|
2016-09-07 22:28:28 +00:00
|
|
|
* Get filename of video file from URL of page.
|
2016-08-01 11:29:13 +00:00
|
|
|
*
|
2016-10-20 21:01:31 +00:00
|
|
|
* @param string $url URL of page
|
|
|
|
* @param string $format Format to use for the video
|
|
|
|
* @param string $password Video password
|
2016-08-01 11:29:13 +00:00
|
|
|
*
|
|
|
|
* @return string Filename of extracted video
|
|
|
|
* */
|
2016-10-20 21:01:31 +00:00
|
|
|
public function getFilename($url, $format = null, $password = null)
|
2016-07-29 22:15:17 +00:00
|
|
|
{
|
2016-10-20 21:01:31 +00:00
|
|
|
return trim($this->getProp($url, $format, 'get-filename', $password));
|
2016-07-29 22:15:17 +00:00
|
|
|
}
|
|
|
|
|
2016-08-01 11:29:13 +00:00
|
|
|
/**
|
2017-04-24 22:41:49 +00:00
|
|
|
* Get filename of video with the specified extension.
|
2016-08-01 11:29:13 +00:00
|
|
|
*
|
2017-04-24 22:40:24 +00:00
|
|
|
* @param string $extension New file extension
|
|
|
|
* @param string $url URL of page
|
|
|
|
* @param string $format Format to use for the video
|
|
|
|
* @param string $password Video password
|
2016-08-01 11:29:13 +00:00
|
|
|
*
|
2017-04-24 22:40:24 +00:00
|
|
|
* @return string Filename of extracted video with specified extension
|
|
|
|
*/
|
|
|
|
public function getFileNameWithExtension($extension, $url, $format = null, $password = null)
|
2016-07-29 22:15:17 +00:00
|
|
|
{
|
|
|
|
return html_entity_decode(
|
|
|
|
pathinfo(
|
2016-10-20 21:13:37 +00:00
|
|
|
$this->getFilename($url, $format, $password),
|
2016-07-29 22:15:17 +00:00
|
|
|
PATHINFO_FILENAME
|
2017-04-24 22:40:24 +00:00
|
|
|
).'.'.$extension,
|
2016-07-29 22:15:17 +00:00
|
|
|
ENT_COMPAT,
|
|
|
|
'ISO-8859-1'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-04-24 22:40:24 +00:00
|
|
|
/**
|
|
|
|
* Get filename of audio from URL of page.
|
|
|
|
*
|
|
|
|
* @param string $url URL of page
|
|
|
|
* @param string $format Format to use for the video
|
|
|
|
* @param string $password Video password
|
|
|
|
*
|
|
|
|
* @return string Filename of converted audio file
|
|
|
|
* */
|
|
|
|
public function getAudioFilename($url, $format = null, $password = null)
|
|
|
|
{
|
|
|
|
return $this->getFileNameWithExtension('mp3', $url, $format, $password);
|
|
|
|
}
|
|
|
|
|
2016-10-15 14:18:04 +00:00
|
|
|
/**
|
|
|
|
* 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 ([
|
2017-10-29 22:21:13 +00:00
|
|
|
'url' => 'rtmp',
|
|
|
|
'webpage_url' => 'pageUrl',
|
|
|
|
'player_url' => 'swfVfy',
|
2016-10-15 14:18:04 +00:00
|
|
|
'flash_version' => 'flashVer',
|
2017-10-29 22:21:13 +00:00
|
|
|
'play_path' => 'playpath',
|
|
|
|
'app' => 'app',
|
2016-10-15 14:18:04 +00:00
|
|
|
] as $property => $option) {
|
|
|
|
if (isset($video->{$property})) {
|
|
|
|
$builder->add('--'.$option);
|
|
|
|
$builder->add($video->{$property});
|
|
|
|
}
|
|
|
|
}
|
2016-10-15 14:20:54 +00:00
|
|
|
|
2016-10-15 14:18:04 +00:00
|
|
|
return $builder;
|
|
|
|
}
|
|
|
|
|
2016-10-14 17:01:51 +00:00
|
|
|
/**
|
2016-10-14 17:02:14 +00:00
|
|
|
* Get a process that runs rtmp in order to download a video.
|
|
|
|
*
|
|
|
|
* @param object $video Video object returned by youtube-dl
|
|
|
|
*
|
2016-10-14 17:01:51 +00:00
|
|
|
* @return \Symfony\Component\Process\Process Process
|
|
|
|
*/
|
2017-05-04 23:51:28 +00:00
|
|
|
private function getRtmpProcess(\stdClass $video)
|
2016-10-14 17:01:51 +00:00
|
|
|
{
|
2017-05-13 22:52:59 +00:00
|
|
|
if (!$this->checkCommand([$this->config->rtmpdump, '--help'])) {
|
2016-10-14 17:01:51 +00:00
|
|
|
throw(new \Exception('Can\'t find rtmpdump'));
|
|
|
|
}
|
|
|
|
$builder = new ProcessBuilder(
|
|
|
|
[
|
|
|
|
$this->config->rtmpdump,
|
2016-10-15 14:20:54 +00:00
|
|
|
'-q',
|
2016-10-14 17:01:51 +00:00
|
|
|
]
|
|
|
|
);
|
2016-10-15 14:18:04 +00:00
|
|
|
$builder = $this->addOptionsToRtmpProcess($builder, $video);
|
2016-10-14 17:01:51 +00:00
|
|
|
if (isset($video->rtmp_conn)) {
|
|
|
|
foreach ($video->rtmp_conn as $conn) {
|
|
|
|
$builder->add('--conn');
|
|
|
|
$builder->add($conn);
|
|
|
|
}
|
|
|
|
}
|
2016-10-14 17:02:14 +00:00
|
|
|
|
2016-10-14 17:01:51 +00:00
|
|
|
return $builder->getProcess();
|
|
|
|
}
|
|
|
|
|
2017-05-13 22:52:59 +00:00
|
|
|
/**
|
2017-05-13 22:54:47 +00:00
|
|
|
* Check if a command runs successfully.
|
2017-05-13 22:52:59 +00:00
|
|
|
*
|
|
|
|
* @param array $command Command and arguments
|
|
|
|
*
|
|
|
|
* @return bool False if the command returns an error, true otherwise
|
|
|
|
*/
|
|
|
|
private function checkCommand(array $command)
|
|
|
|
{
|
|
|
|
$builder = ProcessBuilder::create($command);
|
|
|
|
$process = $builder->getProcess();
|
|
|
|
$process->run();
|
|
|
|
|
|
|
|
return $process->isSuccessful();
|
|
|
|
}
|
|
|
|
|
2016-10-14 17:01:51 +00:00
|
|
|
/**
|
2017-04-24 17:16:38 +00:00
|
|
|
* Get a process that runs avconv in order to convert a video to MP3.
|
2016-10-14 17:02:14 +00:00
|
|
|
*
|
2017-04-24 17:16:38 +00:00
|
|
|
* @param string $url URL of the video file
|
2016-10-14 17:02:14 +00:00
|
|
|
*
|
2016-10-14 17:01:51 +00:00
|
|
|
* @return \Symfony\Component\Process\Process Process
|
|
|
|
*/
|
2017-04-24 17:16:38 +00:00
|
|
|
private function getAvconvMp3Process($url)
|
2016-10-14 17:01:51 +00:00
|
|
|
{
|
2017-05-13 22:52:59 +00:00
|
|
|
if (!$this->checkCommand([$this->config->avconv, '-version'])) {
|
2017-04-24 17:16:38 +00:00
|
|
|
throw(new \Exception('Can\'t find avconv or ffmpeg'));
|
2016-10-14 17:01:51 +00:00
|
|
|
}
|
2016-10-14 17:02:14 +00:00
|
|
|
|
2017-05-02 09:20:36 +00:00
|
|
|
$builder = ProcessBuilder::create(
|
2017-04-24 17:16:38 +00:00
|
|
|
[
|
|
|
|
$this->config->avconv,
|
|
|
|
'-v', 'quiet',
|
|
|
|
//Vimeo needs a correct user-agent
|
|
|
|
'-user-agent', $this->getProp(null, null, 'dump-user-agent'),
|
|
|
|
'-i', $url,
|
|
|
|
'-f', 'mp3',
|
2017-11-10 22:50:17 +00:00
|
|
|
'-b:a', $this->config->audioBitrate.'k',
|
2017-04-24 17:16:38 +00:00
|
|
|
'-vn',
|
|
|
|
'pipe:1',
|
|
|
|
]
|
|
|
|
);
|
2017-05-02 09:20:36 +00:00
|
|
|
|
|
|
|
return $builder->getProcess();
|
2016-10-14 17:01:51 +00:00
|
|
|
}
|
|
|
|
|
2016-08-01 11:29:13 +00:00
|
|
|
/**
|
2016-09-07 22:28:28 +00:00
|
|
|
* Get audio stream of converted video.
|
2016-08-01 11:29:13 +00:00
|
|
|
*
|
2016-10-20 21:13:37 +00:00
|
|
|
* @param string $url URL of page
|
|
|
|
* @param string $format Format to use for the video
|
|
|
|
* @param string $password Video password
|
2016-08-01 11:29:13 +00:00
|
|
|
*
|
|
|
|
* @return resource popen stream
|
|
|
|
*/
|
2016-10-20 21:13:37 +00:00
|
|
|
public function getAudioStream($url, $format, $password = null)
|
2016-07-29 22:15:17 +00:00
|
|
|
{
|
2016-10-20 21:13:37 +00:00
|
|
|
$video = $this->getJSON($url, $format, $password);
|
2016-12-26 23:01:42 +00:00
|
|
|
if (in_array($video->protocol, ['m3u8', 'm3u8_native'])) {
|
|
|
|
throw(new \Exception('Conversion of M3U8 files is not supported.'));
|
|
|
|
}
|
2016-07-29 22:15:17 +00:00
|
|
|
|
|
|
|
if (parse_url($video->url, PHP_URL_SCHEME) == 'rtmp') {
|
2016-10-14 17:16:52 +00:00
|
|
|
$process = $this->getRtmpProcess($video);
|
2017-04-24 17:16:38 +00:00
|
|
|
$chain = new Chain($process);
|
|
|
|
$chain->add('|', $this->getAvconvMp3Process('-'));
|
|
|
|
|
|
|
|
return popen($chain->getProcess()->getCommandLine(), 'r');
|
2016-07-29 22:15:17 +00:00
|
|
|
} else {
|
2017-04-24 17:16:38 +00:00
|
|
|
$avconvProc = $this->getAvconvMp3Process($video->url);
|
2016-09-07 22:28:28 +00:00
|
|
|
|
2017-05-02 09:20:36 +00:00
|
|
|
return popen($avconvProc->getCommandLine(), 'r');
|
2017-04-24 17:16:38 +00:00
|
|
|
}
|
2016-07-29 22:15:17 +00:00
|
|
|
}
|
2016-12-26 14:50:26 +00:00
|
|
|
|
2016-12-26 14:58:07 +00:00
|
|
|
/**
|
|
|
|
* Get video stream from an M3U playlist.
|
|
|
|
*
|
|
|
|
* @param \stdClass $video Video object returned by getJSON
|
|
|
|
*
|
|
|
|
* @return resource popen stream
|
|
|
|
*/
|
2016-12-26 14:50:26 +00:00
|
|
|
public function getM3uStream(\stdClass $video)
|
|
|
|
{
|
2017-05-13 22:52:59 +00:00
|
|
|
if (!$this->checkCommand([$this->config->avconv, '-version'])) {
|
2016-12-26 14:50:26 +00:00
|
|
|
throw(new \Exception('Can\'t find avconv or ffmpeg'));
|
|
|
|
}
|
|
|
|
|
|
|
|
$procBuilder = ProcessBuilder::create(
|
|
|
|
[
|
|
|
|
$this->config->avconv,
|
|
|
|
'-v', 'quiet',
|
|
|
|
'-i', $video->url,
|
|
|
|
'-f', $video->ext,
|
|
|
|
'-c', 'copy',
|
|
|
|
'-bsf:a', 'aac_adtstoasc',
|
|
|
|
'-movflags', 'frag_keyframe+empty_moov',
|
|
|
|
'pipe:1',
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
return popen($procBuilder->getProcess()->getCommandLine(), 'r');
|
|
|
|
}
|
2017-04-24 16:31:14 +00:00
|
|
|
|
2017-04-24 22:40:24 +00:00
|
|
|
/**
|
|
|
|
* Get an avconv stream to remux audio and video.
|
|
|
|
*
|
|
|
|
* @param array $urls URLs of the video ($urls[0]) and audio ($urls[1]) files
|
|
|
|
*
|
|
|
|
* @return resource popen stream
|
|
|
|
*/
|
|
|
|
public function getRemuxStream(array $urls)
|
|
|
|
{
|
|
|
|
$procBuilder = ProcessBuilder::create(
|
|
|
|
[
|
|
|
|
$this->config->avconv,
|
|
|
|
'-v', 'quiet',
|
|
|
|
'-i', $urls[0],
|
|
|
|
'-i', $urls[1],
|
|
|
|
'-c', 'copy',
|
|
|
|
'-map', '0:v:0 ',
|
|
|
|
'-map', '1:a:0',
|
|
|
|
'-f', 'matroska',
|
|
|
|
'pipe:1',
|
|
|
|
]
|
|
|
|
);
|
2017-04-24 22:41:49 +00:00
|
|
|
|
2017-04-24 22:40:24 +00:00
|
|
|
return popen($procBuilder->getProcess()->getCommandLine(), 'r');
|
|
|
|
}
|
|
|
|
|
2017-04-24 16:31:14 +00:00
|
|
|
/**
|
|
|
|
* Get video stream from an RTMP video.
|
|
|
|
*
|
|
|
|
* @param \stdClass $video Video object returned by getJSON
|
|
|
|
*
|
|
|
|
* @return resource popen stream
|
|
|
|
*/
|
|
|
|
public function getRtmpStream(\stdClass $video)
|
|
|
|
{
|
|
|
|
return popen($this->getRtmpProcess($video)->getCommandLine(), 'r');
|
|
|
|
}
|
2017-05-02 15:04:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a Tar stream containing every video in the playlist piped through the server.
|
|
|
|
*
|
2017-05-04 22:06:18 +00:00
|
|
|
* @param object $video Video object returned by youtube-dl
|
2017-05-02 15:04:55 +00:00
|
|
|
* @param string $format Requested format
|
|
|
|
*
|
|
|
|
* @return Response HTTP response
|
|
|
|
*/
|
2017-05-04 23:51:28 +00:00
|
|
|
public function getPlaylistArchiveStream(\stdClass $video, $format)
|
2017-05-02 15:04:55 +00:00
|
|
|
{
|
|
|
|
$playlistItems = [];
|
|
|
|
foreach ($video->entries as $entry) {
|
|
|
|
$playlistItems[] = urlencode($entry->url);
|
|
|
|
}
|
|
|
|
$stream = fopen('playlist://'.implode(';', $playlistItems).'/'.$format, 'r');
|
|
|
|
|
|
|
|
return $stream;
|
|
|
|
}
|
2014-03-13 19:07:56 +00:00
|
|
|
}
|