Reputation: 17616
For every video I upload, how do I request the youtube video id to get sent back as a response?
I'm not looking to retrieve the latest video id because I am uploading multiple video's at once. Is there a specific callback I can specify that when I insert, it'll send back a response with the video's youtube id?
Here is the small part of the code where I'm uploading a video. I've noticed that $media has a method called getHttpResultCode()
which returns 200
, which of course is not what I'm looking for.
$media = new \Google_Http_MediaFileUpload(
$this->client,
$insertRequest,
'video/*',
null,
true,
$chunkSizeBytes
);
$media->setFileSize(filesize($path));
$status = false;
$handle = fopen($path, "rb");
while(!$status && !feof($handle)){
$chunk = fread($handle, $chunkSizeBytes);
$status = $media->nextChunk($chunk);
}
fclose($handle);
Extras
I know there are multiple questions on how to get youtube's video id, however I'm not looking to do a second specific request. I'd like to get the video's youtube id back as a response.
Is that possible? If not what would be the second most logical way of getting what I want?
Upvotes: 0
Views: 249
Reputation: 17616
After some close examining, it would appear that $status is populated with a response once the video has been uploaded.
To access the response simply:
$media->setFileSize(filesize($path));
$status = false;
$handle = fopen($path, "rb");
while(!$status && !feof($handle)){
$chunk = fread($handle, $chunkSizeBytes);
$status = $media->nextChunk($chunk);
}
fclose($handle);
//$status['id'];
Here is a list of what gets returned:
{
"kind": "youtube#video",
"etag": etag,
"id": string,
"snippet": {
"publishedAt": datetime,
"channelId": string,
"title": string,
"description": string,
"thumbnails": {
(key): {
"url": string,
"width": unsigned integer,
"height": unsigned integer
}
},
"channelTitle": string,
"tags": [
string
],
"categoryId": string,
"liveBroadcastContent": string,
"defaultLanguage": string,
"localized": {
"title": string,
"description": string
},
"defaultAudioLanguage": string
},
"contentDetails": {
"duration": string,
"dimension": string,
"definition": string,
"caption": string,
"licensedContent": boolean,
"regionRestriction": {
"allowed": [
string
],
"blocked": [
string
]
},
"contentRating": {
"acbRating": string,
"agcomRating": string,
"anatelRating": string,
"bbfcRating": string,
"bfvcRating": string,
"bmukkRating": string,
"catvRating": string,
"catvfrRating": string,
"cbfcRating": string,
"cccRating": string,
"cceRating": string,
"chfilmRating": string,
"chvrsRating": string,
"cicfRating": string,
"cnaRating": string,
"cncRating": string,
"csaRating": string,
"cscfRating": string,
"czfilmRating": string,
"djctqRating": string,
"djctqRatingReasons": [,
string
],
"eefilmRating": string,
"egfilmRating": string,
"eirinRating": string,
"fcbmRating": string,
"fcoRating": string,
"fmocRating": string,
"fpbRating": string,
"fskRating": string,
"grfilmRating": string,
"icaaRating": string,
"ifcoRating": string,
"ilfilmRating": string,
"incaaRating": string,
"kfcbRating": string,
"kijkwijzerRating": string,
"kmrbRating": string,
"lsfRating": string,
"mccaaRating": string,
"mccypRating": string,
"mdaRating": string,
"medietilsynetRating": string,
"mekuRating": string,
"mibacRating": string,
"mocRating": string,
"moctwRating": string,
"mpaaRating": string,
"mtrcbRating": string,
"nbcRating": string,
"nbcplRating": string,
"nfrcRating": string,
"nfvcbRating": string,
"nkclvRating": string,
"oflcRating": string,
"pefilmRating": string,
"rcnofRating": string,
"resorteviolenciaRating": string,
"rtcRating": string,
"rteRating": string,
"russiaRating": string,
"skfilmRating": string,
"smaisRating": string,
"smsaRating": string,
"tvpgRating": string,
"ytRating": string
}
},
"status": {
"uploadStatus": string,
"failureReason": string,
"rejectionReason": string,
"privacyStatus": string,
"publishAt": datetime,
"license": string,
"embeddable": boolean,
"publicStatsViewable": boolean
},
"statistics": {
"viewCount": unsigned long,
"likeCount": unsigned long,
"dislikeCount": unsigned long,
"favoriteCount": unsigned long,
"commentCount": unsigned long
},
"player": {
"embedHtml": string
},
"topicDetails": {
"topicIds": [
string
],
"relevantTopicIds": [
string
]
},
"recordingDetails": {
"locationDescription": string,
"location": {
"latitude": double,
"longitude": double,
"altitude": double
},
"recordingDate": datetime
},
"fileDetails": {
"fileName": string,
"fileSize": unsigned long,
"fileType": string,
"container": string,
"videoStreams": [
{
"widthPixels": unsigned integer,
"heightPixels": unsigned integer,
"frameRateFps": double,
"aspectRatio": double,
"codec": string,
"bitrateBps": unsigned long,
"rotation": string,
"vendor": string
}
],
"audioStreams": [
{
"channelCount": unsigned integer,
"codec": string,
"bitrateBps": unsigned long,
"vendor": string
}
],
"durationMs": unsigned long,
"bitrateBps": unsigned long,
"recordingLocation": {
"latitude": double,
"longitude": double,
"altitude": double
},
"creationTime": string
},
"processingDetails": {
"processingStatus": string,
"processingProgress": {
"partsTotal": unsigned long,
"partsProcessed": unsigned long,
"timeLeftMs": unsigned long
},
"processingFailureReason": string,
"fileDetailsAvailability": string,
"processingIssuesAvailability": string,
"tagSuggestionsAvailability": string,
"editorSuggestionsAvailability": string,
"thumbnailsAvailability": string
},
"suggestions": {
"processingErrors": [
string
],
"processingWarnings": [
string
],
"processingHints": [
string
],
"tagSuggestions": [
{
"tag": string,
"categoryRestricts": [
string
]
}
],
"editorSuggestions": [
string
]
},
"liveStreamingDetails": {
"actualStartTime": datetime,
"actualEndTime": datetime,
"scheduledStartTime": datetime,
"scheduledEndTime": datetime,
"concurrentViewers": unsigned long
},
"localizations": {
(key): {
"title": string,
"description": string
}
}
}
Upvotes: 0