From 331a808e13fed5bb1a150ba57479d42ca72ff46a Mon Sep 17 00:00:00 2001 From: Athlon1600 Date: Sat, 11 Nov 2023 00:48:31 -0600 Subject: [PATCH] removed getLowToHigh methods --- src/DownloadOptions.php | 31 ---------------------------- src/Models/InitialPlayerResponse.php | 16 ++++++++++---- src/Models/StreamFormat.php | 1 + src/Responses/PlayerApiResponse.php | 1 + src/Responses/VideoPlayerJs.php | 3 +++ 5 files changed, 17 insertions(+), 35 deletions(-) diff --git a/src/DownloadOptions.php b/src/DownloadOptions.php index be50f76..29d8dc8 100644 --- a/src/DownloadOptions.php +++ b/src/DownloadOptions.php @@ -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; - } } \ No newline at end of file diff --git a/src/Models/InitialPlayerResponse.php b/src/Models/InitialPlayerResponse.php index 9abc15f..328e932 100644 --- a/src/Models/InitialPlayerResponse.php +++ b/src/Models/InitialPlayerResponse.php @@ -2,8 +2,6 @@ namespace YouTube\Models; -use YouTube\Utils\Utils; - /** * Class InitialPlayerResponse * JSON data that appears inside /watch?v= page [ytInitialPlayerResponse=] @@ -11,14 +9,24 @@ */ 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'); diff --git a/src/Models/StreamFormat.php b/src/Models/StreamFormat.php index 23b1a67..871b6a1 100644 --- a/src/Models/StreamFormat.php +++ b/src/Models/StreamFormat.php @@ -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; diff --git a/src/Responses/PlayerApiResponse.php b/src/Responses/PlayerApiResponse.php index 90cec8a..e475245 100644 --- a/src/Responses/PlayerApiResponse.php +++ b/src/Responses/PlayerApiResponse.php @@ -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 diff --git a/src/Responses/VideoPlayerJs.php b/src/Responses/VideoPlayerJs.php index 2890a51..b35a5c7 100644 --- a/src/Responses/VideoPlayerJs.php +++ b/src/Responses/VideoPlayerJs.php @@ -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 { } \ No newline at end of file