Ejemplo n.º 1
1
 public static function getVideoData($videoid, $customimage, $customtitle, $customdescription)
 {
     $theTitle = '';
     $Description = '';
     $theImage = '';
     //if($firstvideo=='')
     //$firstvideo=$videoid;
     $XML_SOURCE = '';
     if ($customimage != '') {
         $theImage = $customimage;
     } else {
         if (ini_get('allow_url_fopen')) {
             $XML_SOURCE = YouTubeGalleryMisc::getURLData('http://video.google.com/videofeed?docid=' . $videoid);
             $match = array();
             preg_match("/media:thumbnail url=\"([^\"]\\S*)\"/siU", $XML_SOURCE, $match);
             $theImage = $match[1];
         }
         //if(ini_get('allow_url_fopen'))
     }
     //if($customimage!='')
     $theTitle = 'Google Video';
     if ($customtitle != '') {
         $theTitle = $customtitle;
     }
     if ($customdescription != '') {
         $Description = $customdescription;
     }
     return array('videosource' => 'google', 'videoid' => $videoid, 'imageurl' => $theImage, 'title' => $theTitle, 'description' => $Description);
 }
Ejemplo n.º 2
0
 public static function getVideoData($videoid, $customimage, $customtitle, $customdescription)
 {
     $theTitle = '';
     $Description = '';
     $theImage = '';
     $videodata = array();
     if (phpversion() < 5) {
         return "Update to PHP 5+";
     }
     try {
         $url = 'http://api.own3d.tv/rest/video/list.xml?videoid=' . $videoid;
         $htmlcode = YouTubeGalleryMisc::getURLData($url);
         if (strpos($htmlcode, '<?xml version') === false) {
             $pair = array('Invalid id', 'Invalid id', '', '0', '0', '0', '0', '0', '0', '0', '');
             return $pair;
         }
         $doc = new DOMDocument();
         $doc->loadXML($htmlcode);
         $video_thumb_file_small = 'http://owned.vo.llnwd.net/v1/static/static/images/thumbnails/tn_' . $videoid . '__1.jpg';
         $videodata = array('videosource' => 'own3dtvvideo', 'videoid' => $videoid, 'imageurl' => $video_thumb_file_small, 'title' => $doc->getElementsByTagName("video_name")->item(0)->nodeValue, 'description' => $doc->getElementsByTagName("video_description")->item(0)->nodeValue, 'publisheddate' => "", 'duration' => $doc->getElementsByTagName("video_duration")->item(0)->nodeValue, 'rating_average' => 0, 'rating_max' => 0, 'rating_min' => 0, 'rating_numRaters' => 0, 'statistics_favoriteCount' => 0, 'statistics_viewCount' => $doc->getElementsByTagName("video_views_total")->item(0)->nodeValue, 'keywords' => '');
         return $videodata;
     } catch (Exception $e) {
         return 'cannot get youtube video data';
     }
     return array('videosource' => 'own3dtvvideo', 'videoid' => $videoid, 'imageurl' => $theImage, 'title' => $theTitle, 'description' => $Description);
 }
 public static function getVideoIDList($URL, $optionalparameters, &$playlistid, &$datalink)
 {
     //https://api.dailymotion.com/playlist/xy4h8/videos
     $videolist = array();
     $playlistid = VideoSource_DailymotionPlaylist::extractDailymotionPlayListID($URL);
     if ($playlistid == '') {
         return $videolist;
     }
     //playlist id not found
     $apiurl = 'https://api.dailymotion.com/playlist/' . $playlistid . '/videos';
     $datalink = $apiurl;
     $htmlcode = YouTubeGalleryMisc::getURLData($apiurl);
     if ($htmlcode == '') {
         return $videolist;
     }
     if (!isset($htmlcode) or $htmlcode == '' or $htmlcode[0] != '{') {
         return 'Cannot load data, no connection or access denied';
     }
     $streamData = json_decode($htmlcode);
     foreach ($streamData->list as $entry) {
         $videolist[] = 'http://www.dailymotion.com/playlist/' . $entry->id;
         //http://www.dailymotion.com/playlist/x1crql_BigCatRescue_funny-action-big-cats/1#video=x986zk
         //$media = $entry->children('http://search.yahoo.com/mrss/');
         //$link = $media->group->player->attributes();
         //if(isset($link))
         //{
         //	if(isset($link['url']))
         //	{
         ///		$videolist[] = $link['url'];
         //	}
         //}//if(isset($link)
     }
     //foreach ($xml->entry as $entry)
     return $videolist;
 }
Ejemplo n.º 4
0
 public static function getVideoData($videoid, $customimage, $customtitle, $customdescription)
 {
     //API
     //http://www.dailymotion.com/doc/api/obj-video.html
     $theTitle = '';
     $Description = '';
     $theImage = '';
     $fields = 'created_time,description,duration,rating,ratings_total,thumbnail_small_url,thumbnail_medium_url,title,views_total';
     $HTML_SOURCE = YouTubeGalleryMisc::getURLData('https://api.dailymotion.com/video/' . $videoid . '?fields=' . $fields);
     //echo '$HTML_SOURCE='.$HTML_SOURCE.'<br/>';
     if ($HTML_SOURCE != '' and $HTML_SOURCE[0] == '{') {
         $streamData = json_decode($HTML_SOURCE);
         if ($customimage == '') {
             $theImage = $streamData->thumbnail_small_url;
         } else {
             $theImage = $customimage;
         }
         if ($customtitle == '') {
             $theTitle = $streamData->title;
         } else {
             $theTitle = $customtitle;
         }
         if ($customdescription == '') {
             $Description = $streamData->description;
         } else {
             $Description = $customdescription;
         }
         $videodata = array('videosource' => 'dailymotion', 'videoid' => $videoid, 'imageurl' => $theImage, 'title' => $theTitle, 'description' => $Description, 'publisheddate' => date('Y-m-d H:i:s', $streamData->created_time), 'duration' => $streamData->duration, 'rating_average' => $streamData->rating, 'rating_max' => $streamData->ratings_total, 'rating_min' => 0, 'rating_numRaters' => 0, 'statistics_favoriteCount' => 0, 'statistics_viewCount' => $streamData->views_total, 'keywords' => '');
         return $videodata;
     } else {
         return array('videosource' => 'collegehumor', 'videoid' => $videoid, 'imageurl' => $theImage, 'title' => '***Video not found***', 'description' => $Description);
     }
 }
