コード例 #1
0
/**
 * Youtube function Starts Here
 * Fucntion to get YouTube video title, description
 */
function youtubeurl()
{
    /** Get Youtube video id from filepath param */
    $video_id = addslashes(trim($_GET['filepath']));
    /** Check Youtube video id is exist */
    if (!empty($video_id)) {
        /** Make an YouTube URl with the given id */
        $act[4] = 'http://www.youtube.com/watch?v=' . $video_id;
        /** Call function to get YouTube video details */
        $ydetails = hd_getsingleyoutubevideo($video_id);
        /** If details exist */
        if ($ydetails) {
            /** Get YouTube video title */
            $act[0] = $ydetails['items'][0]->snippet->title;
            /** Get YouTube video description */
            if (isset($ydetails['items'][0]->snippet->description)) {
                $act[5] = $ydetails['items'][0]->snippet->description;
            }
        } else {
            /** Display error message if details are not fetched */
            render_error(__('Could not retrieve Youtube video information', APPTHA_VGALLERY));
        }
        return $act;
    }
}
コード例 #2
0
 /** Function for adding video and update status / featured. */
 public function add_newvideo()
 {
     /** Variable declaration and initialization */
     $match = '';
     /** Assign youtube URL without id */
     $youtubeVideoURL = 'http://www.youtube.com/watch?v=';
     /** Check video status is exists  */
     if (isset($this->_status) || isset($this->_featured)) {
         /** Call function to update video status */
         $this->status_update($this->_videoId, $this->_status, $this->_featured);
     }
     /** Check whether to add / update video */
     if ($this->_addnewVideo) {
         /** Get video name parameters from the request */
         $videoName = filter_input(INPUT_POST, 'name');
         /** Get video description parameters from the request */
         $videoDescription = filter_input(INPUT_POST, 'description');
         /** Get embed_code parameters from the request */
         $embedcode = filter_input(INPUT_POST, 'embed_code');
         /** Get publish parameters from the request */
         $videoPublish = filter_input(INPUT_POST, 'publish');
         /** Get feature parameters from the request */
         $videoFeatured = filter_input(INPUT_POST, 'feature');
         /** Get download parameters from the request */
         $videoDownload = filter_input(INPUT_POST, 'download');
         /** Get midrollads parameters from the request */
         $videomidrollads = filter_input(INPUT_POST, 'midrollads');
         /** Get imaad parameters from the request */
         $videoimaad = filter_input(INPUT_POST, 'imaad');
         /** Get postrollads parameters from the request */
         $videoPostrollads = filter_input(INPUT_POST, 'postrollads');
         /** Get prerollads parameters from the request */
         $videoPrerollads = filter_input(INPUT_POST, 'prerollads');
         /** Get googleadsense parameters from the request */
         $google_adsense = filter_input(INPUT_POST, 'googleadsense');
         /** Get google_adsense_value parameters from the request */
         $google_adsense_value = filter_input(INPUT_POST, 'google_adsense_value');
         /**
          * Get member id from request.
          * If not get current user id
          */
         $member_id = filter_input(INPUT_POST, 'member_id');
         if (empty($member_id)) {
             $current_user = wp_get_current_user();
             $member_id = $current_user->ID;
         }
         /** Get upload video form params */
         $video1 = filter_input(INPUT_POST, 'normalvideoform-value');
         /** Get upload hd video form params */
         $video2 = filter_input(INPUT_POST, 'hdvideoform-value');
         /** Get thumb image form params */
         $img1 = filter_input(INPUT_POST, 'thumbimageform-value');
         /** Get preview image form params */
         $img2 = filter_input(INPUT_POST, 'previewimageform-value');
         /**  Get streamer path option for rtmp streaming */
         $islive = filter_input(INPUT_POST, 'islive-value');
         /**  Get is live option for rtmp streaming */
         $streamname = filter_input(INPUT_POST, 'streamerpath-value');
         /** Get Youtube video url from request */
         $videoLinkurl = filter_input(INPUT_POST, 'youtube-value');
         /** Set video duration */
         $duration = '0:00';
         /** Get video added method */
         $video_added_method = filter_input(INPUT_POST, 'filetypevalue');
         /** Get amazon bucket params */
         $amazon_buckets = filter_input(INPUT_POST, 'amazon_buckets');
         /** Check youtbe / youtu.be / dailymotion / viddler video url is exists */
         if ($videoLinkurl != '') {
             /** Attach http with video url */
             if (preg_match('#https?://#', $videoLinkurl) === 0) {
                 $videoLinkurl = 'http://' . $videoLinkurl;
             }
             /** Remove spaces in video url */
             $act_filepath = addslashes(trim($videoLinkurl));
         }
         if ($videoLinkurl != '' && $act_filepath != '') {
             /** Set file type 1 for YouTube/ viddler /dailymotion  */
             $file_type = '1';
             /** Check video url contains youtbe / youtu.be / dailymotion / viddler */
             if (strpos($act_filepath, 'youtube') > 0 || strpos($act_filepath, 'youtu.be') > 0) {
                 /** Get youtube video id from plugin helper */
                 $youtubeVideoID = getYoutubeVideoID($act_filepath);
                 /** Get thumb URL for YouTube videos */
                 $act_opimage = $previewurl = 'http://img.youtube.com/vi/' . $youtubeVideoID . '/maxresdefault.jpg';
                 /** Get preview URL for YouTube videos */
                 $act_image = $img = 'http://img.youtube.com/vi/' . $youtubeVideoID . '/mqdefault.jpg';
                 /** Get YouTube video URL and fetch information  */
                 $act_filepath = $youtubeVideoURL . $youtubeVideoID;
                 $ydetails = hd_getsingleyoutubevideo($youtubeVideoID);
                 /** Get youTube video duration */
                 $youtube_time = $ydetails['items'][0]->contentDetails->duration;
                 if (!empty($youtube_time)) {
                     /** Convert duration into h:m:s format */
                     $di = new DateInterval($youtube_time);
                     $string = '';
                     $min = $di->i;
                     if ($di->h > 0) {
                         $string .= $di->h . ':';
                         /** Check if minutes is <= 9 while hours value is exist */
                         if ($min <= 9) {
                             $min = '0' . $min;
                         }
                     }
                     $duration = $string . $min . ':' . $di->s;
                 }
             } else {
                 if (strpos($act_filepath, 'dailymotion') > 0) {
                     /** Check video URL is dailymotion
                      * If yes, then get id from the url and get thumb, preview image */
                     $split_id = getDailymotionVideoID($act_filepath);
                     $img = $act_image = $act_opimage = $previewurl = 'http://www.dailymotion.com/thumbnail/video/' . $split_id[0];
                 } else {
                     if (strpos($act_filepath, 'viddler') > 0) {
                         /** Check video url is viddler
                          * If yes, then get id from the url and get thumb, preview image */
                         $imgstr = explode('/', $act_filepath);
                         $img = $act_image = $act_opimage = $previewurl = 'http://cdn-thumbs.viddler.com/thumbnail_2_' . $imgstr[4] . '_v1.jpg';
                     } else {
                         $img = '';
                     }
                 }
             }
         } else {
             /** Get video upload form value */
             $act_filepath1 = $_REQUEST['normalvideoform-value'];
             /** Combine upload directory path and file name */
             $act_filepath1 = $this->_srt_path . $act_filepath1;
             /**
              * Check whether custom url option is used
              * If yes, then get video url, thumb url and remove spaces
              * Else, set video url, thumb url as empty
              */
             $act_filepath = $act_optimage = '';
             if (isset($_POST['custom_url'])) {
                 $act_filepath = addslashes(trim($_POST['customurl']));
                 $act_optimage = addslashes(trim('thumb_' . $_POST['custom_url']));
             }
             /** Get ffmpeg settings value */
             $ffmpeg_path = $this->_settingsData->ffmpeg_path;
             /** Set file type as 2 for upload method */
             $file_type = '2';
             /** Get uploaded video duration from plugin helper using ffmpeg */
             $ffmpegResult = getVideoDuration($ffmpeg_path, $act_filepath1);
             $duration = $ffmpegResult[0];
             $matches = $ffmpegResult[1];
             if (!empty($duration)) {
                 /** Convert duration into hours:minutes format */
                 $duration_array = explode(':', $matches[1][0]);
                 $sec = ceil($duration_array[0] * 3600 + $duration_array[1] * 60 + $duration_array[2]);
                 $duration = $this->converttime($sec);
             }
         }
         /** If upload new image for existing video, then rename the images name */
         if ($this->_videoId) {
             $newImagePath = $this->_srt_path . $img1;
             $newPreviewImagePath = $this->_srt_path . $img2;
             $newThumbFileName = explode('_', $img1);
             $newPreviewThumbFileName = explode('_', $img2);
             /**
              * Check if added method is upload
              */
             if ($video_added_method == 2) {
                 /**
                  * Check thumb image is exst in the directory
                  * If exit then rename the new thumb image with the video id
                  */
                 if (file_exists($newImagePath)) {
                     $img1 = $this->_videoId . '_' . $newThumbFileName[1];
                     rename($newImagePath, $this->_srt_path . $img1);
                 }
                 if (file_exists($newPreviewImagePath) && !empty($newPreviewThumbFileName[1])) {
                     /**
                      * Check preview image is exst in the directory
                      * If exit then rename the new preview image with the video id
                      */
                     $img2 = $this->_videoId . '_' . $newPreviewThumbFileName[1];
                     rename($newPreviewImagePath, $this->_srt_path . $img2);
                 }
             }
             /**
              * Check if video added method is embed code
              */
             if ($video_added_method == 5) {
                 $newThumbFileName = explode('_', $img1);
                 /**
                  * Check image is exst in the directory
                  * If exit then rename the new image with the video id
                  */
                 if (file_exists($newImagePath)) {
                     $img1 = $img2 = $this->_videoId . '_' . $newThumbFileName[1];
                     rename($newImagePath, $this->_srt_path . $img1);
                 }
             }
         }
         /**
          * Get Amazon S3 bucket settings from database
          */
         $player_colors = getPlayerColorArray();
         /**
          * Check if bucket option is enabled and name is exist
          */
         if ($player_colors['amazonbuckets_enable'] && $player_colors['amazonbuckets_name']) {
             /**
              * Get bucket name
              */
             $s3bucket_name = $player_colors['amazonbuckets_name'];
             /**
              * Check video is exist
              * If exist then get bucket video for uploaded videos
              */
             $video1 = $this->getAmazonURLOrUploadFile($video1, $s3bucket_name);
             /** Get bucket hd video for uploaded videos */
             $video2 = $this->getAmazonURLOrUploadFile($video2, $s3bucket_name);
             /** Get bucket thumb image for uploaded videos */
             $img1 = $this->getAmazonURLOrUploadFile($img1, $s3bucket_name);
             /** Get bucket preview image for uploaded videos */
             $img2 = $this->getAmazonURLOrUploadFile($img2, $s3bucket_name);
         }
         /** Get customurl parameter */
         $act_image = addslashes(trim($_POST['customurl']));
         $act_hdpath = $act_name = $act_opimage = '';
         /** If video url is not empty then get image and preview image */
         if (!empty($act_filepath)) {
             /** Set file type 1 for YouTube, dailymotion and viddler videos */
             $file_type = '1';
             if (strpos($act_filepath, 'youtube') > 0 || strpos($act_filepath, 'youtu.be') > 0) {
                 /**
                  * Get Youtube video id
                  * Based on that get video URL , image, preview image 
                  */
                 $match = getYoutubeVideoID($act_filepath);
                 $act_filepath = $youtubeVideoURL . $match;
                 /** Get thumbimage for youtube video */
                 $act_image = 'http://i3.ytimg.com/vi/' . $match . '/mqdefault.jpg';
                 /** Get previewimage for youtube video */
                 $act_opimage = 'http://i3.ytimg.com/vi/' . $match . '/maxresdefault.jpg';
                 /** Call fucntion to get YouTube video information */
                 $ydetails = hd_getsingleyoutubevideo($match);
                 if ($ydetails) {
                     if ($act_name == '') {
                         /** Get youtube video title */
                         $act_name = addslashes($ydetails['items'][0]->snippet->title);
                     }
                 } else {
                     /** Else display error for youtube videos*/
                     render_error(__('Could not retrieve Youtube video information', APPTHA_VGALLERY));
                 }
             } else {
                 if (strpos($act_filepath, 'dailymotion') > 0) {
                     /** Get dailymotion video id */
                     $split_id = getDailymotionVideoID($act_filepath);
                     /** Get dailymotion video and thumb url */
                     $act_image = $act_opimage = 'http://www.dailymotion.com/thumbnail/video/' . $split_id[0];
                 } else {
                     if (strpos($act_filepath, 'viddler') > 0) {
                         /** Get viddler video id */
                         $imgstr = explode('/', $act_filepath);
                         /** Get viddler video thumb and preview image */
                         $act_image = $act_opimage = 'http://cdn-thumbs.viddler.com/thumbnail_2_' . $imgstr[4] . '_v1.jpg';
                     } else {
                         $imgstr = '';
                     }
                 }
             }
         } else {
             if ($video1 != '') {
                 $act_filepath = $video1;
             }
             if ($video2 != '') {
                 $act_hdpath = $video2;
             }
             if ($img1 != '') {
                 $act_image = $img1;
             }
             if ($img2 != '') {
                 $act_opimage = $img2;
             }
         }
         /** Set filetype as 5 for embed method */
         if (!empty($embedcode)) {
             $video_added_method = $file_type = '5';
         }
         /** Get video details for URL type videos */
         if ($video_added_method == 3) {
             $act_filepath = $_POST['customurl'];
             $act_image = $_POST['customimage'];
             $act_opimage = $_POST['custompreimage'];
             $act_hdpath = $_POST['customhd'];
         }
         /** Get video details for rtmp videos */
         if (!empty($streamname)) {
             $file_type = '4';
             /** Get filepath3 from params */
             $thumb_image = filter_input(INPUT_POST, 'filepath3');
             $act_image = $thumb_image;
             $act_opimage = $thumb_image;
         }
         if ($video_added_method == 4) {
             /** Get custom url from params */
             $act_filepath = filter_input(INPUT_POST, 'customurl');
             /** Get customhd from params */
             $act_hdpath = filter_input(INPUT_POST, 'customhd');
             /** Get customimage from params */
             $act_image = filter_input(INPUT_POST, 'customimage');
             /** Get custompreimage from params */
             $act_opimage = filter_input(INPUT_POST, 'custompreimage');
         }
         /** Store video form values into single array */
         $videoData = array('name' => $videoName, 'description' => $videoDescription, 'embedcode' => $embedcode, 'file' => $act_filepath, 'file_type' => $video_added_method, 'member_id' => $member_id, 'duration' => $duration, 'hdfile' => $act_hdpath, 'streamer_path' => $streamname, 'islive' => $islive, 'image' => $act_image, 'opimage' => $act_opimage, 'link' => $videoLinkurl, 'featured' => $videoFeatured, 'download' => $videoDownload, 'postrollads' => $videoPostrollads, 'midrollads' => $videomidrollads, 'imaad' => $videoimaad, 'prerollads' => $videoPrerollads, 'publish' => $videoPublish, 'google_adsense' => $google_adsense, 'google_adsense_value' => $google_adsense_value, 'amazon_buckets' => $amazon_buckets);
         /**
          * Get current date and assign default value
          * for srt files, language and slug
          */
         //$videoData ['post_date']  = date ( 'Y-m-d H:i:s' );
         if (empty($this->_videoId)) {
             $videoData['ordering'] = getAllVideosCount();
             $videoData['slug'] = $videoData['srtfile1'] = $videoData['srtfile2'] = $videoData['subtitle_lang1'] = $videoData['subtitle_lang2'] = '';
         }
         /** Call funtion to perform add / update action */
         $this->addUpdateVideoData($videoData);
     }
 }
