Skip to content

Commit e70b905

Browse files
committed
Merge pull request #130 from ucfcdl/UDOIT_issue122
Updated YouTube Data Api for captions according to YouTube documentation
2 parents 320327a + d3455bd commit e70b905

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

lib/quail/quail/common/services/media/youtube.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class youtubeService extends mediaService
2828
/**
2929
* @var string The service point to request caption data from YouTube
3030
*/
31-
var $search_url = 'https://www.googleapis.com/youtube/v3/videos?part=contentDetails&key=AIzaSyCwO6Tun63CCe-iLiQV0BrJdulvdpb2veQ&id=';
31+
var $search_url = 'https://www.googleapis.com/youtube/v3/videos?part=contentDetails&id=';
3232

3333
/**
3434
* Checks to see if a video is missing caption information in YouTube
@@ -38,7 +38,7 @@ class youtubeService extends mediaService
3838
function captionsMissing($link_url)
3939
{
4040

41-
$url = 'https://www.googleapis.com/youtube/v3/videos?part=contentDetails&id=';
41+
$url = 'https://www.googleapis.com/youtube/v3/captions?part=id&videoId='; //'https://www.googleapis.com/youtube/v3/videos?part=contentDetails&id=';
4242
$api_key = constant( 'GOOGLE_API_KEY' );
4343

4444
if( $youtube_id = $this->isYouTubeVideo($link_url) ) {
@@ -51,11 +51,7 @@ function captionsMissing($link_url)
5151

5252
// If the video was pulled due to copyright violations, the items array will be empty.
5353
// TODO: Make this return a different error, warning the instructor that the video is no longer available
54-
if( empty($response->body->items) ){
55-
return true;
56-
}
57-
58-
return ($response->body->items[0]->contentDetails->caption == 'true')? false: true;
54+
return ( empty($response->body->items) )? true : false;
5955
}
6056

6157
return false;

0 commit comments

Comments
 (0)