Ejemplo n.º 5
0
 public static function getVideoData($videoid, $customimage, $customtitle, $customdescription)
 {
     $theTitle = '';
     $Description = '';
     $theImage = '';
     $Url = 'https://api.present.me/v1/oEmbed?url=https://https://present.me/view/' . $videoid . '&amp;format=json';
     $HTML_SOURCE = YouTubeGalleryMisc::getURLData($Url);
     if ($HTML_SOURCE != '' and $HTML_SOURCE[0] == '{') {
         $streamData = json_decode($HTML_SOURCE);
         if ($customimage == '') {
             $theImage = $streamData->thumbnail_url;
         } else {
             $theImage = $customimage;
         }
         if ($customtitle == '') {
             $theTitle = $streamData->title;
         } else {
             $theTitle = $customtitle;
         }
         if ($customdescription == '') {
             $Description = '';
         } else {
             $Description = $customdescription;
         }
         $videodata = array('videosource' => 'presentme', 'videoid' => $videoid, 'imageurl' => $theImage, 'title' => $theTitle, 'description' => $Description, 'publisheddate' => '', 'duration' => 0, 'rating_average' => 0, 'rating_max' => 0, 'rating_min' => 0, 'rating_numRaters' => 0, 'statistics_favoriteCount' => 0, 'statistics_viewCount' => 0, 'keywords' => '', 'channel_username' => $streamData->provider_name, 'channel_title' => $streamData->author_name);
         //print_r($videodata);
         //die;
         return $videodata;
     } else {
         return array('videosource' => 'collegehumor', 'videoid' => $videoid, 'imageurl' => $theImage, 'title' => '***Video not found***', 'description' => $Description);
     }
 }
Ejemplo n.º 6
0
 public static function getVideoIDList($youtubeURL, $optionalparameters, &$userid)
 {
     $optionalparameters_arr = explode(',', $optionalparameters);
     $videolist = array();
     $spq = implode('&', $optionalparameters_arr);
     $userid = VideoSource_YoutubeUserFavorites::extractYouTubeUserID($youtubeURL);
     if ($userid == '') {
         return $videolist;
     }
     //user id not found
     $url = 'http://gdata.youtube.com/feeds/api/users/' . $userid . '/favorites?v=2' . ($spq != '' ? '&' . $spq : '');
     //&max-results=10
     $xml = false;
     $htmlcode = YouTubeGalleryMisc::getURLData($url);
     if (strpos($htmlcode, '<?xml version') === false) {
         if (strpos($htmlcode, 'Invalid id') === false) {
             return 'Cannot load data, Invalid id';
         }
         return 'Cannot load data, no connection';
     }
     $xml = simplexml_load_string($htmlcode);
     if ($xml) {
         foreach ($xml->entry as $entry) {
             $attr = $entry->link[0]->attributes();
             if (isset($entry->link[0]) && $attr['rel'] == 'alternate') {
                 $videolist[] = $attr['href'];
             } else {
                 $attr = $entry->link[1]->attributes();
                 $videolist[] = $attr['href'];
             }
         }
     }
     return $videolist;
 }
Ejemplo n.º 7
0
 public static function getVideoData($videoid, $customimage, $customtitle, $customdescription)
 {
     $theTitle = '';
     $Description = '';
     $theImage = '';
     $HTML_SOURCE = YouTubeGalleryMisc::getURLData('http://www.ustream.tv/recorded/' . $videoid);
     if ($HTML_SOURCE != '' and $HTML_SOURCE[0] == '<') {
         if ($customimage != '') {
             $theImage = $customimage;
         } else {
             $theImage = VideoSource_Ustream::getValueByAlmostTag($HTML_SOURCE, '<meta property="og:image" content="');
             $theImage = str_replace(',', '%2C', $theImage);
         }
         if ($customtitle == '') {
             $theTitle = VideoSource_Ustream::getValueByAlmostTag($HTML_SOURCE, '<meta property="og:title" content="');
         } else {
             $theTitle = $customtitle;
         }
         if ($customdescription == '') {
             $Description = VideoSource_Ustream::getValueByAlmostTag($HTML_SOURCE, '<meta property="og:description" content="');
         } else {
             $Description = $customdescription;
         }
         $videodata = array('videosource' => 'ustream', 'videoid' => $videoid, 'imageurl' => $theImage, 'title' => $theTitle, 'description' => $Description, 'publisheddate' => VideoSource_Ustream::getValueByAlmostTag($HTML_SOURCE, '<span data-dateformat="%F %j at %g:%i%a" data-timestamp="'), 'duration' => 0, 'rating_average' => 0, 'rating_max' => 0, 'rating_min' => 0, 'rating_numRaters' => 0, 'statistics_favoriteCount' => 0, 'statistics_viewCount' => 0, 'keywords' => '');
         return $videodata;
     } else {
         return array('videosource' => 'collegehumor', 'videoid' => $videoid, 'imageurl' => $theImage, 'title' => '***Video not found***', 'description' => $Description);
     }
 }