コード例 #3
0
/**
 * youtube function
 */
function youtubeurl()
{
    $act_filepath = addslashes(trim($_GET['filepath']));
    if (!empty($act_filepath)) {
        if (strpos($act_filepath, 'youtube') > 0 || strpos($act_filepath, 'youtu.be') > 0) {
            if (strpos($act_filepath, 'youtube') > 0) {
                $imgstr = explode('v=', $act_filepath);
                $imgval = explode('&', $imgstr[1]);
                $match = $imgval[0];
            } else {
                if (strpos($act_filepath, 'youtu.be') > 0) {
                    $imgstr = explode('/', $act_filepath);
                    $match = $imgstr[3];
                    $act_filepath = 'http://www.youtube.com/watch?v=' . $imgstr[3];
                }
            }
            $youtube_data = hd_getsingleyoutubevideo($match);
            if ($youtube_data) {
                $act[0] = addslashes($youtube_data['title']);
                if (isset($youtube_data['thumbnail_url'])) {
                    $act[3] = $youtube_data['thumbnail_url'];
                }
                $act[4] = $act_filepath;
                if (isset($youtube_data['description'])) {
                    $act[5] = addslashes($youtube_data['description']);
                }
                if (isset($youtube_data['tags'])) {
                    $act[6] = addslashes($youtube_data['tags']);
                }
            } else {
                $this->render_error(__('Could not retrieve Youtube video information', 'hdflvvideoshare'));
            }
        } else {
            $act[4] = $act_filepath;
            $this->render_error(__('URL entered is not a valid Youtube Url', 'hdflvvideoshare'));
        }
        return $act;
    }
}
コード例 #4
0
/**
 * youtube function
 */
function youtubeurl()
{
    $video_id = addslashes(trim($_GET['filepath']));
    if (!empty($video_id)) {
        $act_filepath = 'http://www.youtube.com/watch?v=' . $video_id;
        $youtube_data = hd_getsingleyoutubevideo($video_id);
        if ($youtube_data) {
            $act[0] = addslashes($youtube_data['title']);
            if (isset($youtube_data['thumbnail_url'])) {
                $act[3] = $youtube_data['thumbnail_url'];
            }
            $act[4] = $act_filepath;
            if (isset($youtube_data['description'])) {
                $act[5] = addslashes($youtube_data['description']);
            }
            if (isset($youtube_data['tags'])) {
                $act[6] = addslashes($youtube_data['tags']);
            }
        } else {
            $this->render_error(__('Could not retrieve Youtube video information', 'hdflvvideoshare'));
        }
        return $act;
    }
}