00001 <?php
00002
00003 require_once('mediaService.php');
00004
00009 class youtubeService extends mediaService {
00010
00014 var $regex = array(
00015 '@youtube\.com/v/([^"\& ]+)@i',
00016 '@youtube\.com/watch\?v=([^"\& ]+)@i',
00017 '@youtube\.com/\?v=([^"\& ]+)@i',
00018 );
00019
00023 var $search_url = 'http://gdata.youtube.com/feeds/api/videos?q=%s&caption&v=2';
00024
00030 function captionsMissing($link_url) {
00031
00032 if($code = $this->isYouTubeVideo($link_url)) {
00033 $result = file_get_contents(sprintf($this->search_url, $code));
00034 if(!$result) {
00035 return false;
00036 }
00037 if (strpos($result, 'video:'. $code) === false) {
00038 return true;
00039 }
00040 }
00041 return false;
00042 }
00043
00050 private function isYouTubeVideo($link_url) {
00051 $matches = null;
00052 foreach($this->regex as $pattern) {
00053 if(preg_match($pattern, trim($link_url), $matches)) {
00054 return $matches[1];
00055 }
00056 }
00057 return false;
00058 }
00059 }