Ejemplo n.º 8
0
 public static function getVideoData($videoid, $customimage, $customtitle, $customdescription)
 {
     $theTitle = '';
     $Description = '';
     $theImage = '';
     $HTML_SOURCE = YouTubeGalleryMisc::getURLData('http://www.collegehumor.com/video/' . $videoid);
     $strPart = '<meta name="og:image" content="';
     $strPartLength = strlen($strPart);
     $p1 = strpos($HTML_SOURCE, $strPart);
     if ($p1 > 0) {
         $p2 = strpos($HTML_SOURCE, '"', $p1 + $strPartLength);
         $theImage = substr($HTML_SOURCE, $p1 + $strPartLength, $p2 - $p1 - $strPartLength);
         $theImage = str_replace('\\', '', $theImage);
     }
     if ($theImage == '') {
         return array('videosource' => 'collegehumor', 'videoid' => $videoid, 'imageurl' => $theImage, 'title' => '***Video not found***', 'description' => $Description);
     }
     if ($customimage != '') {
         $theImage = $customimage;
     }
     if ($customtitle == '') {
         if (ini_get('allow_url_fopen')) {
             $theTitle = 'CollegeHumor';
             $strPart = '<meta name="og:title" content="';
             $strPartLength = strlen($strPart);
             $p1 = strpos($HTML_SOURCE, $strPart);
             if ($p1 > 0) {
                 $p2 = strpos($HTML_SOURCE, '"', $p1 + $strPartLength);
                 $theTitle = substr($HTML_SOURCE, $p1 + $strPartLength, $p2 - $p1 - $strPartLength);
             }
         }
         //if(ini_get('allow_url_fopen'))
     } else {
         $theTitle = $customtitle;
     }
     if ($customdescription == '') {
         if (ini_get('allow_url_fopen')) {
             $Description = 'CollegeHumor';
             $strPart = '<meta name="description" content="';
             $strPartLength = strlen($strPart);
             $p1 = strpos($HTML_SOURCE, $strPart);
             if ($p1 > 0) {
                 $p2 = strpos($HTML_SOURCE, '"', $p1 + $strPartLength);
                 $Description = substr($HTML_SOURCE, $p1 + $strPartLength, $p2 - $p1 - $strPartLength);
             }
         }
         //if(ini_get('allow_url_fopen'))
     } else {
         $Description = $customdescription;
     }
     return array('videosource' => 'collegehumor', 'videoid' => $videoid, 'imageurl' => $theImage, 'title' => $theTitle, 'description' => $Description);
 }
Ejemplo n.º 9
0
 public static function extractBreakID($theLink, &$HTML_SOURCE)
 {
     if ($HTML_SOURCE == '') {
         $HTML_SOURCE = YouTubeGalleryMisc::getURLData($theLink);
     }
     $ActualLink = VideoSource_Break::getValueByAlmostTag($HTML_SOURCE, '<meta name="embed_video_url" content="');
     preg_match('/break.com\\/(\\d+)$/', $ActualLink, $matches);
     if (count($matches) != 0) {
         $video_id = $matches[1];
         return $video_id;
     }
     return '';
 }
Ejemplo n.º 10
0
 public static function getVideoData($videoid, $customimage, $customtitle, $customdescription)
 {
     //blank	array
     $blankArray = array('videosource' => 'soundcloud', 'videoid' => $videoid, 'imageurl' => '', 'title' => '', 'description' => '', 'publisheddate' => '', 'duration' => 0, 'rating_average' => 0, 'rating_max' => 0, 'rating_min' => 0, 'rating_numRaters' => 0, 'statistics_favoriteCount' => 0, 'statistics_viewCount' => 0, 'keywords' => '', 'likes' => 0, 'dislikes' => '', 'commentcount' => '', 'channel_username' => '', 'channel_title' => '', 'channel_subscribers' => 0, 'channel_subscribed' => 0, 'channel_location' => '', 'channel_commentcount' => 0, 'channel_viewcount' => 0, 'channel_videocount' => 0, 'channel_description' => '');
     $theTitle = '';
     $Description = '';
     $theImage = '';
     require_once JPATH_SITE . DS . 'components' . DS . 'com_youtubegallery' . DS . 'includes' . DS . 'misc.php';
     $client_id = YouTubeGalleryMisc::getSettingValue('soundcloud_api_client_id');
     //$consumer_secret = YouTubeGalleryMisc::getSettingValue('soundcloud_api_client_secret');
     $url = 'http://api.soundcloud.com/tracks/' . $videoid . '.json?client_id=' . $client_id;
     //echo '$url='.$url.'<br/>';
     $HTML_SOURCE = YouTubeGalleryMisc::getURLData($url);
     if ($HTML_SOURCE == '') {
         $blankArray['title'] = '***Video not found***';
         $blankArray['description'] = '';
         return $blankArray;
     }
     //-----------------------------------------------------------------------------------------------
     $strPart = '{"kind":"track","id":';
     $strPartLength = strlen($strPart);
     $test = substr($HTML_SOURCE, 0, $strPartLength);
     if ($test != $strPart) {
         $blankArray['title'] = '***Cannot Connect to SoundCloud Server***';
         $blankArray['description'] = 'Check your API Client ID (go to Setting).';
         return $blankArray;
     }
     $obj = json_decode($HTML_SOURCE);
     $blankArray['title'] = $obj->title;
     $blankArray['description'] = $obj->description;
     $blankArray['publisheddate'] = $obj->created_at;
     $blankArray['duration'] = floor($obj->duration / 1000);
     $blankArray['keywords'] = $obj->tag_list;
     $blankArray['statistics_viewCount'] = $obj->playback_count;
     $blankArray['statistics_favoriteCount'] = $obj->favoritings_count;
     $blankArray['commentcount'] = $obj->comment_count;
     $blankArray['imageurl'] = $obj->artwork_url;
     $u = $obj->user;
     $blankArray['channel_username'] = $u->username;
     $blankArray['channel_title'] = $u->username;
     if ($customtitle != '') {
         $blankArray['title'] = $customtitle;
     }
     if ($customdescription != '') {
         $blankArray['description'] = $customdescription;
     }
     if ($customimage != '' and strpos($customimage, '#') === false) {
         $blankArray['imageurl'] = $customimage;
     }
     return $blankArray;
 }
 public static function getVideoIDList($URL, $optionalparameters, &$playlistid)
 {
     //https://api.dailymotion.com/playlist/xy4h8/videos
     //$optionalparameters_arr=explode(',',$optionalparameters);
     //$videolist=array();
     //$spq=implode('&',$optionalparameters_arr);
     $videolist = array();
     $playlistid = VideoSource_DailymotionPlaylist::extractDailymotionPlayListID($URL);
     if ($playlistid == '') {
         return $videolist;
     }
     //playlist id not found
     //echo '$playlistid='.$playlistid.'<br/>';
     $apiurl = 'https://api.dailymotion.com/playlist/' . $playlistid . '/videos';
     //$apiurl = 'https://api.dailymotion.com/playlist/xy4h8/videos';
     //echo '$apiurl ='.$apiurl .'<br/>';
     //$xml=false;
     $htmlcode = YouTubeGalleryMisc::getURLData($apiurl);
     //echo '$htmlcode='.$htmlcode.'<br/>';
     //die;
     if (!isset($htmlcode) or $htmlcode == '' or $htmlcode[0] != '{') {
         //if(strpos($htmlcode,'Invalid id')===false)
         //	return 'Cannot load data, Invalid id';
         return 'Cannot load data, no connection or access denied';
     }
     $streamData = json_decode($htmlcode);
     //                print_r($streamData );
     foreach ($streamData->list as $entry) {
         //print_r($entry);
         $videolist[] = 'http://www.dailymotion.com/playlist/' . $entry->id;
         //http://www.dailymotion.com/playlist/x1crql_BigCatRescue_funny-action-big-cats/1#video=x986zk
         //$media = $entry->children('http://search.yahoo.com/mrss/');
         //$link = $media->group->player->attributes();
         //if(isset($link))
         //{
         //	if(isset($link['url']))
         //	{
         ///		$videolist[] = $link['url'];
         //	}
         //}//if(isset($link)
     }
     //foreach ($xml->entry as $entry)
     //print_r($videolist);
     //die;
     return $videolist;
 }
