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/2.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Rudloff committed Jun 17, 2019
2 parents a0811c6 + 6a28011 commit b139e6e
Show file tree
Hide file tree
Showing 12 changed files with 400 additions and 282 deletions.
43 changes: 43 additions & 0 deletions classes/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ class Config
*/
private $file;

/**
* Generic formats supported by youtube-dl.
*
* @var array
*/
public $genericFormats = [];

/**
* Config constructor.
*
Expand All @@ -135,6 +142,42 @@ private function __construct(array $options = [])
{
$this->applyOptions($options);
$this->getEnv();

if (empty($this->genericFormats)) {
// We don't put this in the class definition so it can be detected by xgettext.
$this->genericFormats = [
'best' => _('Best'),
'bestvideo+bestaudio' => _('Remux best video with best audio'),
'worst' => _('Worst'),
];
}

foreach ($this->genericFormats as $format => $name) {
if (strpos($format, '+') !== false) {
if (!$this->remux) {
// Disable combined formats if remux mode is not enabled.
unset($this->genericFormats[$format]);
}
} elseif (!$this->stream) {
// Force HTTP if stream is not enabled.
$this->replaceGenericFormat($format, $format.'[protocol=https]/'.$format.'[protocol=http]');
}
}
}

/**
* Replace a format key.
*
* @param string $oldFormat Old format
* @param string $newFormat New format
*
* @return void
*/
private function replaceGenericFormat($oldFormat, $newFormat)
{
$keys = array_keys($this->genericFormats);
$keys[array_search($oldFormat, $keys)] = $newFormat;
$this->genericFormats = array_combine($keys, $this->genericFormats);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion classes/streams/YoutubeStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct(Video $video)

while ($rangeStart < $contentLenghtHeader[0]) {
$rangeEnd = $rangeStart + $video->downloader_options->http_chunk_size;
if ($rangeEnd > $contentLenghtHeader[0]) {
if ($rangeEnd >= $contentLenghtHeader[0]) {
$rangeEnd = $contentLenghtHeader[0] - 1;
}
$response = $video->getHttpResponse(['Range' => 'bytes='.$rangeStart.'-'.$rangeEnd]);
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"phpunit/phpunit": "~6.5.2",
"doctrine/instantiator": "~1.0.0",
"ffmpeg/ffmpeg": "4.0.3",
"rg3/youtube-dl": "2019.04.24",
"rg3/youtube-dl": "2019.06.08",
"heroku/heroku-buildpack-php": "*",
"anam/phantomjs-linux-x86-binary": "~2.1.1",
"phpstan/phpstan": "~0.9.2"
Expand All @@ -40,10 +40,10 @@
"type": "package",
"package": {
"name": "rg3/youtube-dl",
"version": "2019.04.24",
"version": "2019.06.08",
"dist": {
"type": "zip",
"url": "https://github.com/rg3/youtube-dl/archive/2019.04.24.zip"
"url": "https://github.com/rg3/youtube-dl/archive/2019.06.08.zip"
}
}
},
Expand Down
Loading

0 comments on commit b139e6e

Please sign in to comment.