Reputation: 3415
I'm looking to return the schedule date for a stream in YouTube.
YT Link: https://www.youtube.com/channel/UCP7jMXSY2xbc3KCAE0MHQ-A
This is my code to pull this data out using the YouTube v3 API:
$videos = $this->yt->searchAdvanced(array(
'q' => '',
'part' => 'snippet',
'channelId' => $this->channel_id,
'eventType' => $event_type, // Upcoming
'type' => 'video',
'order' => 'date',
'maxResults' => $max,
'key' => YOUTUBE_API_KEY
));
Here is the object that is returned from this:
If I use my function to get video info this is all the information I can get. This is using parts:
id, snippet, contentDetails, player, statistics, status
: Where is the scheduled date? :
stdClass Object
(
[kind] => youtube#video
[etag] => "q5k97EMVGxODeKcDgp8gnMu79wM/KAZsrzeX5ImiUQpLbwhPR7lo9mA"
[id] => qUAmTYHEyM8
[snippet] => stdClass Object
(
[publishedAt] => 2016-03-03T06:48:50.000Z
[channelId] => UCP7jMXSY2xbc3KCAE0MHQ-A
[title] => Match 3 - Google DeepMind Challenge Match: Lee Sedol vs AlphaGo
[description] => Watch DeepMind's program AlphaGo take on the legendary Lee Sedol (9-dan pro), the top Go player of the past decade, in a $1M 5-game challenge match in Seoul. This is the livestream for Match 3 to be played on: 12th March 13:00 KST (local), 04:00 GMT; note for US viewers this is the day before on: 11th March 20:00 PT, 23:00 ET.
In October 2015, AlphaGo became the first computer program ever to beat a professional Go player by winning 5-0 against the reigning 3-times European Champion Fan Hui (2-dan pro). That work was featured in a front cover article in the science journal Nature in January 2016.
Match commentary by Michael Redmond (9-dan pro) and Chris Garlock.
[thumbnails] => stdClass Object
(
[default] => stdClass Object
(
[url] => https://i.ytimg.com/vi/qUAmTYHEyM8/default_live.jpg
[width] => 120
[height] => 90
)
[medium] => stdClass Object
(
[url] => https://i.ytimg.com/vi/qUAmTYHEyM8/mqdefault_live.jpg
[width] => 320
[height] => 180
)
[high] => stdClass Object
(
[url] => https://i.ytimg.com/vi/qUAmTYHEyM8/hqdefault_live.jpg
[width] => 480
[height] => 360
)
[standard] => stdClass Object
(
[url] => https://i.ytimg.com/vi/qUAmTYHEyM8/sddefault_live.jpg
[width] => 640
[height] => 480
)
[maxres] => stdClass Object
(
[url] => https://i.ytimg.com/vi/qUAmTYHEyM8/maxresdefault_live.jpg
[width] => 1280
[height] => 720
)
)
[channelTitle] => DeepMind
[categoryId] => 28
[liveBroadcastContent] => upcoming
[localized] => stdClass Object
(
[title] => Match 3 - Google DeepMind Challenge Match: Lee Sedol vs AlphaGo
[description] => Watch DeepMind's program AlphaGo take on the legendary Lee Sedol (9-dan pro), the top Go player of the past decade, in a $1M 5-game challenge match in Seoul. This is the livestream for Match 3 to be played on: 12th March 13:00 KST (local), 04:00 GMT; note for US viewers this is the day before on: 11th March 20:00 PT, 23:00 ET.
In October 2015, AlphaGo became the first computer program ever to beat a professional Go player by winning 5-0 against the reigning 3-times European Champion Fan Hui (2-dan pro). That work was featured in a front cover article in the science journal Nature in January 2016.
Match commentary by Michael Redmond (9-dan pro) and Chris Garlock.
)
)
[contentDetails] => stdClass Object
(
[duration] => PT0S
[dimension] => 2d
[definition] => sd
[caption] => false
[licensedContent] => 1
)
[status] => stdClass Object
(
[uploadStatus] => uploaded
[privacyStatus] => public
[license] => youtube
[embeddable] => 1
[publicStatsViewable] => 1
)
[statistics] => stdClass Object
(
[viewCount] => 41
[likeCount] => 1
[dislikeCount] => 0
[favoriteCount] => 0
[commentCount] => 0
)
[player] => stdClass Object
(
[embedHtml] =>
)
)
Note that the published date I highlighted is NOT the schedule date.
As you can see there is no scheduled date. Do I need to pass more data to 'part'? Their API suggests there's no more data that can be pulled back too.
https://developers.google.com/youtube/v3/docs/search/list#request
Thanks
Upvotes: 6
Views: 3513
Reputation: 11183
The YouTube Live Streaming API's list
documentation has a relevant example:
list (by broadcast status)
...retrieve information about all, active, completed, or upcoming live broadcasts. Note that the broadcastStatus parameter is also set to all to ensure that all matching broadcasts are included in the response.
GET https://www.googleapis.com/youtube/v3/liveBroadcasts?part=snippet%2CcontentDetails%2Cstatus&broadcastStatus=active&broadcastType=all&key=[YOUR_API_KEY] HTTP/1.1 Authorization: Bearer [YOUR_ACCESS_TOKEN] Accept: application/json
The start time can be found in the part=liveStreamingDetails
, which will contain scheduledStartTime
in ISO format, and activeLiveChatId
.
Upvotes: 2
Reputation: 3415
Okay I worked it out.
Simply add liveStreamingDetails
to the part
parameter.
I was trying to achieve this through search.list
. Instead use the videos.list
with liveStreamingDetails
to get the schedule date as search.list
doesn't support liveStreamingDetails
.
Cheers
Upvotes: 14