Ejemplo n.º 12
0
 public static function getVideoData($videoid, $customimage, $customtitle, $customdescription, $theLink)
 {
     echo '<!-- ';
     $theTitle = '';
     $Description = '';
     $theImage = '';
     $XML_SOURCE = YouTubeGalleryMisc::getURLData('http://video.yahoo.com/services/oembed?url=' . $theLink);
     if ($customimage == '') {
         $p1 = strpos($XML_SOURCE, 'thumbUrl=');
         if ($p1 > 0) {
             $p2 = strpos($XML_SOURCE, '.jpg', $p1);
             $theImage = substr($XML_SOURCE, $p1 + 9, $p2 - $p1 - 9 + 4);
             $theImage = str_replace('\\', '', $theImage);
         }
     } else {
         $theImage = $customimage;
     }
     if ($customtitle == '') {
         if (ini_get('allow_url_fopen')) {
             $theTitle = 'Yahoo Video';
             $p1 = strpos($XML_SOURCE, '"title":"');
             if ($p1 > 0) {
                 $p2 = strpos($XML_SOURCE, '"', $p1 + 9);
                 $theTitle = substr($XML_SOURCE, $p1 + 9, $p2 - $p1 - 9);
             }
         }
         //if(ini_get('allow_url_fopen'))
     } else {
         $theTitle = $customtitle;
     }
     if ($customdescription == '') {
         if (ini_get('allow_url_fopen')) {
             $Description = 'Yahoo Video';
             $p1 = strpos($XML_SOURCE, '"description":"');
             if ($p1 > 0) {
                 $p2 = strpos($XML_SOURCE, '"', $p1 + 9);
                 $Description = substr($XML_SOURCE, $p1 + 9, $p2 - $p1 - 9);
             }
         }
         //if(ini_get('allow_url_fopen'))
     } else {
         $Description = $customdescription;
     }
     echo ' -->';
     return array('videosource' => 'yahoo', 'videoid' => $videoid, 'imageurl' => $theImage, 'title' => $theTitle, 'description' => $Description);
 }
Ejemplo n.º 13
0
 public static function getUserInfo($youtubeURL, &$item)
 {
     $userid = VideoSource_YoutubeUserUploads::extractYouTubeUserID($youtubeURL);
     if ($userid == '') {
         return 'user id not found';
     }
     $url = 'http://gdata.youtube.com/feeds/api/users/' . $userid;
     $xml = false;
     $htmlcode = YouTubeGalleryMisc::getURLData($url);
     if (strpos($htmlcode, '<?xml version') === false) {
         if (strpos($htmlcode, 'Invalid id') === false) {
             return 'Cannot load data, Invalid id';
         }
         return 'Cannot load data, no connection';
     }
     echo '$htmlcode=' . $htmlcode . '<br/>';
     //die;
     $doc = new DOMDocument();
     $doc->loadXML($htmlcode);
     $item['channel_username'] = $doc->getElementsByTagName("username")->item(0)->nodeValue;
     $item['channel_title'] = $doc->getElementsByTagName("title")->item(0)->nodeValue;
     $item['channel_description'] = $doc->getElementsByTagName("content")->item(0)->nodeValue;
     $item['channel_location'] = $doc->getElementsByTagName("location")->item(0)->nodeValue;
     $feedLink = $doc->getElementsByTagName("feedLink");
     if ($feedLink->length > 0) {
         foreach ($feedLink as $fe) {
             $rel = $fe->getAttribute("rel");
             if (!(strpos($rel, '#user.subscriptions') === false)) {
                 $item['channel_subscribed'] = $fe->getAttribute("countHint");
             }
             if (!(strpos($rel, '#user.contacts') === false)) {
                 $item['channel_commentcount'] = $fe->getAttribute("countHint");
             }
             if (!(strpos($rel, '#user.uploads') === false)) {
                 $item['channel_videocount'] = $fe->getAttribute("countHint");
             }
         }
     }
     $statistics = $doc->getElementsByTagName("statistics");
     $se = $statistics->item(0);
     $item['channel_subscribers'] = $se->getAttribute("subscriberCount");
     $item['channel_viewcount'] = $se->getAttribute("viewCount");
     $item['channel_totaluploadviews'] = $se->getAttribute("totalUploadViews");
     return '';
 }
Ejemplo n.º 14
0
 public static function getVideoIDList($youtubeURL, $optionalparameters, &$playlistid)
 {
     $optionalparameters_arr = explode(',', $optionalparameters);
     $videolist = array();
     $spq = implode('&', $optionalparameters_arr);
     $videolist = array();
     $keywords = VideoSource_YoutubeSearch::extractYouTubeSearchKeywords($youtubeURL);
     //echo '$keywords='.$keywords.'<br/>';
     //die;
     if ($keywords == '') {
         return $videolist;
     }
     //WRONG LINK id not found
     $url = 'https://gdata.youtube.com/feeds/api/videos?q=' . urlencode($keywords) . '&v=2&' . $spq;
     $xml = false;
     $htmlcode = YouTubeGalleryMisc::getURLData($url);
     //print_r($htmlcode);
     //die;
     if (strpos($htmlcode, '<?xml version') === false) {
         if (strpos($htmlcode, 'Invalid id') === false) {
             return 'Cannot load data, Invalid id';
         }
         return 'Cannot load data, no connection';
     }
     $xml = simplexml_load_string($htmlcode);
     //print_r($xml);
     //die;
     if ($xml) {
         foreach ($xml->entry as $entry) {
             $media = $entry->children('http://search.yahoo.com/mrss/');
             $link = $media->group->player->attributes();
             if (isset($link)) {
                 if (isset($link['url'])) {
                     $videolist[] = $link['url'];
                 }
             }
             //if(isset($link)
         }
         //foreach ($xml->entry as $entry)
     }
     //if($xml){
     //print_r($videolist);
     //die;
     return $videolist;
 }
