/** * Store a newly created resource in storage. * * @return Response */ public function postCreate(VideoRequest $request) { $video = new Video(); $video->user_id = Auth::id(); $video->language_id = $request->language_id; $video->name = $request->name; $video->video_album_id = $request->video_album_id; $video->description = $request->description; $video->album_cover = $request->album_cover; if ($request->youtube != "") { $youtube = explode('?v=', $request->youtube); $video->youtube = rtrim($youtube[1]); } $video_file = ""; if ($request->hasFile('video')) { $file = $request->file('video'); $filename = $file->getClientOriginalName(); $extension = $file->getClientOriginalExtension(); $video_file = sha1($filename . time()) . '.' . $extension; $video->filename = $video_file; } $video->save(); if ($request->hasFile('video')) { $videoalbum = VideoAlbum::find($request->video_album_id); $destinationPath = public_path() . '/appfiles/videoalbum/' . $videoalbum->folder_id . '/'; $request->file('video')->move($destinationPath, $video_file); } }
public function newVideo($link) { $video = new Video(); $video->user = Auth::user()->name; $video->link = $link; $video->save(); }
public function import() { set_time_limit(0); DB::table('videos')->delete(); // //if (file_exists('video1.xml')) { $uri = 'http://a1.noterik.com:8081/smithers2/domain/espace/user/luce/video'; //dd($uri); $content = utf8_encode(file_get_contents($uri)); $xml = simplexml_load_string($content); //print_r($xml); foreach ($xml->video as $video) { //echo '--video_id='.$xml->video['id'].PHP_EOL; //echo '--genre='.$video->properties->genre.PHP_EOL; $video_item = new Video(); $video_item->video_id = $video['id']; $video_item->genre = $video->properties->genre; $video_item->topic = $video->properties->topic; $video_item->title = $video->properties->TitleSet_TitleSetInEnglish_title; $video_item->geographical_coverage = $video->properties->SpatioTemporalInformation_SpatialInformation_GeographicalCoverage; $video_item->summary = $video->properties->summaryInEnglish; $video_item->thesaurus_terms = $video->properties->ThesaurusTerm; $video_item->save(); } // return view('video.parser'); }
/** * Действие-обработчик запроса на сохранение видео. * * @param StoreVideosRequest $request * @return \Illuminate\Http\RedirectResponse * @throws \App\Services\Exception */ public function postCreate(StoreVideosRequest $request) { $video = new Video(); $video->youtube_id = trim($request->youtube_id); $video->company_id = Company::whereShortTitle($request->segment(3))->first()->id; $video->save(); return redirect()->action('Admin\\VideosController@getEdit', ['company' => $request->segment(3), 'id' => $video->id])->with('success', 'Видео успешно сохранено.'); }
/** * @param VideoFormRequest $request * @param Video $video * @return \Illuminate\Http\RedirectResponse */ public function store(Request $request, Video $video) { //retrieve the authenticated user if ($request->ajax()) { $user = Auth::user(); //create the resource $video->title = $request->get('title'); $video->url = $request->get('videoUrl'); $video->description = $request->get('description'); $video->category_id = $request->get('videoCategory'); $video->user_id = $user->id; $video->save(); return response(json_encode($request->all())); } return redirect()->action('HomeController@index'); }
public function store() { $input = Input::all(); $input = $input['video']; $validator = Validator::make($input, ['title' => 'required', 'description' => 'required', 'url' => 'required']); if ($validator->fails()) { return $this->respondNotFound($validator->errors()); } $video = new Video(); $video->title = $input['title']; $video->description = $input['description']; $video->url = $input['url']; // $video->image_url = $input['imageUrl']; $video->save(); return $this->setStatusCode(200)->respond(["video" => $this->videoTransformer->transform($video), "message" => "succesfully created the video"]); }
/** * Import videos to database and score them. * * @return Response */ public function import(Request $request) { set_time_limit(0); $uri = $request->uri; $content = utf8_encode(file_get_contents($uri)); $xml = simplexml_load_string($content); foreach ($xml->video as $video) { $video_item = new Video(); $video_item->video_id = $video['id']; $video_item->genre = $video->properties->genre; $video_item->topic = $video->properties->topic; $video_item->title = $video->properties->TitleSet_TitleSetInEnglish_title; $video_item->geographical_coverage = $video->properties->SpatioTemporalInformation_SpatialInformation_GeographicalCoverage; $video_item->summary = $video->properties->summaryInEnglish; $video_item->thesaurus_terms = $video->properties->ThesaurusTerm; $video_item->save(); } $terms = Term::all(); //take all Profile terms $videos = Video::all(); foreach ($videos as $video) { $id = $video->id; foreach ($terms as $term) { $results = DB::select(DB::raw('select MATCH (genre, topic, geographical_coverage, thesaurus_terms, title) AGAINST (? WITH QUERY EXPANSION) as rev from videos where id = (?)'), [$term->term, $id]); DB::table('videos_terms_scores')->insert(['video_id' => $id, 'term_id' => $term->id, 'video_score' => $results[0]->rev]); } } $query = DB::select(DB::raw('UPDATE videos_terms_scores as t join (select video_id,MAX(video_score) as maximum FROM videos_terms_scores GROUP BY video_id)as max_scores on t.video_id=max_scores.video_id SET t.video_score=t.video_score/max_scores.maximum')); $terms = Term::all(); //take all Profile terms $videos = Video::all(); foreach ($videos as $video) { $id = $video->id; foreach ($terms as $term) { $results = DB::select(DB::raw('select COUNT(*) as rev from videos where id=' . $id . ' and topic LIKE "%' . $term->term . '%"')); DB::table('videos_terms_scores')->where('video_id', $id)->where('term_id', $term->id)->update(['video_score' => DB::raw('video_score*0.5+' . $results[0]->rev * 0.5 . '')]); } } $response = ['message' => 'Successful import']; $statusCode = 200; return Response::json($response, $statusCode); }
/** * 得到页面上所有的视频地址,已经存过的视频地址不会被重新储存。 * @param int $page 第几页 * @return array 视频地址 */ protected function fetchVideosrcs($page) { // 准备DOM $html = $this->getHtml($page); $dom = new Dom(); $dom->load($html); $videoSrcs = []; // 遍历全部iframe foreach ($dom->find('iframe') as $videoFrame) { // 获得iframe的地址 $videoFrameSrc = $videoFrame->getAttribute('src'); // 如果iframe的地址不存在,或者不含有特定字符串(用来判别是否是视频),废弃 if (empty($videoFrameSrc)) { continue; } if (!strstr($videoFrameSrc, 'https://www.tumblr.com/video/')) { continue; } // 如果已经检测了此视频,返回 $parentId = $videoFrame->getParent()->getAttribute('id'); $name = explode('_', $parentId)[3] . '.mp4'; if (Video::where('name', '=', $name)->count() != 0) { continue; } // 准备video的DOM $videoHtml = $this->requestHtml($videoFrameSrc); $videoDom = new Dom(); $videoDom->load($videoHtml); // 获取对应节点 $videoElem = $videoDom->find('video')[0]; $videoSource = $videoElem->find('source')[0]; // 开始读取数据 $video = new Video(); $video->state = 'detected'; $video->error = ''; $video->name = $name; $video->source = $videoSource->getAttribute('src'); $video->save(); } }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request, $type) { if ($type == 'event') { $this->validate($request, ['title' => 'required|unique:events|max:50', 'content' => 'required|max:10000', 'start_date' => 'date|before:tomorrow', 'end_date' => 'date|after:start_date', 'start_time' => 'date_format:h:i|before:end_time', 'end_time' => 'date_format:h:i|after:start_time', 'number' => 'max:12', 'street' => 'max:40', 'suburb' => 'max:40', 'area' => 'max:40', 'country' => 'max:30', 'image[]' => ['required' => 'One image is requred', 'image' => 'Make sure the image is a .jpg, .png or .gif']]); $event = new Event(); $location = new Location(); $event->title = $request->title; $event->content = $request->content; $event->start_date = str_replace('-', '/', $request->start_date); $event->end_date = str_replace('-', '/', $request->end_date); $event->start_time = $request->start_time; $event->end_time = $request->end_time; $event->type = $request->type; $event->status = $request->status; $event->slug = strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', $event->title))); $event->save(); $location->number = $request->number; $location->street = $request->street; $location->suburb = $request->suburb; $location->area = $request->area; $location->country = $request->country; $location->location_map = $request->number . '+' . $request->street . ',+' . $request->suburb . ',+' . $request->area . ',+' . $request->country; $location->location_map = str_replace(' ', '+', $location->location_map); $location->event_id = $event->id; $location->save(); $original = 'img/site/original/'; $sliderPath = 'img/site/slider/'; $galleryThumbPath = 'img/site/gallery/thumbnail/'; $galleryPrevPath = 'img/site/gallery/preview/'; $thumbnail = 'img/site/thumbnail/'; if ($request->hasFile('image')) { $counter = 0; foreach ($request->file('image') as $image) { $fileName = uniqid() . '.' . $request->file('image')[$counter]->getClientOriginalName(); $imageSource = \Image::make($request->file('image')[$counter]); $imageSource->save($original . $fileName); \Image::make($request->file('image')[$counter])->resize(1000, null, function ($constraint) { $constraint->aspectRatio(); })->save($galleryPrevPath . $fileName, 80); \Image::make($request->file('image')[$counter])->resize(1000, null, function ($constraint) { $constraint->aspectRatio(); })->crop(1000, 400, 0, 0)->save($sliderPath . $fileName, 80); \Image::make($request->file('image')[$counter])->fit(100, 100)->save($galleryThumbPath . $fileName, 80); \Image::make($request->file('image')[$counter])->fit(250, 150)->save($thumbnail . $fileName, 80); $imagedb = new Image(); $eventImage = new EventImage(); $imagedb->image = $fileName; $imagedb->save(); $eventImage->image_id = $imagedb->id; $eventImage->event_id = $event->id; $eventImage->save(); $counter++; } } if (count($request->currentImage) > 0) { foreach ($request->currentImage as $checked) { $imagedb = Image::where('id', $checked)->first(); \File::delete([$sliderPath . $imagedb->image, $galleryPrevPath . $imagedb->image, $galleryThumbPath . $imagedb->image, $thumbnail . $imagedb->image, $original . $imagedb->image]); EventImage::where('event_id', $event->id)->where('image_id', $checked)->delete(); $imagedb->delete(); } } } elseif ($type == 'video') { $event = new Video(); $event->title = $request->title; $event->description = $request->description; $event->player = $request->player; if ($request->player == 'youtube') { $event->video = substr($request->video, -11); } elseif ($request->player == 'vimeo') { $event->video = substr($request->video, -9); } $event->slug = strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', $event->title))); $event->save(); return redirect('/admin/' . $type . '/' . $event->slug . '/edit'); } else { return view('errors.404'); } if (isset($request->preview)) { return redirect('/event/' . $event->slug); } else { \Session::flash('created', 'The ' . $event->title . ' event has been created.'); return redirect('/admin/event/' . $event->slug . '/edit'); } }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { //print_r($request->input); //Input Validation $this->validate($request, $this->rules, $this->messages); $this->validate($request, $this->file_rules, $this->messages); $topicVal = $request->input('topic'); if (!$request->input('othertopic') == NULL) { $topicVal = $request->input('othertopic'); // $courseVal = $request->input('sub').$request->input('num'); // $oldPriority = Topic::where('course',$courseVal)->max('priority'); // $priority = $oldPriority+1; // $id = Topic::insertGetId(['course' => $courseVal, 'priority' => $priority , 'topic' => $topicVal]); } $class = $request->input('sub') . '' . $request->input('num'); $instructorname = $request->input('instructorlast') . " " . $request->input('instructorfirst'); $instructor = strtolower($request->input('instructorlast') . "" . substr($request->input('instructorfirst'), 0, 1) . "" . substr($request->input('instructorfirst'), -1)); $vid_slug = preg_replace('/\\s+/', '', $request->input('title')) . '-' . $instructor . '-' . $class; $vid_name = strtolower(preg_replace('/\\s+/', '', $request->input('title')) . '.' . $request->file('video')->getClientOriginalExtension()); $video_req = array('slug' => $vid_slug, 'topic' => $topicVal, 'class' => $class, 'instructor' => $instructorname, 'vid_url' => $class . '/' . $instructor . '/' . $vid_name, 'title' => $request->input('title'), 'isVerified' => FALSE, 'created_at' => date("Y-m-d"), 'created_by' => $request->input('user'), 'tags' => $request->input('tags'), 'semester' => $request->input('semester'), 'year' => $request->input('year'), 'description' => $request->input('description'), 'unit' => $request->input('unit')); $newvid = new Video($video_req); $newvid->save(); print_r($newvid); print_r($newvid->class); $request->file('video')->move(base_path() . '/resources/uploaded_videos/' . $class . '/' . $instructor . '/', $vid_name); return Redirect::route('videos.index')->with('message', 'Video Uploaded'); }