public static function YoutubeShortCodeHandler($arguments, $content, $parser, $shortcode) { $contentBlock = Youtube::get()->filter(array("ID" => $arguments["ID"]))->First(); if ($contentBlock) { return $contentBlock->renderWith("Youtube", $arguments); } }
/** * Get Youtube video info by video id * @param Request $request * @return Response */ public function queryYoutubeVideo(Request $request) { $video = null; if ($request->has('id')) { $video = \Youtube::getVideoInfo($request->input('id')); } return new Response(json_encode($video)); }
public function listChannel($usuario) { $channel = YoutubeService::getChannelByName($usuario); $playlists = YoutubeService::getPlaylistsByChannelId($channel->id); $videos = []; foreach ($playlists as $playlist) { $videos[$playlist->snippet->title] = YoutubeService::getPlaylistItemsByPlaylistId($playlist->id); } return $videos; }
public function postAdd() { if (!$this->checkRoute()) { return Redirect::route('index'); } $title = 'Add A Youtube Video / Playlist - ' . $this->site_name; $input = Input::only('url', 'category', 'modpack', 'mod'); $validator = Validator::make($input, ['url' => 'required']); if ($validator->fails()) { return Redirect::action('YoutubeController@getadd')->withErrors($validator)->withInput(); } $youtube = new Youtube(); $processed_url = $this->processURL($input['url']); if (!$processed_url['type']) { return Redirect::action('YoutubeController@getadd')->withErrors(['message' => 'Unable to process URL.'])->withInput(); } $youtube_information = $youtube->getVideoInfo($processed_url['id'], $processed_url['type']); if (!$youtube_information) { return Redirect::action('YoutubeController@getadd')->withErrors(['message' => 'Unable to process Youtube API.'])->withInput(); } $youtube_information = $youtube_information->items[0]; $youtube->type = $processed_url['type']; $youtube->title = $youtube_information->snippet->title; $youtube->youtube_id = $youtube_information->id; $youtube->channel_title = $youtube_information->snippet->channelTitle; $youtube->channel_id = $youtube_information->snippet->channelId; $youtube->thumbnail = $youtube_information->snippet->thumbnails->medium->url; $youtube->category_id = $input['category']; if ($input['modpack']) { $youtube->modpack_id = $input['modpack']; } elseif ($input['mod']) { $youtube->mod_id = $input['mod']; } $youtube->last_ip = Request::getClientIp(); $success = $youtube->save(); if ($success) { Cache::tags('modpacks')->flush(); Cache::tags('mods')->flush(); Queue::push('BuildCache'); return View::make('youtube.add', ['title' => $title, 'success' => true, 'categories' => $this->categories]); } return Redirect::action('YoutubeController@getadd')->withErrors(['message' => 'Unable to add modpack code.'])->withInput(); }
public function agregarYoutube() { $hosts = array('youtube.com', 'www.youtube.com'); $paths = array('/watch'); $infoValidate = Video::validarUrl(Input::get('video'), $hosts, $paths); if ($infoValidate['estado']) { if ($ID_video = Youtube::parseVIdFromURL(Input::get('video'))) { $datos = array('ID_video' => $ID_video); //Aca se manda a la funcion agregarItem de la clase Item //y se queda con la respuesta para redirigir cual sea el caso $respuesta = Video::agregarYoutube($datos); return Redirect::to('admin/' . $this->folder_name)->withErrors($respuesta['mensaje'])->withInput(); } else { $infoValidate['texto'] = 'Hubo problemas con la información del video. Intente más tarde.'; } } //echo $infoValidate['texto']; return Redirect::to('admin/' . $this->folder_name . '/agregar')->withErrors($infoValidate['texto'])->withInput(); }
/** * @param $key * @return array */ public function getVideoInfo($key) { $result = []; $result['duration'] = ''; $result['thumbnail'] = ''; $key = trim($key); try { if (filter_var($key, FILTER_VALIDATE_URL)) { $array = explode('=', $key); $key = end($array); } $video = \Youtube::getVideoInfo($key); $start = new \DateTime('@0'); // Unix epoch $start->add(new \DateInterval($video->contentDetails->duration)); $result['duration'] = $start->format('H:i:s'); $result['thumbnail'] = isset($video->snippet->thumbnails->standard->url) ? $video->snippet->thumbnails->standard->url : $video->snippet->thumbnails->high->url; } catch (\Exception $e) { return $result; } return $result; }
public function getSitemapVideos() { $videos = Youtube::orderBy('created_at', 'desc')->get(); foreach ($videos as $video) { if ($video->category_id == 1) { $modpack = $video->modpack; $version = $modpack->version; if (!$modpack) { break; } $friendly_name = Str::slug($video->channel_title); $url_version = preg_replace('/\\./', '-', $version->name); $this->sitemap->add(URL::to('modpack/' . $url_version . '/' . $modpack->slug . '/lets-play/' . $video->id . '-' . $friendly_name)); } elseif ($video->category_id == 2) { $mod = $video->mod; if (!$mod) { break; } $friendly_name = Str::slug($video->channel_title); $this->sitemap->add(URL::to('mod/' . $mod->slug . '/spotlight/' . $video->id . '-' . $friendly_name)); } elseif ($video->category_id == 3) { $mod = $video->mod; if (!$mod) { break; } $friendly_name = Str::slug($video->channel_title); $this->sitemap->add(URL::to('mod/' . $mod->slug . '/tutorial/' . $video->id . '-' . $friendly_name)); } else { break; } } return $this->sitemap->render('xml'); }
if (strlen($gYTSearch) >= 3) { $lHTML = file_get_html(Config::$YoutubeSearchVideoURL . urlencode($gYTSearch)); $lVideo = new Videos(); foreach($lHTML->find('div[class=yt-lockup-content] h3 a') as $lElement) { if (strlen($lElement->href) > 0 && strlen($lElement->title) > 0) { if (!preg_match(Config::$YoutubeIgnoreResultRegex, $lElement->title)) { $lYTID = Youtube::extractYTID($lElement->href); $lYTTitle = preg_replace('/[\'\"\`\=\&\%\'\+]+/', ' ', $lElement->title); $lYTTitle = preg_replace('/\s{2,}/', ' ', $lYTTitle); if (Youtube::validYoutubeID($lYTID)) { $lRec = " {\n"; $lRec .= " \"ytid\": \"$lYTID\",\n"; $lRec .= " \"href\": \"$lElement->href\",\n"; $lRec .= " \"title\": \"$lElement->title\"\n"; $lRec .= " }"; array_push($gOutRecords, $lRec); $lVideo->addVideo($lYTID, $lYTTitle); } else { Log::writeLog(1, $_SERVER["SCRIPT_NAME"], "Invalid Youtube ID \"$lYTID\""); }
// $refresh_token='access_granted'; // } // // $DB = new DB(); // $DB->query_no_result("INSERT into youtube_tokens (access_token,refresh_token,updated) values ('".$result_array['access_token']."','".$refresh_token."','". date("Y-m-d H:i:s")."')"); // } // // curl_close($ch); //return $result; } } ?> <h3>Authorization Url</h3> <div><a href="<?php echo (new Youtube())->authorization_url(); ?> ">Request</a></div> <h3>Access Tokens, Refresh Tokens</h3> <div><?php //echo (new Youtube())->getTokens(); ?> </div> <?php $tokens = new Youtube(); $tokens->getTokens(); ?>
/** * Manually updates field with new video stats * @param [type] $column [description] * @param [type] $entry_id [description] * @param [type] $youtube_id [description] * @return [type] [description] */ private function _save_field_data($column, $entry_id, $youtube_id) { // stats cache has expired, update the values for the field $y = new Youtube($this->settings['api_key'], $youtube_id); list($views) = $y->stats(); list($title, $since) = $y->snippet(); // save the field $data = implode('|', array($youtube_id, date('U'), $title, $views, $since)); $val = array($column => $data); return ee()->db->where('entry_id', $entry_id)->update('channel_data', $val); }
<?php /** * Route URI's */ use Illuminate\Support\Facades\Redirect; Route::group(['prefix' => config('youtube.route_base_uri')], function () { Route::get(config('youtube.authentication_uri'), function () { return redirect()->to(Youtube::createAuthUrl()); }); Route::get(config('youtube.redirect_uri'), function (\Illuminate\Http\Request $request) { $code = $request->get('code'); if (is_null($code)) { throw new Exception('$_GET[\'code\'] is not set.'); } else { $token = Youtube::authenticate($code); Youtube::saveAccessTokenToDB($token); } $afterRedirectUri = config('youtube.after_redirect_uri'); if (isset($afterRedirectUri)) { return redirect()->route($afterRedirectUri, ['code' => $token]); } else { return redirect('/'); } }); });
|-------------------------------------------------------------------------- | Routes File |-------------------------------------------------------------------------- | | Here is where you will register all of the routes in an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the controller to call when that URI is requested. | */ Route::get('/', function () { return view('welcome'); }); Route::get('/hello', function () { $activities = Youtube::getActivitiesByChannelId('UC5aFrNqC7R5N5CNRA9MIi7g'); $video = $activities[0]->contentDetails->upload->videoId; $videoInfo = Youtube::getVideoInfo($video); var_dump($videoInfo); }); Route::get('update', 'YTUpdate\\YTUpdateController@UpDateVideo'); /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | This route group applies the "web" middleware group to every route | it contains. The "web" middleware group is defined in your HTTP | kernel and includes session state, CSRF protection, and more. | */ Route::group(['middleware' => ['web']], function () { //
<?php require_once "inc/start.php"; if (!var_check($_GET['id'])) { redirect("index.php?error=No+Video+ID"); } $id = $_GET['id']; if (!youtube_validate_id($id)) { redirect("index.php?error=Invalid+Video+ID"); } $edit = var_check($_GET['edit']); $video = new Youtube($id); $info = $video->retrieve_info(); if ($info == False) { redirect("index.php?error=Video+Doesn%27t+Exist"); } $title = format_string(Config::Get("go.title"), array("ID" => $id, "TITLE" => $info['title'])); $description = format_string(Config::Get("go.description"), array("ID" => $id, "TITLE" => $info['title'])); $keywords = format_string(Config::Get("go.keywords"), array("ID" => $id, "TITLE" => $info['title'])); $stream = $video->get_best_stream(); $caption_url = sprintf("ajax/get_caption.php?id=%s&type=vtt%s", $id, $edit ? "&edit=True" : ""); $caption = "<span class=\"text-success\"><b>Caption</b></span>"; $craption = "<span class=\"text-danger\"><b>Craption</b></span>"; $caption_type = $edit ? $caption : $craption; #$button_go_craption = "<a href=\"go.php?id=".$id."&edit=True\" id=\"caption\" class=\"btn btn-default btn-block btn-success\" title=\"Edit this Craption\">Edit this Craption</a>"; #$button_go_edit = "<a href=\"go.php?id=".$id."\" id=\"caption\" class=\"btn btn-default btn-block btn-danger\" title=\"Take a look at the original Craption\">Take a look at the original Craption</a>"; ?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US"> <?php
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Youtube the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Youtube::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<?php require_once "../inc/start.php"; if (var_check($_POST['id']) && var_check($_POST['caption_block_value']) && var_check($_POST['caption_block_start'])) { if (!var_check($_POST['id'])) { die($error_no_id['value']); } $id = $_POST['id']; $cue = array("start" => $_POST['caption_block_start'], "value" => $_POST['caption_block_value']); $video = new Youtube($id); echo $video->update_asr_cue($cue); return True; }
public function __construct($rawPost) { parent::__construct($rawPost); $this->channel = \Youtube::getChannelById($this->rawPost->snippet->channelId); }
/** * Store a newly created resource in storage. * * @return Response */ public function postStore(ProjectFormRequest $request) { $step = $request->get('step'); $secret_key = $request->get('_secret_key_'); if (empty($secret_key)) { $project = new Project(); $project->fill($request->except('_token')); $project->user_id = $request->input('user_id'); $project->slug = Str::slug($request->input('name')); $project->currencytype = $request->input('currencytype'); # Attach file with project if ($request->hasFile('file_attachment')) { $response = Event::fire(new FileAttachment($request, ['input_file_tag' => 'file_attachment', 'width' => $this->width, 'height' => $this->height, 'mHeight' => $this->mHeight, 'mWidth' => $this->mWidth])); if (count($response) > 0) { $project->file_attachment = $response[0]; } } /** section to upload video file to Youtube after saving it in * a local upload folder */ if ($request->hasFile('video_attachment') && $request->file('video_attachment')->isValid()) { //dd('here'); $uploadedVideo = $request->file('video_attachment'); try { $randomFileName = FileUploadUtilities::generateRandomFileName($uploadedVideo->getClientOriginalExtension()); $uploadedVideoFile = $uploadedVideo->move(FileUploadUtilities::getAbsoluteVideoUploadPath(), $randomFileName); //uploading it to YouTube using library façade //dd(FileUploadUtilities::getAbsoluteVideoUploadPath(). $randomFileName); $id = \Youtube::upload(FileUploadUtilities::getAbsoluteVideoUploadPath() . $randomFileName, ['title' => $request->get('name'), 'description' => $request->get('short_description'), 'category_id' => 10, 'tags' => [$request->get('name')]]); dd($id); } catch (\Exception $ex) { dd($ex->getMessage()); return redirect()->back()->withError('Video file could not be uploaded')->withInput(); } } if ($request->hasFile('pitch_video')) { $file = $request->file('pitch_video'); $imageName = date("ymdHis") . '.' . $file->getClientOriginalExtension(); $realPath = base_path() . '/public/images/file-attached-to-project/video/'; $openMakePath = $realPath . $imageName; $request->file('pitch_video')->move($realPath, $imageName); $project->pitch_video = $imageName; } else { $project->pitch_video = ''; } # Attach file with project : End if ($project->save()) { $auto_id = $project->id; //$secret_id = Crypt::encrypt($auto_id); $request->session()->flash('alert-success', 'Project has been created successfully'); $step = $step + 1; Session::put('step', $step); Session::put('last_insert_id', $auto_id); return \Redirect::to('/admin/project/create'); } else { Session::put('step', $step); $request->session()->flash('alert-warning', 'Error on project creation ! '); return redirect()->back()->withInput(); } } else { $project_id = $secret_key; if ($step == 1) { $project = Project::find($project_id); $project->fill($request->except('_token')); $project->user_id = $request->input('user_id'); $project->slug = Str::slug($request->input('name')); if ($request->hasFile('file_attachment')) { $response = Event::fire(new FileAttachment($request, ['input_file_tag' => 'media_file_attachment', 'width' => $this->width, 'height' => $this->height, 'mHeight' => $this->mHeight, 'mWidth' => $this->mWidth])); if (count($response) > 0) { $project->file_attachment = $response[0]; } } if ($project->save()) { $request->session()->flash('alert-success', 'Project has been created successfully'); $step = $step + 1; Session::put('step', $step); return \Redirect::to('/admin/project/create'); } } if ($step == 2) { $projectData = array(); $projectData['details_description'] = $request->get('details_description'); $projectData['address'] = $request->get('address'); $projectData['address_alternate'] = $request->get('address_alternate'); $projectData['city'] = $request->get('city'); $projectData['state'] = $request->get('state'); $projectData['country_id'] = $request->get('country_id'); $projectData['feed_url'] = $request->get('feed_url'); $projectData['pincode'] = $request->get('pincode'); $projectData['external_video_url'] = $request->get('external_video_url'); //$projectData['media_file_attachment'] = $request->get('media_file_attachment'); $projectData['media_file_short_note'] = $request->get('media_file_short_note'); if ($request->hasFile('media_file_attachment')) { $response = Event::fire(new FileAttachment($request, ['input_file_tag' => 'media_file_attachment', 'width' => $this->width, 'height' => $this->height, 'mHeight' => $this->mHeight, 'mWidth' => $this->mWidth])); if (count($response) > 0) { $projectData['media_file_attachment'] = $response[0]; } } if (Project::where('id', $project_id)->update($projectData)) { $step = $step + 1; Session::put('step', $step); return \Redirect::to('/admin/project/create'); } else { Session::put('step', $step); $request->session()->flash('alert-warning', 'Error on project creation ! '); return redirect()->back()->withInput(); } } if ($step == 3) { $projectData = array(); //dd( $request->all()); $reward_row_count = $request->get('reward_row_count'); $pledge_amount = $request->get('pledge_amount'); $short_note = $request->get('short_note'); $user_limit = $request->get('user_limit'); $delevery_year = $request->get('delevery_year'); $delevery_month = $request->get('delevery_month'); $shipping_details = $request->get('shipping_details'); $file = $request->file('file_attachment'); if (count($pledge_amount) > 0) { $rewardsData = array(); for ($k = 0; $k <= $reward_row_count; $k++) { $reward = new Reward(); if ($file[$k] != '') { $imageName = uniqid('project-reward-', true) . '.' . $file[$k]->getClientOriginalExtension(); $realPath = base_path() . '/public/images/file-attached-to-project/'; $resizePath = base_path() . '/public/images/file-attached-to-project/resize/' . $imageName; $openMakePath = $realPath . $imageName; $file[$k]->move($realPath, $imageName); Image::make($openMakePath)->resize(1400, 623)->save($resizePath); $reward->reword_image = $imageName; } else { $reward->reword_image = "null"; } if ($k == 0) { $reward->active = 1; } else { $reward->active = 0; } $reward->pledge_amount = $pledge_amount[$k]; $reward->short_note = $short_note[$k]; $reward->user_limit = $user_limit[$k]; $reward->delevery_year = $delevery_year[$k]; $reward->delevery_month = $delevery_month[$k]; $reward->shipping_details = $shipping_details[$k]; $reward->P_ID = $project_id; $reward->save(); } $step = $step + 2; Session::put('step', $step); return \Redirect::to('/admin/project/create'); } } } }
function loadVideoInfo(&$video) { $isArray = is_array($video); if ($isArray) { foreach ($video as $v) { $infos = Youtube::getVideoInfo($v->url); $v->infos = $infos; } } else { $infos = Youtube::getVideoInfo($video->url); $video->infos = $infos; } }
/* * Initialize parameter variables. */ $gVID = isset($_POST['vid'])?$_POST['vid']:$_GET['vid']; $gUID = isset($_POST['uid'])?$_POST['uid']:$_GET['uid']; if (Security::containsIllegalChars($gUID)) { Log::writeLog(1, $_SERVER["SCRIPT_NAME"], "User ID \"$gUID\" contains illegal characters."); } elseif (Security::containsIllegalChars($gVID)) { Log::writeLog(1, $_SERVER["SCRIPT_NAME"], "Video ID \"$gVID\" contains illegal characters."); } elseif (strlen($gUID) > 0 && strlen($gVID) > 0 && Youtube::validYoutubeID($gVID)) { /* * Find video entry. */ $gLocalSrch = new Videos(); $gLocalSrchResult = $gLocalSrch->getSongByID($gVID); $lVideoTitle = (strlen($gLocalSrchResult[VideoTitle])>64)?substr($gLocalSrchResult[VideoTitle], 0, 64)."...":$gLocalSrchResult[VideoTitle]; /* * Insert transcode request into db. */ $lClientIP = isset($_SERVER['HTTP_X_FORWARDED_FOR'])?$_SERVER['HTTP_X_FORWARDED_FOR']:$_SERVER['REMOTE_ADDR']; $lStatement = "INSERT INTO Conversions (Timestamp, VideoID, RequestingUID, ClientIP, Description) Values(NOW(), '$gVID', '$gUID', '$lClientIP', '$lVideoTitle')"; $lDB = new Database();
print_r($playlists); echo "</pre>"; } */ //echo $youtube->page_info['totalResults'] . "<br>"; //echo $youtube->page_info['resultsPerPage'] . "<br>"; /* $playlist_items = $youtube->getPlaylistItemsByPlaylistId('PL6gx4Cwl9DGAKIXv8Yr6nhGJ9Vlcjyymq'); echo "<pre>"; print_r($playlist_items); echo "</pre>"; */ }); Route::get('/mock', function () { $youtube = new Youtube(array('key' => Config::get('keys.youtube'))); $youtube_channel = $youtube->getChannelByName('CodingEntrepreneurs'); $next_playlisttoken = ''; do { $playlists = $youtube->getPlaylistsByChannelId($youtube_channel->id, array('maxResults' => 50, 'pageToken' => $next_playlisttoken)); $next_playlisttoken = $youtube->page_info; if (!empty($playlists)) { foreach ($playlists as $pl) { //only cached playlists that are public if ($pl->status->privacyStatus == 'public') { $playlist_id = $pl->id; $next_videostoken = ''; do { $playlist_items = $youtube->getPlaylistItemsByPlaylistId($playlist_id, array('maxResults' => 50, 'pageToken' => $next_videostoken)); $next_videostoken = $youtube->page_info; echo "next video token: ";
public function getUploads() { $channel = \Youtube::getChannelById($this->channelId); $playlistId = $channel->contentDetails->relatedPlaylists->uploads; return $this->getPlaylistVideos($playlistId); }
private function getYoutubeResults($query) { if (Cache::has($query)) { return Cache::get($query); } else { $params = ['q' => $query, 'type' => 'video', 'part' => 'id, snippet', 'regionCode' => 'KR', 'relevanceLanguage' => 'ko', 'maxResults' => 6]; $value = \Youtube::searchAdvanced($params); Cache::put($query, $value, 1440); // store it for 24 hours return $value; } }
<?php include_once "services.php"; $page = !empty($_GET["page"]) ? $_GET["page"] : ""; $reddit = new Reddit(); $soundcloud = new SoundCloud(); $youtube = new Youtube(); // $beatport = new Beatport(); $S = new Services(); if ($page == "filters") { foreach ($S::getServices() as $k => $v) { echo "<input type=\"checkbox\" name=\"tracks-services\" value=\"{$k}\" id=\"{$k}\" /><label for=\"{$k}\">{$k}</label><br />"; } echo <<<EOT <script type="text/javascript"> \$("#filters-tracks").siblings().hide().end().show().find("input").button({ icons: { primary: "ui-icon-check" } }).click(function(){ \tif( this.checked ) { \t\t\$(this).button("option", "icons", { primary: "ui-icon-close" }); \t\t\$("#loadhere").children("#tracks").find(".item."+\$(this).val().toLowerCase()).hide(); \t} \telse { \t\t\$(this).button("option", "icons", { primary: "ui-icon-check" }); \t\t\$("#loadhere").children("#tracks").find(".item."+\$(this).val().toLowerCase()).show(); \t} }); </script> EOT; } else { if ($page == "search") { header("Content-type: application/json"); $q = urldecode($_GET["q"]);
* Bluethrust Clan Scripts v4 * Copyright 2014 * * Author: Bluethrust Web Development * E-mail: support@bluethrust.com * Website: http://www.bluethrust.com * * License: http://www.bluethrust.com/license.php * */ if (!defined("SHOW_PROFILE_MAIN")) { exit; } include_once $prevFolder . "plugins/youtube/youtube.php"; include_once $prevFolder . "plugins/youtube/ytbuttoncss.php"; $ytObj = new Youtube($mysqli); if ($ytObj->hasYoutube($memberInfo['member_id'])) { $ytInfo = $ytObj->get_info_filtered(); if ($ytInfo['showsubscribe'] + $ytInfo['showvideos'] > 0) { echo "\n\t\t\t\t\t<div class='formTitle' style='position: relative; text-align: center; margin-top: 20px'>Youtube</div>\n\t\t\t\t\t\n\t\t\t\t\t<table class='profileTable' style='border-top-width: 0px'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td class='main' style='padding: 25px 0px'>\n\t\t\t\t\t\t\t<div id='loadingSpiralYTCache' class='loadingSpiral' style='padding-top: 0px'>\n\t\t\t\t\t\t\t\t<p align='center'>\n\t\t\t\t\t\t\t\t\t<img src='" . $MAIN_ROOT . "themes/" . $THEME . "/images/loading-spiral.gif'><br>Refreshing Data\n\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t"; if ($ytInfo['showsubscribe'] == 1) { echo "\n\n\t\t\t\t\t<div id='ytInfoCard'>" . $ytObj->dispSubscribeButton() . "</div>\n\t\t\t\t\t<div style='font-style: italic; text-align: center; margin-top: 3px; margin-left: auto; margin-right: auto; margin-bottom: 25px; position: relative' class='main'>\n\t\t\t\t\t\tLast updated <span id='lastUpdateTime'>" . getPreciseTime($ytInfo['lastupdate']) . "</span>\n\t\t\t\t\t</div>\n\n\t\t\t\t"; } if ($ytInfo['showvideos'] > 0) { echo "\n\n\t\t\t\t\t<div id='ytVideosContainer' class='ytProfileVideos'>\n\t\t\t\t\t\t<div style='position: absolute'>\n\t\t\t\t\t\t"; $result = $mysqli->query("SELECT * FROM " . $dbprefix . "youtube_videos WHERE youtube_id = '" . $ytInfo['youtube_id'] . "' ORDER BY youtubevideo_id LIMIT " . $ytInfo['showvideos']); while ($row = $result->fetch_assoc()) { echo "<div class='ytVideo'><a href='http://www.youtube.com/watch?v=" . $row['video_id'] . "' target='_blank'><img src='" . $row['thumbnail'] . "' width='185' height='104' style='border: 0px'><p class='main' style='padding-top: 2px; margin-top: 0px'>" . $row['title'] . "</a></p></div>"; } echo "\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t\n\t\t\t\t"; echo "\n\t\t\t\t\t<div class='videoScroller'></div>\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t<script type='text/javascript'>\n\t\t\t\t\t\t\$(document).ready(function() {\n\t\t\t\t\t\t\tvar videoHeight = 0;\n\t\t\t\t\t\t\t\$('.ytVideo').each(function(index) {\n\t\t\t\t\t\t\t\tif(\$(this).height() > videoHeight) {\n\t\t\t\t\t\t\t\t\tvideoHeight = \$(this).height();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\$('#ytVideosContainer').css('height', videoHeight+'px');\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tvar maxScroll = \$('#ytVideosContainer')[0].scrollWidth-\$('#ytVideosContainer').width();\n\t\t\t\t\t\t\tif(maxScroll > 0) {\n\t\t\t\t\t\t\t\t\$('.videoScroller').slider({\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tmax: maxScroll,\n\t\t\t\t\t\t\t\t\tslide: function(event, ui) {\n\t\t\t\t\t\t\t\t\t\t\$('#ytVideosContainer').scrollLeft(\$(this).slider('option', 'value'));\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tchange: function(event, ui) {\n\t\t\t\t\t\t\t\t\t\t\$('#ytVideosContainer').scrollLeft(\$(this).slider('option', 'value'));\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t});\n\t\t\t\t\t</script>\n\t\t\n\t\t\t\t\t\n\t\t\t\t";
if (!var_check($_GET['id'])) { die($error_no_id['value']); } $id = $_GET['id']; if (!youtube_validate_id($id)) { die($error_invalid_id['value']); } if (!var_check($_GET['type'])) { die($error_no_caption_format['value']); } $type = strtolower($_GET['type']); if (!in_array($type, $caption_format)) { die($error_caption_format_not_exist['value']); } $edit = var_check($_GET['edit'], True); $video = new Youtube($id); $data = $video->get_asr_caption($edit); if ($data == False) { die("No captions"); } if (var_check($_GET['dl'])) { // Download it. header('Content-Transfer-Encoding: binary'); if ($edit) { header(sprintf("Content-Disposition: attachment; filename=\"asr_%s_corrected.%s\"", $id, $type)); } else { header(sprintf("Content-Disposition: attachment; filename=\"asr_%s.%s\"", $id, $type)); } } switch ($type) { case "vtt":
public function createWebsite() { $user_id = Auth::user()->id; $rules = array('title' => 'required', 'type' => 'required', 'account_id' => 'required'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::to('/websites/new')->withErrors($validator)->withInput(); } else { $client = new GuzzleHttp\Client(); $title = Input::get('title'); $tagline = Input::get('tagline'); $about = Input::get('about'); $type = Input::get('type'); $account_id = Input::get('account_id'); $domain_name = Input::get('domain_name'); $is_public = 0; if (Input::has('public')) { $is_public = 1; } $website = new Website(); $website->user_id = $user_id; $website->long_id = Str::slug(substr($title, 0, 160) . '-' . str_random(6)); $website->type = $type; $website->domain_name = $domain_name; $website->title = $title; $website->tagline = $tagline; $website->about = $about; $website->public = $is_public; $website->save(); $website_id = $website->id; if ($type == 'youtube') { $youtube = new Youtube(array('key' => Config::get('keys.youtube'))); $youtube_channel = $youtube->getChannelByName($account_id); $site_channel_id = $youtube_channel->id; $site_channel_title = $youtube_channel->snippet->title; $site_channel_description = $youtube_channel->snippet->description; $site_channel_thumbnail = $youtube_channel->snippet->thumbnails->high->url; } else { if ($type == 'vimeo') { $vimeo = $client->get("http://vimeo.com/api/v2/{$account_id}/info.json"); $vimeo_channel = json_decode($vimeo->getBody(), true); $site_channel_id = $vimeo_channel['id']; $site_channel_title = $vimeo_channel['display_name']; $site_channel_description = strip_tags($vimeo_channel['bio']); $site_channel_thumbnail = $vimeo_channel['portrait_huge']; } } $channel = new Channel(); $channel->user_id = $user_id; $channel->website_id = $website_id; $channel->channel_id = $site_channel_id; $channel->title = $site_channel_title; $channel->description = $site_channel_description; $channel->thumbnail = $site_channel_thumbnail; $channel->save(); $channel_id = $channel->id; $next_playlisttoken = ''; if ($type == 'youtube') { do { $playlists = $youtube->getPlaylistsByChannelId($youtube_channel->id, array('maxResults' => 50, 'pageToken' => $next_playlisttoken)); $next_playlisttoken = $youtube->page_info; if (!empty($playlists)) { foreach ($playlists as $pl) { //only cached playlists that are public if ($pl->status->privacyStatus == 'public') { $playlist_id = $pl->id; $playlist_params['body'] = array('id' => $playlist_id, 'user_id' => $user_id, 'website_id' => $website_id, 'channel_id' => $channel_id, 'title' => $pl->snippet->title, 'playlist_type' => 'youtube', 'description' => $pl->snippet->description, 'thumbnail' => $pl->snippet->thumbnails->high->url, 'published_at' => $pl->snippet->publishedAt); $playlist_params['index'] = 'video-websites'; $playlist_params['type'] = 'playlist'; $playlist_params['id'] = $playlist_id; $ret = Es::index($playlist_params); $next_videostoken = ''; do { $playlist_items = $youtube->getPlaylistItemsByPlaylistId($playlist_id, array('maxResults' => 50, 'pageToken' => $next_videostoken)); $next_videostoken = $youtube->page_info; if (!empty($playlist_items)) { foreach ($playlist_items as $video) { if ($video->status->privacyStatus == 'public') { $video_id = $video->id; $video_params['body'] = array('id' => $video_id, 'video_id' => $video->contentDetails->videoId, 'user_id' => $user_id, 'website_id' => $website_id, 'channel_id' => $channel_id, 'playlist_id' => $playlist_id, 'video_type' => 'youtube', 'position' => $video->snippet->position, 'title' => $video->snippet->title, 'description' => $video->snippet->description, 'thumbnails' => array('small' => $video->snippet->thumbnails->default->url, 'medium' => $video->snippet->thumbnails->medium->url, 'large' => $video->snippet->thumbnails->high->url), 'published_at' => $video->snippet->publishedAt); $video_params['index'] = 'video-websites'; $video_params['type'] = 'video'; $video_params['id'] = $video_id; $ret = Es::index($video_params); } } } } while (is_string($next_videostoken)); } } } } while (is_string($next_playlisttoken)); } else { if ($type == 'vimeo') { $playlists_response = $client->get("http://vimeo.com/api/v2/{$account_id}/channels.json"); $playlists = json_decode($playlists_response->getBody(), true); if (!empty($playlists)) { foreach ($playlists as $pl) { $playlist_id = $pl['id']; $playlist_params['body'] = array('id' => $playlist_id, 'user_id' => $user_id, 'website_id' => $website_id, 'channel_id' => $channel_id, 'title' => $pl['name'], 'playlist_type' => 'vimeo', 'description' => $pl['description'], 'thumbnail' => $pl['logo'], 'published_at' => $pl['created_on']); $playlist_params['index'] = 'video-websites'; $playlist_params['type'] = 'playlist'; $playlist_params['id'] = $playlist_id; $ret = Es::index($playlist_params); $video_page = 1; $video_index = 0; do { $videos_response = $client->get("http://vimeo.com/api/v2/{$playlist_id}/videos.json?page={$video_page}"); $videos = json_decode($videos_response->getBody(), true); if (!empty($videos)) { foreach ($videos as $video) { if ($video['embed_privacy'] == 'anywhere') { $video_id = $video['id']; $video_params['body'] = array('id' => $video_id, 'video_id' => $video_id, 'user_id' => $user_id, 'website_id' => $website_id, 'channel_id' => $channel_id, 'playlist_id' => $playlist_id, 'video_type' => 'vimeo', 'position' => $video_index, 'title' => $video['title'], 'description' => strip_tags($video['description']), 'thumbnails' => array('small' => $video['thumbnail_small'], 'medium' => $video['thumbnail_medium'], 'large' => $video['thumbnail_large']), 'published_at' => date('Y-m-d', strtotime($video['upload_date']))); $video_params['index'] = 'video-websites'; $video_params['type'] = 'video'; $video_params['id'] = $video_id; $ret = Es::index($video_params); } $video_index += 1; } } $video_page += 1; } while (!empty($videos) && $video_page <= 3); } } else { $video_page = 1; $video_index = 0; do { $allvideos_response = $client->get("http://vimeo.com/api/v2/{$account_id}/all_videos.json?page={$video_page}"); $videos = json_decode($allvideos_response->getBody(), true); if (!empty($videos)) { foreach ($videos as $video) { if ($video['embed_privacy'] == 'anywhere') { $video_id = $video['id']; $video_params['body'] = array('id' => $video_id, 'video_id' => $video_id, 'user_id' => $user_id, 'website_id' => $website_id, 'channel_id' => $channel_id, 'video_type' => 'vimeo', 'position' => $video_index, 'title' => $video['title'], 'description' => strip_tags($video['description']), 'thumbnails' => array('small' => $video['thumbnail_small'], 'medium' => $video['thumbnail_medium'], 'large' => $video['thumbnail_large']), 'published_at' => date('Y-m-d', strtotime($video['upload_date']))); $video_params['index'] = 'video-websites'; $video_params['type'] = 'video'; $video_params['id'] = $video_id; $ret = Es::index($video_params); } $video_index += 1; } } $video_page += 1; } while (!empty($videos) && $video_page <= 3); } } } return Redirect::to('/websites/new')->with('message', array('type' => 'success', 'text' => 'You have successfully created a website!')); } }
<?php include "../../model/Conecta.php"; include "../../model/beans/Youtube.php"; include "../../model/dao/DaoYoutube.php"; $youtube = new Youtube(); $youtube->setTitulo($_POST["titulo"]); $youtube->setUrl($_POST["url"]); $youtube->setDescricao($_POST["descricao"]); $conexao = new Conecta(); $daoYoutube = new DaoYoutube($youtube, $conexao); $daoYoutube->inserir(); //print_r($daoEvento->visualizarTudo()); header("Location: ../../youtube.php");
function create_shortcode() { $option = get_option('ta_videobook_setting'); //Default Googke Key $GoogleKey = 'AIzaSyBZqdpiCXFQqHI4h90fFfbkiaZSPquqhjM'; //Default Playlist $PlayListID = 'PLKbMO3RbT7Pd9XQWaFRBCR5wb_wcrSgL5'; if (isset($option['google_key']) && !is_null($option['google_key'])) { $GoogleKey = $option['google_key']; } if (isset($option['playlistID']) && !is_null($option['playlistID'])) { $PlayListID = $option['playlistID']; } $YouTube_v3 = new Youtube($GoogleKey); $Number_Video_Of_Page = 12; // 1 - Lay trang hi?n t?i $Current_Page = isset($_GET['vdPage']) ? $_GET['vdPage'] : 1; // 2 - Lay thong tin PlayList // Bao nhieu Video de Phan trang $playList = $YouTube_v3->getPlaylistById($PlayListID, ['contentDetails']); $Video_Items_Count = $playList->contentDetails->itemCount; if ($Video_Items_Count == 0) { echo 'No video in the playlist'; return; } $count_pages = ceil($Video_Items_Count / 12); //echo 'So luong video trong playlist la: ' . $Video_Items_Count; $KetQua = ""; echo '<div style="width: 700px;">'; //echo var_dump($playList); // 3 - Lay danh sach video t? playlist $playlistItems = []; $nextPageToken = ""; for ($index = 0; $index < $count_pages; $index++) { $pageNumber = $index + 1; if ($pageNumber == $Current_Page) { $playlistItems = $YouTube_v3->getPlaylistItemsByPlaylistId($PlayListID, $nextPageToken, $Number_Video_Of_Page, ['id', 'snippet']); break; } else { $nextPageToken = is_null($nextPageToken) ? true : $nextPageToken; $playlistItems = $YouTube_v3->getPlaylistItemsByPlaylistId($PlayListID, $nextPageToken, $Number_Video_Of_Page, ['id']); $nextPageToken = $playlistItems['info']['nextPageToken']; } } // 4 - Hien thi Video player $first_video = $playlistItems['results'][0]; $first_video_id = $first_video->snippet->resourceId->videoId; $first_Video_Player = $YouTube_v3->getVideoInfo($first_video_id, ['player']); echo '<div class="intelliam-normal-player" style="width: 100%">'; //echo '<div class="intelliam-big-title">' . $first_video->snippet->title . '</div>'; echo '<div class="intelliam-fluid-width-video-wrapper" id="video-container"><div class="fluid-width-video-wrapper" style="padding-top: 55%">' . $first_Video_Player->player->embedHtml . '</div></div>'; echo '</div>'; //Hien thi phan trang intelliam_util::displayPagination($count_pages, $Current_Page); // Lay Danh sach Id cua tat ca video $VideoId_List = intelliam_util::getVideoIdList($playlistItems['results']); // Lay Danh thong tin video tu danh sach $Video_List_ContentDetails_Statistics = $YouTube_v3->getVideoInfo($VideoId_List, ['contentDetails', 'statistics']); //Hien Thi danh sach video intelliam_util::displayVideoList($playlistItems['results'], $Video_List_ContentDetails_Statistics); //Hien thi phan trang intelliam_util::displayPagination($count_pages, $Current_Page); echo '</div>'; //return $KetQua; }
} else { $memberInfo = $member->get_info_filtered(); $consoleObj->select($_GET['cID']); include_once "../plugins/youtube/youtube.php"; if (!$member->hasAccess($consoleObj)) { exit; } $accessedByConsole = true; include "../plugins/youtube/ytbuttoncss.php"; } if (trim($_SERVER['HTTPS']) == "" || $_SERVER['HTTPS'] == "off") { $dispHTTP = "http://"; } else { $dispHTTP = "https://"; } $ytObj = new Youtube($mysqli); if (!$ytObj->hasYoutube($memberInfo['member_id'])) { $countErrors = 0; $dispError = ""; if ($accessedByConsole && !isset($_GET['error'])) { echo "\n\t\t\t\t<script type='text/javascript'>\n\t\t\t\t\twindow.location = '" . $MAIN_ROOT . "plugins/youtube/youtubeconnect.php';\n\t\t\t\t</script>\n\t\t\t"; exit; } if (isset($_GET['code']) && $_GET['state'] == $_SESSION['btYoutubeNonce'] && !isset($_GET['error'])) { $arrURLInfo = parse_url($dispHTTP . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']); $response = $ytObj->getAccessToken($_GET['code'], $arrURLInfo['scheme'] . "://" . $arrURLInfo['host'] . $arrURLInfo['path']); if (isset($response['access_token'])) { $ytObj->accessToken = $response['access_token']; $ytObj->refreshToken = $response['refresh_token']; $channelInfo = $ytObj->getChannelInfo(); $channelSnippet = $ytObj->getChannelInfo("snippet");
public static function editar($input) { $respuesta = array(); $reglas = array('titulo' => array('required', 'max:50', 'unique:item_lang,titulo,' . $input['id'])); if (isset($input['imagen_portada_crop'])) { $reglas['imagen_portada_crop'] = array('required'); } $validator = Validator::make($input, $reglas); if ($validator->fails()) { $messages = $validator->messages(); if ($messages->has('titulo')) { $respuesta['mensaje'] = 'El título de la obra contiene más de 50 caracteres o ya existe.'; } elseif ($messages->has('imagen_portada_crop')) { $respuesta['mensaje'] = 'Se olvidó de guardar la imagen recortada.'; } else { $respuesta['mensaje'] = 'Los datos necesarios para la obra son erróneos.'; } $respuesta['error'] = true; } else { $ok = false; if (isset($input['video']) && $input['video'] != "") { if (is_array($input['video'])) { foreach ($input['video'] as $key => $video) { if ($video != "") { $dataUrl = parse_url($video); if (in_array($dataUrl['host'], ['vimeo.com', 'www.vimeo.com'])) { $hosts = array('vimeo.com', 'www.vimeo.com'); if (Video::validarUrlVimeo($video, $hosts)['estado']) { $ok = true; } } else { $hosts = array('youtube.com', 'www.youtube.com'); $paths = array('/watch'); if (Video::validarUrl($video, $hosts, $paths)['estado']) { if ($ID_video = Youtube::parseVIdFromURL($video)) { $ok = true; } } } } else { $ok = true; break; } } } else { $dataUrl = parse_url($input['video']); if (in_array($dataUrl['host'], ['vimeo.com', 'www.vimeo.com'])) { $hosts = array('vimeo.com', 'www.vimeo.com'); if (Video::validarUrlVimeo($input['video'], $hosts)['estado']) { $ok = true; } } else { $hosts = array('youtube.com', 'www.youtube.com'); $paths = array('/watch'); if (Video::validarUrl($input['video'], $hosts, $paths)['estado']) { if ($ID_video = Youtube::parseVIdFromURL($input['video'])) { $ok = true; } } } } } else { $ok = true; } if ($ok) { $muestra = Muestra::find($input['muestra_id']); if (isset($input['cuerpo'])) { $cuerpo = $input['cuerpo']; } else { $cuerpo = NULL; } // $muestra->cuerpo = $cuerpo; // // $muestra->save(); $lang = Idioma::where('codigo', App::getLocale())->where('estado', 'A')->first(); $muestra_lang = Muestra::join('muestra_lang', 'muestra_lang.muestra_id', '=', 'muestra.id')->where('muestra_lang.lang_id', $lang->id)->where('muestra.id', $muestra->id)->first(); $datos = array('cuerpo' => $cuerpo); $muestra_modificacion = DB::table('muestra_lang')->where('id', $muestra_lang->id)->update($datos); if (isset($input['descripcion'])) { $input['descripcion'] = $input['descripcion']; } else { $input['descripcion'] = NULL; } $item = Item::editarItem($input); $respuesta['mensaje'] = 'Muestra modificada.'; $respuesta['error'] = false; $respuesta['data'] = $muestra; } else { $respuesta['error'] = true; $respuesta['mensaje'] = "Problema en la/s url de video cargada."; } } return $respuesta; }