Ejemplo n.º 15
0
 public static function getVideoData($videoid, $customimage, $customtitle, $customdescription)
 {
     $theTitle = '';
     $Description = '';
     $theImage = '';
     $videodata = array();
     if (phpversion() < 5) {
         return "Update to PHP 5+";
     }
     try {
         $url = 'http://api.own3d.tv/rest/live/list.json?liveid=' . $videoid;
         $htmlcode = YouTubeGalleryMisc::getURLData($url);
         if (strpos($htmlcode, '[{"') === false) {
             $pair = array('Invalid id', 'Invalid id', '', '0', '0', '0', '0', '0', '0', '0', '');
             return $pair;
         }
         $streamData = json_decode($htmlcode);
         $p = explode('/', $streamData[0]->thumbnail_small);
         if (count($p) < 5) {
             $video_thumb_file_small = '';
         } else {
             $video_thumb_file_small = 'http://owned.vo.llnwd.net/e2/live/' . $p[count($p) - 1];
         }
         $videodata = array('videosource' => 'own3dtvlive', 'videoid' => $videoid, 'imageurl' => $video_thumb_file_small, 'title' => $streamData[0]->live_name, 'description' => $streamData[0]->live_description, 'publisheddate' => $streamData[0]->live_since, 'duration' => 0, 'rating_average' => 0, 'rating_max' => 0, 'rating_min' => 0, 'rating_numRaters' => 0, 'statistics_favoriteCount' => 0, 'statistics_viewCount' => $streamData[0]->live_viewers, 'keywords' => '');
         $url_live_status = 'http://api.own3d.tv/liveCheck.php?live_id=' . $videoid;
         $htmlcode = YouTubeGalleryMisc::getURLData($url_live_status);
         if (strpos($htmlcode, '<?xml version') === false) {
             $videodata['description'] .= 'Cannot get Live Status';
             return $videodata;
         }
         $doc = new DOMDocument();
         $doc->loadXML($htmlcode);
         $isLive = $doc->getElementsByTagName("isLive")->item(0)->nodeValue;
         $liveViewers = $doc->getElementsByTagName("liveViewers")->item(0)->nodeValue;
         $liveDuration = $doc->getElementsByTagName("liveDuration")->item(0)->nodeValue;
         $videodata['statistics_viewCount'] = $liveViewers;
         $videodata['duration'] = $liveDuration;
         return $videodata;
     } catch (Exception $e) {
         //$description='cannot get youtibe video data';
         return 'cannot get youtube video data';
     }
     return array('videosource' => 'own3dtvlive', 'videoid' => $videoid, 'imageurl' => $theImage, 'title' => $theTitle, 'description' => $Description);
 }
 public static function getVideoIDList($youtubeURL, $optionalparameters, &$userid, &$datalink)
 {
     $videolist = array();
     $base_url = 'https://www.googleapis.com/youtube/v3';
     $api_key = YouTubeGalleryMisc::getSettingValue('youtube_api_key');
     if ($api_key == '') {
         return $videolist;
     }
     $userid = VideoSource_YoutubeUserFavorites::extractYouTubeUserID($youtubeURL);
     if ($userid == '') {
         return $videolist;
     }
     //user id not found
     //------------- step 1 get user favorites plylist id
     $part = 'contentDetails';
     $url = $base_url . '/channels?forUsername='******'&key=' . $api_key . '&part=' . $part;
     $htmlcode = YouTubeGalleryMisc::getURLData($url);
     //echo '$htmlcode='.$htmlcode.'</br>';
     if ($htmlcode == '') {
         return $videolist;
     }
     $j = json_decode($htmlcode);
     if (!$j) {
         return 'Connection Error';
     }
     $items = $j->items;
     $playlistid = '';
     if (isset($items[0]->contentDetails->relatedPlaylists->uploads)) {
         $playlistid = $items[0]->contentDetails->relatedPlaylists->favorites;
         if ($playlistid == '') {
             return $videolist;
         }
         //user not found or no files uploaded
     }
     //echo '$playlistid='.$playlistid.'</br>';
     // ----------------------- step 2 - get videos
     $videolist = VideoSource_YoutubePlaylist::getPlaylistVideos($playlistid, $datalink, $api_key, $optionalparameters);
     //print_r($videolist);
     //die;
     return $videolist;
 }
Ejemplo n.º 17
0
 public static function getVideoIDList($youtubeURL, $optionalparameters, &$playlistid)
 {
     $optionalparameters_arr = explode(',', $optionalparameters);
     $videolist = array();
     $spq = implode('&', $optionalparameters_arr);
     $videolist = array();
     $playlistid = VideoSource_YoutubePlaylist::extractYouTubePlayListID($youtubeURL);
     if ($playlistid == '') {
         return $videolist;
     }
     //playlist id not found
     $url = 'http://gdata.youtube.com/feeds/api/playlists/' . $playlistid . ($spq != '' ? '?' . $spq : '');
     //&max-results=10;
     $xml = false;
     $htmlcode = YouTubeGalleryMisc::getURLData($url);
     if (strpos($htmlcode, '<?xml version') === false) {
         if (strpos($htmlcode, 'Invalid id') === false) {
             return 'Cannot load data, Invalid id';
         }
         return 'Cannot load data, no connection';
     }
     $xml = simplexml_load_string($htmlcode);
     if ($xml) {
         foreach ($xml->entry as $entry) {
             $media = $entry->children('http://search.yahoo.com/mrss/');
             $link = $media->group->player->attributes();
             if (isset($link)) {
                 if (isset($link['url'])) {
                     $videolist[] = $link['url'];
                 }
             }
             //if(isset($link)
         }
         //foreach ($xml->entry as $entry)
     }
     //if($xml){
     return $videolist;
 }
