|
From: Florin C B. <ory...@us...> - 2013-03-17 02:20:25
|
Update of /cvsroot/mxbb/mx_music/music_box/includes In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv20982/includes Modified Files: music_functions.php Log Message: update for vimeo and youtube Index: music_functions.php =================================================================== RCS file: /cvsroot/mxbb/mx_music/music_box/includes/music_functions.php,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** music_functions.php 26 Sep 2008 12:29:04 -0000 1.9 --- music_functions.php 17 Mar 2013 02:20:23 -0000 1.10 *************** *** 793,798 **** // END function music_user_access() // ---------------------------------------------------------------------------- - - function mx_music_sitename($domain) { --- 793,796 ---- *************** *** 807,811 **** return $r; } - function mx_music_sitesufix($domain) { --- 805,808 ---- *************** *** 816,820 **** return $r; } ! // ---------------------------------------------------------------------------- // You must retain the full copyright notice below including the link to my site. --- 813,959 ---- return $r; } ! function mx_video_image($url) ! { ! $image_url = parse_url($url); ! if($image_url['host'] == 'www.youtube.com' || $image_url['host'] == 'youtube.com') ! { ! $array = explode("&", $image_url['query']); ! return "http://img.youtube.com/vi/".substr($array[0], 2)."/0.jpg"; ! } ! else if($image_url['host'] == 'www.vimeo.com' || $image_url['host'] == 'vimeo.com') ! { ! $hash = unserialize(file_get_contents("http://vimeo.com/api/v2/video/".substr($image_url['path'], 1).".php")); ! return $hash[0]["thumbnail_small"]; ! } ! } ! function mx_video_get_title($url) ! { ! $image_url = parse_url($url); ! if($image_url['host'] == 'www.youtube.com' || $image_url['host'] == 'youtube.com') ! { ! $array = explode("&", $image_url['query']); ! // This is the youtube video code ! $code = substr($array[0], 2); ! // Get video feed info (xml) from youtube, but only the title | http://php.net/manual/en/function.file-get-contents.php ! $video_feed = file_get_contents("http://gdata.youtube.com/feeds/api/videos?v=2&q=".$code."&max-results=1&fields=entry(title)&prettyprint=true"); ! // xml to object | http://php.net/manual/en/function.simplexml-load-string.php ! $video_obj = simplexml_load_string($video_feed); ! // Get the title string to a variable ! $video_str = $video_obj->entry->title; ! // Change the type to string ! $title = (string) $video_str; ! // Output ! return $title; ! } ! } ! function mx_video_get_content($url, $mode = 'description') ! { ! $desc_url = parse_url($url); ! if($desc_url['host'] == 'www.youtube.com' || $desc_url['host'] == 'youtube.com') ! { ! $array = explode("&", $desc_url['query']); ! // This is the youtube video code ! $id = substr($array[0], 2); ! // create an array to return ! $videoDetails = array(); ! // get the xml data from youtube ! $url = "http://gdata.youtube.com/feeds/api/videos/".$id; ! $xml = simplexml_load_file($url); ! // load up the array ! $videoDetails['title'] = $xml->title[0]; ! $videoDetails['description'] = $xml->content[0]; ! $videoDetails['thumbnail'] = "http://i.ytimg.com/vi/".$id."/2.jpg"; ! // Output ! switch($mode) ! { ! case 'title': ! return $videoDetails['title']; ! break; ! case 'description': ! return $videoDetails['description']; ! break; ! case 'desc': ! return substr($videoDetails['desc'], 0, 120).'...'; ! break; ! case 'thumbnail': ! case 'thumburl': ! return thumbnail; ! break; ! default: ! return $videoDetails; ! } ! } ! elseif($desc_url['host'] == 'www.vimeo.com' || $desc_url['host'] == 'vimeo.com') ! { ! $video_id = explode('vimeo.com/', $url); ! $video_id = $video_id[1]; ! // create an array to return ! $data['video_type'] = 'vimeo'; ! $data['video_id'] = $video_id; ! // get the xml data from youtube ! $url = "http://vimeo.com/api/v2/video/$video_id.xml"; ! $xml = simplexml_load_file($url); ! // load up foreach ! foreach ($xml->video as $video) { ! $data['id']=$video->id; ! $data['title']=$video->title; ! $data['info']=$video->description; ! $data['url']=$video->url; ! $data['upload_date']=$video->upload_date; ! $data['mobile_url']=$video->mobile_url; ! $data['thumb_small']=$video->thumbnail_small; ! $data['thumb_medium']=$video->thumbnail_medium; ! $data['thumb_large']=$video->thumbnail_large; ! $data['user_name']=$video->user_name; ! $data['urer_url']=$video->urer_url; ! $data['user_thumb_small']=$video->user_portrait_small; ! $data['user_thumb_medium']=$video->user_portrait_medium; ! $data['user_thumb_large']=$video->user_portrait_large; ! $data['user_thumb_huge']=$video->user_portrait_huge; ! $data['likes']=$video->stats_number_of_likes; ! $data['views']=$video->stats_number_of_plays; ! $data['comments']=$video->stats_number_of_comments; ! $data['duration']=$video->duration; ! $data['width']=$video->width; ! $data['height']=$video->height; ! $data['tags']=$video->tags; ! } // End foreach ! // Change the type to string ! $desc = substr($data['info'], 0, 120).'...'; ! // Output ! switch($mode) ! { ! case 'title': ! return $data['title']; ! break; ! case 'description': ! return $data['info']; ! break; ! case 'desc': ! return $desc; ! break; ! case 'thumbnail': ! case 'thumburl': ! return $data['thumbnail_small']; ! break; ! case 'views': ! return $data['stats_number_of_plays']; ! break; ! case 'upload_date': ! return $data['upload_date']; ! break; ! case 'user_name': ! return $data['user_name']; ! break; ! case 'views': ! return $data['views']; ! case 'duration': ! return $data['duration']; ! break; ! default: ! return $data; ! } ! } // End Vimeo ! } // ---------------------------------------------------------------------------- // You must retain the full copyright notice below including the link to my site. |