-
Notifications
You must be signed in to change notification settings - Fork 310
/
InitialPlayerResponse.php
39 lines (33 loc) · 1001 Bytes
/
InitialPlayerResponse.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
namespace YouTube\Models;
/**
* Class InitialPlayerResponse
* JSON data that appears inside /watch?v= page [ytInitialPlayerResponse=]
* @package YouTube\Models
*/
class InitialPlayerResponse extends JsonObject
{
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');
}
public function getCaptionTracks(): array
{
return (array)$this->deepGet("captions.playerCaptionsTracklistRenderer.captionTracks");
}
}