Ejemplo n.º 18
0
 protected static function getYouTubeVideoData_API_v2($videoid, &$blankArray, $getinfomethod)
 {
     if (phpversion() < 5) {
         return "Update to PHP 5+";
     }
     try {
         $url = 'http://gdata.youtube.com/feeds/api/videos/' . $videoid . '?v=2';
         //v=2to get likes and dislikes
         $blankArray['datalink'] = $url;
         /*
         if($getinfomethod=='js' or $getinfomethod=='jsmanual')
         {
         	$rd=YouTubeGalleryMisc::getRawData($videoid);
         	if($rd=='')
         	{
         		YouTubeGalleryMisc::setDelayedRequest($videoid,$url);
         		return '';
         	}
         	elseif($rd=='' or $rd=='*youtubegallery_request*')
         		return '';
         	else $htmlcode=$rd;
         }
         else
         */
         $htmlcode = YouTubeGalleryMisc::getURLData($url);
         if (($getinfomethod == 'js' or $getinfomethod == 'jsmanual') and $htmlcode == '') {
             return '';
         }
         //	return 'Get info method not set, go to Settings.';
         if (strpos($htmlcode, '<?xml version') === false) {
             if (strpos($htmlcode, 'Invalid id') === false) {
                 return substr($htmlcode, 0, 30);
             } else {
                 return 'Invalid id';
             }
             //return $pair;
         } else {
             if (strpos($htmlcode, '<code>too_many_recent_calls</code>') !== false) {
                 return 'Youtube API Key needed';
             }
         }
         $doc = new DOMDocument();
         $doc->loadXML($htmlcode);
         if (!isset($doc->getElementsByTagName("title")->item(0)->nodeValue)) {
             return 'Youtube 2 Video "' . $videoid . '" not found.';
         }
         $blankArray['title'] = $doc->getElementsByTagName("title")->item(0)->nodeValue;
         $blankArray['description'] = $doc->getElementsByTagName("description")->item(0)->nodeValue;
         $blankArray['publisheddate'] = $doc->getElementsByTagName("published")->item(0)->nodeValue;
         if ($doc->getElementsByTagName("duration")) {
             if ($doc->getElementsByTagName("duration")->item(0)) {
                 $blankArray['duration'] = $doc->getElementsByTagName("duration")->item(0)->getAttribute("seconds");
             }
         }
         $MediaElement = $doc->getElementsByTagName("thumbnail");
         if ($MediaElement->length > 0) {
             $images = array();
             foreach ($MediaElement as $me) {
                 $images[] = $me->getAttribute("url");
             }
             $blankArray['imageurl'] = implode(',', $images);
         }
         $FeedElement = $doc->getElementsByTagName("feedLink");
         if ($FeedElement->length > 0) {
             $fe0 = $FeedElement->item(0);
             $blankArray['commentcount'] = $fe0->getAttribute("countHint");
         }
         $RatingElement = $doc->getElementsByTagName("rating");
         if ($RatingElement->length > 0) {
             $re0 = $RatingElement->item(0);
             $blankArray['rating_average'] = $re0->getAttribute("average");
             $blankArray['rating_max'] = $re0->getAttribute("max");
             $blankArray['rating_min'] = $re0->getAttribute("min");
             $blankArray['rating_numRaters'] = $re0->getAttribute("numRaters");
             if ($RatingElement->length > 1) {
                 $re1 = $RatingElement->item(1);
                 $blankArray['likes'] = $re1->getAttribute("numLikes");
                 $blankArray['dislikes'] = $re1->getAttribute("numDislikes");
             } else {
                 $blankArray['likes'] = 0;
                 $blankArray['dislikes'] = 0;
             }
         }
         $StatElement = $doc->getElementsByTagName("statistics");
         if ($StatElement->length > 0) {
             $se0 = $StatElement->item(0);
             $blankArray['statistics_favoriteCount'] = $se0->getAttribute("favoriteCount");
             $blankArray['statistics_viewCount'] = $se0->getAttribute("viewCount");
         }
         $blankArray['keywords'] = $doc->getElementsByTagName("keywords")->item(0)->nodeValue;
     } catch (Exception $e) {
         return 'Cannot get youtube video data.';
     }
     return '';
 }
Ejemplo n.º 19
0
 public static function getYouTubeVideoData($videoid, &$blankArray)
 {
     if (phpversion() < 5) {
         return "Update to PHP 5+";
     }
     try {
         $url = 'http://gdata.youtube.com/feeds/api/videos/' . $videoid . '?v=2';
         //v=2to get likes and dislikes
         $doc = new DOMDocument();
         $htmlcode = YouTubeGalleryMisc::getURLData($url);
         if (strpos($htmlcode, '<?xml version') === false) {
             if (strpos($htmlcode, 'Invalid id') === false) {
                 return 'Cannot Connect to Youtube Server';
             } else {
                 return 'Invalid id';
             }
             return $pair;
         }
         $doc->loadXML($htmlcode);
         if (!isset($doc->getElementsByTagName("title")->item(0)->nodeValue)) {
             return '<p>Youtube Video "' . $videoid . '" not found.</p>';
         }
         $blankArray['title'] = $doc->getElementsByTagName("title")->item(0)->nodeValue;
         $blankArray['description'] = $doc->getElementsByTagName("description")->item(0)->nodeValue;
         $blankArray['publisheddate'] = $doc->getElementsByTagName("published")->item(0)->nodeValue;
         if ($doc->getElementsByTagName("duration")) {
             if ($doc->getElementsByTagName("duration")->item(0)) {
                 $blankArray['duration'] = $doc->getElementsByTagName("duration")->item(0)->getAttribute("seconds");
             }
         }
         $MediaElement = $doc->getElementsByTagName("thumbnail");
         if ($MediaElement->length > 0) {
             $images = array();
             foreach ($MediaElement as $me) {
                 $images[] = $me->getAttribute("url");
             }
             $blankArray['imageurl'] = implode(',', $images);
         }
         $FeedElement = $doc->getElementsByTagName("feedLink");
         if ($FeedElement->length > 0) {
             $fe0 = $FeedElement->item(0);
             $blankArray['commentcount'] = $fe0->getAttribute("countHint");
         }
         $RatingElement = $doc->getElementsByTagName("rating");
         if ($RatingElement->length > 0) {
             //print_r($RatingElement);
             $re0 = $RatingElement->item(0);
             $blankArray['rating_average'] = $re0->getAttribute("average");
             $blankArray['rating_max'] = $re0->getAttribute("max");
             $blankArray['rating_min'] = $re0->getAttribute("min");
             $blankArray['rating_numRaters'] = $re0->getAttribute("numRaters");
             if ($RatingElement->length > 1) {
                 $re1 = $RatingElement->item(1);
                 //print_r($re1);
                 $blankArray['likes'] = $re1->getAttribute("numLikes");
                 $blankArray['dislikes'] = $re1->getAttribute("numDislikes");
             } else {
                 $blankArray['likes'] = 0;
                 $blankArray['dislikes'] = 0;
             }
         }
         $StatElement = $doc->getElementsByTagName("statistics");
         if ($StatElement->length > 0) {
             $se0 = $StatElement->item(0);
             $blankArray['statistics_favoriteCount'] = $se0->getAttribute("favoriteCount");
             $blankArray['statistics_viewCount'] = $se0->getAttribute("viewCount");
         }
         $blankArray['keywords'] = $doc->getElementsByTagName("keywords")->item(0)->nodeValue;
     } catch (Exception $e) {
         return 'Cannot get youtube video data.';
     }
     //print_r($blankArray);
     //die;
     return '';
 }
