Skip to content

Commit

Permalink
removed getLowToHigh methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Athlon1600 committed Nov 11, 2023
1 parent d346b5f commit 331a808
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 35 deletions.
31 changes: 0 additions & 31 deletions src/DownloadOptions.php
Expand Up @@ -73,35 +73,4 @@ public function getFirstCombinedFormat(): ?StreamFormat
$combined = $this->getCombinedFormats();
return count($combined) ? $combined[0] : null;
}

protected function getLowToHighVideoFormats(): array
{
$copy = array_values($this->getVideoFormats());

usort($copy, function ($a, $b) {

/** @var StreamFormat $a */
/** @var StreamFormat $b */

return $a->height - $b->height;
});

return $copy;
}

protected function getLowToHighAudioFormats(): array
{
$copy = array_values($this->getAudioFormats());

// just assume higher filesize => higher quality...
usort($copy, function ($a, $b) {

/** @var StreamFormat $a */
/** @var StreamFormat $b */

return intval($a->contentLength) - intval($b->contentLength);
});

return $copy;
}
}
16 changes: 12 additions & 4 deletions src/Models/InitialPlayerResponse.php
Expand Up @@ -2,23 +2,31 @@

namespace YouTube\Models;

use YouTube\Utils\Utils;

/**
* Class InitialPlayerResponse
* JSON data that appears inside /watch?v= page [ytInitialPlayerResponse=]
* @package YouTube\Models
*/
class InitialPlayerResponse extends JsonObject
{
//public array $videoDetails;
//public array $microformat;
public ?array $responseContext = null;
public ?array $playabilityStatus = null;
public ?array $videoDetails = null;

public function isPlayabilityStatusOkay(): bool
{
return $this->deepGet('playabilityStatus.status') == 'OK';
}

/**
* If video is not playable, "reason" will include human-readable explanation
* @return string|null
*/
public function getPlayabilityStatusReason(): ?string
{
return $this->deepGet('playabilityStatus.reason');
}

public function getVideoDetails(): ?array
{
return $this->deepGet('videoDetails');
Expand Down
1 change: 1 addition & 0 deletions src/Models/StreamFormat.php
Expand Up @@ -6,6 +6,7 @@ class StreamFormat extends JsonObject
{
public ?int $itag = null;
public ?string $mimeType = null;
public ?string $bitrate = null;
public ?int $width = null;
public ?int $height = null;
public ?string $contentLength = null;
Expand Down
1 change: 1 addition & 0 deletions src/Responses/PlayerApiResponse.php
Expand Up @@ -20,6 +20,7 @@ protected function query(string $key)

public function getAllFormats(): array
{
// where both video and audio tracks are combined
$formats = $this->query('streamingData.formats');

// video only or audio only streams
Expand Down
3 changes: 3 additions & 0 deletions src/Responses/VideoPlayerJs.php
Expand Up @@ -2,6 +2,9 @@

namespace YouTube\Responses;

/**
* Response from: https://s.ytimg.com/yts/jsbin/player-fr_FR-vflHVjlC5/base.js
*/
class VideoPlayerJs extends HttpResponse
{
}

0 comments on commit 331a808

Please sign in to comment.