コード例 #1
0
ファイル: youtubesearch.php プロジェクト: n4m4573/joomla-3.x
 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;
 }
コード例 #2
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;
     require_once JPATH_ADMINISTRATOR . '/components/com_youtubegallery/google/_videos.php';
     $videos = new YoutubeVideos();
     $videos_raw = $videos->getVideosFromSearch($keywords);
     $videolist = array();
     for ($i = 0, $limit = count($videos_raw); $i < $limit; $i++) {
         $url = 'https://www.youtube.com/watch?v=' . $videos_raw[$i]->id->videoId;
         $videolist[] = $url;
     }
     return $videolist;
 }
コード例 #3
0
ファイル: misc.php プロジェクト: n4m4573/joomla-3.x
 function formVideoList($rawList, &$firstvideo)
 {
     //print_r ($rawList);
     //die;
     $gallery_list = array();
     $main_ordering = 10000;
     //10000 step
     foreach ($rawList as $b) {
         $b = str_replace("\n", '', $b);
         $b = trim(str_replace("\r", '', $b));
         $listitem = $this->csv_explode(',', $b, '"', false);
         $theLink = trim($listitem[0]);
         if (!(strpos($theLink, '/embed/') === false)) {
             //Convert Embed links to Address bar version
             $theLink = str_replace('www.youtube.com/embed/', 'youtu.be/', $theLink);
             $theLink = str_replace('youtube.com/embed/', 'youtu.be/', $theLink);
         }
         $vsn = $this->getVideoSourceName($theLink);
         //echo $vsn='$vsn='.$vsn.'<br/>';
         //die;
         if (isset($listitem[4])) {
             $specialparams = $listitem[4];
         } else {
             $specialparams = '';
         }
         if ($vsn == 'youtubeplaylist') {
             require_once 'youtubeplaylist.php';
             $newlist = VideoSource_YoutubePlaylist::getVideoIDList($theLink, $specialparams, $playlistid);
         } elseif ($vsn == 'youtubeuserfavorites') {
             require_once 'youtubeuserfavorites.php';
             $newlist = VideoSource_YoutubeUserFavorites::getVideoIDList($theLink, $specialparams, $playlistid);
         } elseif ($vsn == 'youtubeuseruploads') {
             require_once 'youtubeuseruploads.php';
             $newlist = VideoSource_YoutubeUserUploads::getVideoIDList($theLink, $specialparams, $playlistid);
         } elseif ($vsn == 'youtubestandard') {
             require_once 'youtubestandard.php';
             $newlist = VideoSource_YoutubeStandard::getVideoIDList($theLink, $specialparams, $playlistid);
         } elseif ($vsn == 'youtubesearch') {
             require_once 'youtubesearch.php';
             $newlist = VideoSource_YoutubeSearch::getVideoIDList($theLink, $specialparams, $playlistid);
             if (!is_array($newlist)) {
                 echo 'Youtube Search: ' . $newlist;
                 die;
             }
         } elseif ($vsn == 'vimeouservideos') {
             require_once 'vimeouservideos.php';
             $newlist = VideoSource_VimeoUserVideos::getVideoIDList($theLink, $specialparams, $playlistid);
         } elseif ($vsn == 'vimeochannel') {
             require_once 'vimeochannel.php';
             $newlist = VideoSource_VimeoChannel::getVideoIDList($theLink, $specialparams, $playlistid);
         } elseif ($vsn == 'vimeoalbum') {
             require_once 'vimeoalbum.php';
             $newlist = VideoSource_VimeoAlbum::getVideoIDList($theLink, $specialparams, $playlistid);
         } elseif ($vsn == 'dailymotionplaylist') {
             require_once 'dailymotionplaylist.php';
             $newlist = VideoSource_DailymotionPlaylist::getVideoIDList($theLink, $specialparams, $playlistid);
         }
         //echo '$vsn='.$vsn.'<br/>';
         //die;
         $channels_youtube = array('youtubeuseruploads', 'youtubestandard', 'youtubeplaylist', 'youtubeuserfavorites', 'youtubesearch');
         $channels_other = array('vimeouservideos', 'vimeochannel', 'vimeoalbum', 'dailymotionplaylist');
         $channels_vimeo = array('vimeouservideos', 'vimeochannel', 'vimeoalbum');
         if (in_array($vsn, $channels_youtube) or in_array($vsn, $channels_other)) {
             if (in_array($vsn, $channels_youtube)) {
                 $video_source = 'youtube';
             }
             if (in_array($vsn, $channels_vimeo)) {
                 $video_source = 'vimeo';
             }
             if ($vsn == 'dailymotionplaylist') {
                 $video_source = 'dailymotion';
             }
             $new_List_Clean = array();
             $ordering = 1;
             $startsecond = 0;
             $endsecond = 0;
             if (isset($listitem[5])) {
                 $startsecond = $listitem[5];
             }
             if (isset($listitem[6])) {
                 $endsecond = $listitem[6];
             }
             foreach ($newlist as $theLinkItem) {
                 $item = $this->GrabVideoData($theLinkItem, $video_source);
                 if ($item['videoid'] != '') {
                     //echo 'd:videoid='.$item['videoid'].'<br/>';
                     if ($firstvideo == '') {
                         $firstvideo = $item['videoid'];
                     }
                     $item['ordering'] = $main_ordering + $ordering;
                     if (isset($listitem[1])) {
                         $item['title'] = $listitem[1];
                         $item['custom_title'] = $listitem[1];
                     }
                     if (isset($listitem[2])) {
                         $item['description'] = $listitem[2];
                         $item['custom_description'] = $listitem[2];
                     }
                     if (isset($listitem[3])) {
                         if (strpos($listitem[3], '#') === false) {
                             $item['imageurl'] = $listitem[3];
                         }
                         $item['custom_imageurl'] = $listitem[3];
                     }
                     $item['startsecond'] = $startsecond;
                     $item['endsecond'] = $endsecond;
                     $new_List_Clean[] = $item;
                     $ordering++;
                 }
             }
             $item = array('videosource' => $vsn, 'videoid' => $playlistid, 'imageurl' => '', 'title' => '', 'description' => '', 'specialparams' => $specialparams, 'count' => count($new_List_Clean), 'link' => '', 'ordering' => $main_ordering, 'channel_username' => '', 'channel_title' => '', 'channel_subscribers' => '', 'channel_subscribed' => '', 'channel_location' => '', 'channel_commentcount' => '', 'channel_viewcount' => '', 'channel_videocount' => '', 'channel_description' => '', 'channel_totaluploadviews' => '');
             if ($vsn == 'youtubeuseruploads' and !(strpos($specialparams, 'moredetails=true') === false)) {
                 //Try to get channel info
                 require_once 'youtubeuseruploads.php';
                 $user_info = VideoSource_YoutubeUserUploads::getUserInfo($theLink, $item);
                 if ($user_info != '') {
                     $item['channel_title'] = $user_info;
                 }
             }
             $gallery_list[] = $item;
             $gallery_list = array_merge($gallery_list, $new_List_Clean);
             //print_r($gallery_list);
             //die;
         } elseif ($vsn == 'videolist') {
             $linkPair = explode(':', $theLink);
             //echo '$linkPair='.$linkPair.'<br/>';
             if (isset($linkPair[1])) {
                 if (trim($linkPair[1]) == 'all') {
                     $vID = -1;
                 } elseif (trim($linkPair[1]) == 'category') {
                     if (isset($linkPair[2])) {
                         $vID = 'category=' . $linkPair[2];
                     }
                 } elseif (trim($linkPair[1]) == 'catid') {
                     if (isset($linkPair[2])) {
                         $vID = 'catid=' . (int) $linkPair[2];
                     }
                 } else {
                     $vID = (int) $linkPair[1];
                     //echo '$vID='.$vID.'<br/>';
                     //die;
                 }
                 $item = array('videosource' => $vsn, 'videoid' => $vID, 'isvideo' => "0", 'imageurl' => '', 'title' => '', 'description' => '', 'specialparams' => '', 'count' => '', 'link' => '', 'ordering' => '');
                 $gallery_list[] = $item;
             }
         } else {
             $item = $this->GrabVideoData($listitem, $vsn);
             if (isset($item['videoid']) and $item['videoid'] != '') {
                 if ($firstvideo == '') {
                     $firstvideo = $item['videoid'];
                 }
                 $item['ordering'] = $main_ordering;
                 $gallery_list[] = $item;
             }
         }
         $main_ordering += 10000;
     }
     //foreach($rawList as $b)
     return $gallery_list;
 }
コード例 #4
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;
 }