Ejemplo n.º 20
0
 public static function getVideoIDList($youtubeURL, $optionalparameters, &$playlistid, &$datalink)
 {
     $linkPair = explode(':', $youtubeURL);
     if (!isset($linkPair[1])) {
         return array();
     }
     $url = '';
     $playlistid = $linkPair[1];
     switch ($linkPair[1]) {
         case 'top_rated':
             $url = 'https://gdata.youtube.com/feeds/api/standardfeeds/top_rated';
             break;
         case 'top_favorites':
             $url = 'https://gdata.youtube.com/feeds/api/standardfeeds/top_favorites';
             break;
         case 'most_viewed':
             $url = 'https://gdata.youtube.com/feeds/api/standardfeeds/most_viewed';
             break;
         case 'most_shared':
             $url = 'https://gdata.youtube.com/feeds/api/standardfeeds/most_shared';
             break;
         case 'most_popular':
             $url = 'https://gdata.youtube.com/feeds/api/standardfeeds/most_popular';
             break;
         case 'most_recent':
             $url = 'https://gdata.youtube.com/feeds/api/standardfeeds/most_recent';
             break;
         case 'most_discussed':
             $url = 'https://gdata.youtube.com/feeds/api/standardfeeds/most_discussed';
             break;
         case 'most_responded':
             $url = 'https://gdata.youtube.com/feeds/api/standardfeeds/most_responded';
             break;
         case 'recently_featured':
             $url = 'https://gdata.youtube.com/feeds/api/standardfeeds/recently_featured';
             break;
         case 'on_the_web':
             $url = 'https://gdata.youtube.com/feeds/api/standardfeeds/on_the_web';
             break;
         default:
             return array();
             break;
     }
     $datalink = $url;
     $optionalparameters_arr = explode(',', $optionalparameters);
     $videolist = array();
     $spq = implode('&', $optionalparameters_arr);
     $spq = str_replace('max-results', 'maxResults', $spq);
     $url .= $spq != '' ? '?' . $spq : '';
     $xml = false;
     $htmlcode = YouTubeGalleryMisc::getURLData($url);
     if ($htmlcode == '') {
         return $videolist;
     }
     if (strpos($htmlcode, '<?xml version') === false) {
         if (strpos($htmlcode, 'Invalid id') === false) {
             return 'Cannot load data, Invalid id';
         }
         return 'Cannot load data, no connection';
     }
     $xml = simplexml_load_string($htmlcode);
     if ($xml) {
         foreach ($xml->entry as $entry) {
             /*
             if(isset($entry->link[0]))
             {
             	$link=$entry->link[0];
             	$attr = $link->attributes();
             	
             	$videolist[] = $attr['href'];
             }
             */
             //
             $media = $entry->children('http://search.yahoo.com/mrss/');
             $link = $media->group->player->attributes();
             if (isset($link['url'])) {
                 $videolist[] = $link['url'];
             }
             //
         }
     }
     return $videolist;
 }
Ejemplo n.º 21
0
 public static function getPlaylistVideos($playlistid, &$datalink, $api_key, $optionalparameters)
 {
     $base_url = 'https://www.googleapis.com/youtube/v3';
     $videolist = array();
     if ($playlistid == '') {
         return $videolist;
     }
     //playlist id not found
     $part = 'id,snippet';
     $optionalparameters_arr = explode(',', $optionalparameters);
     $spq = implode('&', $optionalparameters_arr);
     $spq = str_replace('max-results', 'maxResults', $spq);
     //API 2 -> API 3 conversion
     $datalink = $base_url . '/playlistItems?part=' . $part . '&key=' . $api_key . '&playlistId=' . $playlistid . ($spq != '' ? '&' . $spq : '');
     $opt = "";
     $count = YouTubeGalleryMisc::getMaxResults($spq, $opt);
     if ($count < 1) {
         $maxResults = 1;
     } elseif ($count > 50) {
         $maxResults = 50;
     } else {
         $maxResults = $count;
     }
     $videos_found = 0;
     $nextPageToken = '';
     while ($videos_found < $count) {
         $newspq = str_replace($opt, 'maxResults=' . $maxResults, $spq);
         $url = $base_url . '/playlistItems?part=' . $part . '&key=' . $api_key . '&playlistId=' . $playlistid . ($newspq != '' ? '&' . $newspq : '');
         if ($nextPageToken != '') {
             $url .= '&pageToken=' . $nextPageToken;
         }
         $htmlcode = YouTubeGalleryMisc::getURLData($url);
         if ($htmlcode == '') {
             return $videolist;
         }
         $j = json_decode($htmlcode);
         if (!$j) {
             return 'Connection Error';
         }
         $nextPageToken = $j->nextPageToken;
         $pageinfo = $j->pageInfo;
         if ($pageinfo->totalResults < $count) {
             $count = $pageinfo->totalResults;
         }
         $items = $j->items;
         if (count($items) < $maxResults) {
             $maxResults = count($items);
         }
         foreach ($items as $item) {
             if ($item->kind == 'youtube#playlistItem') {
                 $s = $item->snippet->resourceId;
                 if ($s->kind == 'youtube#video') {
                     $videoId = $s->videoId;
                     $videolist[] = 'https://www.youtube.com/watch?v=' . $videoId;
                 }
             }
         }
         $videos_found += $maxResults;
         if ($count - $videos_found < 50) {
             $maxResults = $count - $videos_found;
         }
     }
     return $videolist;
 }
