feat: Split Youtube downloads in smaller chunks

Fixes #217
This commit is contained in:
Pierre Rudloff 2019-04-22 20:20:04 +02:00
parent bba2087a55
commit 1a6ff90eac
4 changed files with 256 additions and 5 deletions

View file

@ -24,6 +24,7 @@ use Symfony\Component\Process\Process;
* @property-read array $entries List of videos (if the object contains information about a playlist)
* @property-read array $rtmp_conn
* @property-read string|null $_type Object type (usually "playlist" or null)
* @property-read stdClass $downloader_options
*/
class Video
{
@ -62,6 +63,12 @@ class Video
*/
private $json;
/**
* URLs of the video files.
* @var array
*/
private $urls;
/**
* VideoDownload constructor.
*
@ -219,13 +226,16 @@ class Video
* */
public function getUrl()
{
$urls = explode("\n", $this->getProp('get-url'));
// Cache the URLs.
if (!isset($this->urls)) {
$this->urls = explode("\n", $this->getProp('get-url'));
if (empty($urls[0])) {
throw new EmptyUrlException(_('youtube-dl returned an empty URL.'));
if (empty($urls[0])) {
throw new EmptyUrlException(_('youtube-dl returned an empty URL.'));
}
}
return $urls;
return $this->urls;
}
/**