Ejemplo n.º 22
0
 public static function getVideoIDList($youtubeURL, $optionalparameters, &$playlistid, &$datalink)
 {
     $optionalparameters_arr = explode(',', $optionalparameters);
     $videolist = array();
     $base_url = 'https://www.googleapis.com/youtube/v3';
     $api_key = YouTubeGalleryMisc::getSettingValue('youtube_api_key');
     if ($api_key == '') {
         return $videolist;
     }
     $spq = implode('&', $optionalparameters_arr);
     $keywords = VideoSource_YoutubeSearch::extractYouTubeSearchKeywords($youtubeURL);
     if ($keywords == '') {
         return $videolist;
     }
     //WRONG LINK id not found
     $part = 'id,snippet';
     $spq = str_replace('max-results', 'maxResults', $spq);
     $datalink = $base_url . '/search?q=' . urlencode($keywords) . '&part=' . $part . '&key=' . $api_key . ($spq != '' ? '&' . $spq : '');
     $opt = "";
     $count = YouTubeGalleryMisc::getMaxResults($spq, $opt);
     if ($count < 1) {
         $maxResults = 1;
     } elseif ($count > 50) {
         $maxResults = 50;
     } else {
         $maxResults = $count;
     }
     $videos_found = 0;
     $nextPageToken = '';
     while ($videos_found < $count) {
         $newspq = str_replace($opt, 'maxResults=' . $maxResults, $spq);
         $url = $base_url . '/search?q=' . urlencode($keywords) . '&part=' . $part . '&key=' . $api_key . ($newspq != '' ? '&' . $newspq : '');
         if ($nextPageToken != '') {
             $url .= '&pageToken=' . $nextPageToken;
         }
         $htmlcode = YouTubeGalleryMisc::getURLData($url);
         if ($htmlcode == '') {
             return $videolist;
         }
         $j = json_decode($htmlcode);
         if (!$j) {
             return 'Connection Error';
         }
         $nextPageToken = $j->nextPageToken;
         $pageinfo = $j->pageInfo;
         if ($pageinfo->totalResults < $count) {
             $count = $pageinfo->totalResults;
         }
         $items = $j->items;
         if (count($items) < $maxResults) {
             $maxResults = count($items);
         }
         foreach ($items as $item) {
             if ($item->kind == 'youtube#searchResult') {
                 $s = $item->id;
                 if ($s->kind == 'youtube#video') {
                     $videoId = $s->videoId;
                     $videolist[] = 'https://www.youtube.com/watch?v=' . $videoId;
                 }
             }
         }
         $videos_found += $maxResults;
         if ($count - $videos_found < 50) {
             $maxResults = $count - $videos_found;
         }
     }
     return $videolist;
 }
Ejemplo n.º 23
0
 public static function getVideoIDList($youtubeURL, $optionalparameters, &$playlistid, &$datalink)
 {
     //not ready yet
     //return array();
     //************************************************************************************************************************************
     $base_url = 'https://www.googleapis.com/youtube/v3';
     //https://developers.google.com/youtube/v3/docs/search/list
     /*
     		*videoType 	string 	The videoType parameter lets you restrict a search to a particular type of videos. If you specify a value for this parameter, you must also set the type parameter's value to video.
     
     		Acceptable values are:
     
     		any – Return all videos.
     		episode – Only retrieve episodes of shows.
     		movie – Only retrieve movies.
     */
     $optionalparameters_arr = explode(',', $optionalparameters);
     $videolist = array();
     $season = VideoSource_YoutubeShow::getValueOfParameter($optionalparameters_arr, 'season');
     $content_type = VideoSource_YoutubeShow::getValueOfParameter($optionalparameters_arr, 'content');
     if ($content_type == '') {
         $content_type = 'episodes';
     }
     $season = explode(':', $season);
     if (count($season) == 4) {
         $season_id = $season[2];
     } else {
         return $videolist;
     }
     //season id not found
     $optionalparameters_arr = VideoSource_YoutubeShow::deleteParameter($optionalparameters_arr, 'season');
     $optionalparameters_arr = VideoSource_YoutubeShow::deleteParameter($optionalparameters_arr, 'content');
     $part = 'id,snippet';
     $spq = implode('&', $optionalparameters_arr);
     $spq = str_replace('max-results', 'maxResults', $spq);
     $datalink = 'http://gdata.youtube.com/feeds/api/seasons/' . $season_id . '/' . $content_type . '?v=3' . ($spq != '' ? '&' . $spq : '');
     $opt = "";
     $count = YouTubeGalleryMisc::getMaxResults($spq, $opt);
     if ($count < 1) {
         $maxResults = 1;
     } elseif ($count > 50) {
         $maxResults = 50;
     } else {
         $maxResults = $count;
     }
     $videos_found = 0;
     $nextPageToken = '';
     while ($videos_found < $count) {
         $newspq = str_replace($opt, 'maxResults=' . $maxResults, $spq);
         $url = $base_url . '/playlistItems?part=' . $part . '&key=' . $api_key . '&playlistId=' . $playlistid . ($newspq != '' ? '&' . $newspq : '');
         if ($nextPageToken != '') {
             $url .= '&pageToken=' . $nextPageToken;
         }
         $htmlcode = YouTubeGalleryMisc::getURLData($url);
         if ($htmlcode == '') {
             return $videolist;
         }
         $j = json_decode($htmlcode);
         if (!$j) {
             return 'Connection Error';
         }
         $nextPageToken = $j->nextPageToken;
         $pageinfo = $j->pageInfo;
         if ($pageinfo->totalResults < $count) {
             $count = $pageinfo->totalResults;
         }
         $items = $j->items;
         if (count($items) < $maxResults) {
             $maxResults = count($items);
         }
         foreach ($xml->entry as $entry) {
             $link = $entry->link->attributes();
             $videolist[] = $link['href'];
         }
     }
     $videos_found += $maxResults;
     if ($count - $videos_found < 50) {
         $maxResults = $count - $videos_found;
     }
     return $videolist;
 }