Example #1
0
 /**
  * Create screenshot from uploaded video
  * @param  \App\Models\Video $video The object we created
  * @return boolean	Always true
  */
 private function capture(\App\Models\Video $video)
 {
     //that's easier
     $video_path = public_path('/videos/' . $video->video);
     //find duration
     $ffprobe = \FFMpeg\FFProbe::create();
     $duration = $ffprobe->format($video_path)->get('duration');
     //take the shot
     $ffmpeg = \FFMpeg\FFMpeg::create();
     $capture = $ffmpeg->open($video_path);
     $capture->frame(\FFMpeg\Coordinate\TimeCode::fromSeconds($duration > 5 ? 5 : (int) ($duration / 2)))->save(public_path('/previews/' . $video->getKey() . '.jpg'));
     return true;
 }
Example #2
0
 public function show($id)
 {
     $vid = Video::findOrFail($id);
     $path = env('FILE_UPLOAD_PATH') . '/' . $vid->id . '~' . $vid->upload_filename;
     $file = File::get($path);
     return (new Response($file, 200))->header('Content-Type', File::mimeType($path));
 }
Example #3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $videos = glob(public_path() . '/b/*');
     usort($videos, function ($a, $b) {
         $a = (int) basename($a, '.webm');
         $b = (int) basename($b, '.webm');
         if ($a == $b) {
             return 0;
         }
         return $a < $b ? -1 : 1;
     });
     $category = \App\Models\Category::where('shortname', '=', 'misc')->first();
     $user = \App\Models\User::find(1);
     foreach ($videos as $video) {
         if (\App\Models\Video::whereFile(basename($video))->count() > 0) {
             continue;
         }
         $v = new \App\Models\Video();
         $v->user()->associate($user);
         $v->category()->associate($category);
         $v->hash = sha1_file($video);
         $v->file = basename($video);
         $v->save();
     }
 }
 public function videoPass(Swf2VidEvent $event)
 {
     /** @var Video $video */
     if ($data = $event->getEventData()) {
         if ($video = @Video::find($data['video']['video_id'])) {
             if ($user = $event->getUser()) {
                 if (Video::count(['conditions' => ['project_id = ? and vid_status = "pass" and updated_at > DATE_SUB(NOW(), INTERVAL 10 MINUTE)', $video->project_id]])) {
                     //redo
                     return;
                 }
                 $minLevel = Swf2Vid::getInstance()->getUserVideoLevel();
                 $levels = $user->user_level;
                 /** @var UserLevel $level */
                 foreach ($levels as $level) {
                     if ($level->credits > 0) {
                         if (AccessLevels::getInstance()->checkAccess($level->level, $minLevel)) {
                             $level->credits = $level->credits - 1;
                             $level->save_direct();
                             return;
                         }
                     }
                 }
             }
             $video->vid_status = 'fail';
             $video->save_direct();
         }
         App::getInstance()->dispatch(Swf2VidEvent::VIDEO_NO_CREDITS, $event);
     }
 }
Example #5
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $idMidia = Midia::where('id_registro_tabela', $id)->where('id_tipo_midia', $this->tipo_midia)->first()->id_midia;
     $dados['imagens'] = Midia::find($idMidia)->multimidia()->where('id_midia', $idMidia)->get();
     $dados['dados'] = Video::findOrFail($id);
     return view('video', $dados);
 }
Example #6
0
 public function index()
 {
     $videoCount = Video::count();
     $memberCount = $this->userRepo->countMembers();
     $eventCount = Event::count();
     return view('admin.index', ['noOfVideos' => $videoCount, 'noOfMembers' => $memberCount, 'noOfEvents' => $eventCount]);
 }
Example #7
0
 /**
  * Encode video
  *
  * @fixme проверить не осталось ли еще активных процессов на конвертацию от прошлой cron задачи, если осталось, то менять $threads для тещушего cron.
  * @return int
  * @throws \Exception
  * @throws \yii\web\UnsupportedMediaTypeHttpException
  */
 public function actionEncode()
 {
     /** @var Video $video */
     // get params
     $params = Yii::$app->params;
     $outputFormat = $params['video.encode.outputFormat'];
     $threads = $params['video.encode.threads'];
     $timeout = $params['video.encode.timeout'];
     $savePath = $params['path.video.converted'];
     // ffmpeg init
     $ffmpegConfig = ['ffmpeg.threads' => $threads, 'timeout' => $timeout];
     // video processing
     $error = null;
     $videos = Video::getUnconvertedVideo($threads);
     foreach ($videos as $video) {
         $video->converted_filename = FileHelper::generateFileName($outputFormat, $savePath);
         $filePaths = $video->getPaths();
         // video encode
         if (FfmpegHelper::convert($filePaths['upload'], $filePaths['converted'], $outputFormat, $ffmpegConfig)) {
             $meta = FfmpegHelper::getProperties($filePaths['converted']);
             $video->converted_video_bitrate = $meta['video_bitrate'];
             $video->converted_audio_bitrate = $meta['audio_bitrate'];
             $video->status = Video::STATUS_ENCODE_SUCCESS;
         } else {
             $video->status = Video::STATUS_ENCODE_ERROR;
             $error = true;
         }
         $video->save(false);
     }
     return $error === null ? Controller::EXIT_CODE_NORMAL : Controller::EXIT_CODE_ERROR;
 }
Example #8
0
 public static function generate()
 {
     // Там еще в сайтмепе есть приоритетность. Для главной ставим самую высокую, для всех категорий чуть ниже и последняя приоритетность для постов
     //Создает XML-строку и XML-документ при помощи DOM
     $dom = new DomDocument('1.0');
     //добавление корня - <books>
     $urlset = $dom->appendChild($dom->createElement('urlset'));
     $urlset->setAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
     // Главная страница
     $url = $urlset->appendChild($dom->createElement('url'));
     $loc = $url->appendChild($dom->createElement('loc'));
     $loc->appendChild($dom->createTextNode("http://" . $_SERVER['SERVER_NAME']));
     $priority = $url->appendChild($dom->createElement('priority'));
     $priority->appendChild($dom->createTextNode('1.0'));
     // Категории фото
     $categoryPhoto = CategoryPhoto::find()->all();
     foreach ($categoryPhoto as $category) {
         $url = $urlset->appendChild($dom->createElement('url'));
         $loc = $url->appendChild($dom->createElement('loc'));
         $loc->appendChild($dom->createTextNode("http://" . $_SERVER['SERVER_NAME'] . "/category/photo/" . $category->url));
         $priority = $url->appendChild($dom->createElement('priority'));
         $priority->appendChild($dom->createTextNode('0.7'));
     }
     // Категории видео
     $categoryVideo = Category::find()->all();
     foreach ($categoryVideo as $category) {
         $url = $urlset->appendChild($dom->createElement('url'));
         $loc = $url->appendChild($dom->createElement('loc'));
         $loc->appendChild($dom->createTextNode("http://" . $_SERVER['SERVER_NAME'] . "/category/video/" . $category->url));
         $priority = $url->appendChild($dom->createElement('priority'));
         $priority->appendChild($dom->createTextNode('0.7'));
     }
     // Страницы фото
     $photoCatalog = PhotoCatalog::find()->where('publish = 1')->all();
     foreach ($photoCatalog as $photo) {
         $url = $urlset->appendChild($dom->createElement('url'));
         $loc = $url->appendChild($dom->createElement('loc'));
         $loc->appendChild($dom->createTextNode("http://" . $_SERVER['SERVER_NAME'] . "/photo/" . $photo->category->url . "/" . $photo->url));
         $priority = $url->appendChild($dom->createElement('priority'));
         $priority->appendChild($dom->createTextNode('0.5'));
     }
     // Страницы видео
     $videos = Video::find()->where('publish = 1')->all();
     foreach ($videos as $video) {
         $url = $urlset->appendChild($dom->createElement('url'));
         $loc = $url->appendChild($dom->createElement('loc'));
         $loc->appendChild($dom->createTextNode("http://" . $_SERVER['SERVER_NAME'] . "/video/" . $video->category->url . "/" . $video->url));
         $priority = $url->appendChild($dom->createElement('priority'));
         $priority->appendChild($dom->createTextNode('0.5'));
     }
     //генерация xml
     $dom->formatOutput = true;
     // установка атрибута formatOutput
     // domDocument в значение true
     // save XML as string or file
     //$test1 = $dom->saveXML(); // передача строки в test1
     $dom->save('../web/sitemap.xml');
     // сохранение файла
 }
 public function GetSingleVideo($id)
 {
     $v = Video::GetSingleVideo($id);
     $video = $v[0];
     $data["video"] = $video;
     $data["randomVideos"] = Video::GetRandomVideos(3);
     return view("single_video", ["data" => $data]);
 }
Example #10
0
 /**
  * @param bool $category
  * @return Video
  */
 public function getPrev($category = false)
 {
     if (!$category) {
         return Video::where('id', '<', $this->id)->orderBy('id', 'DESC')->first();
     } else {
         return Video::whereCategoryId($this->category->id)->where('id', '<', $this->id)->orderBy('id', 'DESC')->first();
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('videos')->truncate();
     $videos = ['21E3SLSV-Ys', 'iQoWiRJZ29M', '7ap-XeeHOkM', 'qdnVzjbh9PQ', 'm3ld6g9XycY', 'EKdjrcfh4Hk', 'RFgGh1rvwBE', 'YjrMB_GZCUQ', 'GFYJ-XoiwoQ', 'gSIuplM93Vg', '8WL57ZbZFJw', 'HeGAQAt72iw', '_gY640fF3cE', 'd4B9z_WJAKs', '8QlW8_PdYbw', 'Ar0x-jC7gl4', 'eH6qFJoySf8', 'euoiYTR284Y', 'yLerTXg1jXI', 'S1cufMC4se0', 'aoSRxe_iHmg', 'We8pAyeobGY', 'd59I52u2A8E', 'HA1sOLxvQow'];
     $faker = Faker\Factory::create();
     foreach ($videos as $video) {
         Video::create(['youtube_id' => $video, 'title' => $faker->unique()->sentence(5), 'slug' => $faker->slug(), 'description' => $faker->text(100), 'category_id' => $faker->randomElement([1, 2, 3])]);
     }
 }
Example #12
0
 public function init()
 {
     parent::init();
     if ($this->latestVideos === null) {
         $User = OvcUser::getCurrentUser();
         $courseIds = OvcCourse::getUserCourseIds($User->id);
         $this->latestVideos = \app\models\Video::find()->where(['course_id' => $courseIds])->orderBy('id DESC')->limit(16)->all();
     }
 }
Example #13
0
 public function actionView($category = null, $url = null)
 {
     $video = Video::find()->where("url = :url && publish = 0", [":url" => $url])->one();
     if ($video == null) {
         throw new HttpException(404);
     }
     // счетчик показов
     $video->updateCounters(['hits' => 1]);
     return $this->render('/video/view', ['video' => $video]);
 }
Example #14
0
 public function run()
 {
     $model = null;
     if ($this->type == 'video') {
         $model = Video::find()->where('id <> :id && publish = 1', [':id' => $this->currentId])->orderBy('RAND()')->limit(3)->all();
     } else {
         $model = PhotoCatalog::find()->where('id <> :id && publish = 1', [':id' => $this->currentId])->orderBy('RAND()')->limit(4)->all();
     }
     return $this->render($this->type == 'video' ? 'randomize_video' : 'randomize_photo', ['model' => $model]);
 }
Example #15
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //
     $faker = Faker\Factory::create();
     $teachers = Teacher::lists('id')->toarray();
     $series = Series::lists('id')->toarray();
     foreach (range(1, 50) as $index) {
         Video::create(['title' => $faker->title, 'description' => $faker->sentence(10), 'video_url' => $faker->url, 'cover_url' => $faker->url, 'user_id' => $faker->randomElement($teachers), 'series_id' => $faker->randomElement($series), 'watch_count' => $faker->randomDigit(), 'reply_count' => $faker->randomDigit(), 'favorite_count' => $faker->randomDigit()]);
     }
 }
Example #16
0
 public function run()
 {
     if ($this->type == 'video') {
         $model = Video::find()->orderBy('hits DESC')->limit(5)->all();
     }
     if ($this->type == 'photo') {
         $model = PhotoCatalog::find()->orderBy('hits DESC')->limit(5)->all();
     }
     return $this->render('teaser', ['model' => $model, 'type' => $this->type]);
 }
Example #17
0
 public function beforeDelete()
 {
     //echo "test"; die();
     //Video::deleteAll('category_id = :category_id', [':category_id'=>$this->id]);
     $videos = Video::find()->where('category_id = :category_id', [':category_id' => $this->id])->all();
     foreach ($videos as $v) {
         $v->delete();
     }
     return parent::beforeDelete();
     // TODO: Change the autogenerated stub
 }
Example #18
0
 public function actionIndex()
 {
     $query = Video::find()->where("publish = 1");
     // делаем копию выборки
     $countQuery = clone $query;
     // подключаем класс Pagination, выводим по 10 пунктов на страницу
     $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => 24]);
     // приводим параметры в ссылке к ЧПУ
     $pages->pageSizeParam = false;
     $videos = $query->offset($pages->offset)->orderBy('id DESC')->limit($pages->limit)->all();
     return $this->render('index', ['videos' => $videos, 'pages' => $pages]);
 }
Example #19
0
 public function getTarget()
 {
     $target_type = $this->target_type;
     switch ($target_type) {
         case 'user':
             return User::find($this->target_id);
         case 'comment':
             return Comment::find($this->target_id);
         case 'video':
             return Video::find($this->target_id);
         default:
             return null;
     }
 }
Example #20
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Video::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'created' => $this->created]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'url', $this->url])->andFilterWhere(['like', 'video', $this->video])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'content', $this->content]);
     return $dataProvider;
 }
 /**
  *
  * @return type
  */
 public function store(Request $request)
 {
     $this->validate($request, ['youtube_id' => 'required|unique:videos|max:20']);
     $videoId = Input::get('youtube_id');
     // Process Video
     // Connect to youtube
     $youtubeKey = array("key" => "AIzaSyAmsWXPu2gP78el5mSftCeLLRCdvWfOHWU");
     $youtube = new Youtube($youtubeKey);
     // Get video Info
     $videoInfo = $youtube->getVideoInfo($videoId);
     // dd($videoInfo->snippet);
     $user = Video::create(['youtube_id' => $videoId]);
     $data = ['video' => $videoInfo->snippet];
     return Redirect::route('video.list', $data);
 }
Example #22
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Video::find();
     $query->joinWith(['editor']);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->sort->attributes['editor'] = ['asc' => ['bnm_users.name' => SORT_ASC]];
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['ID' => $this->ID, 'user' => $this->user, 'date' => $this->date, 'type' => $this->type]);
     $query->andFilterWhere(['like', 'bnm_media.name', $this->name])->andFilterWhere(['like', 'desp', $this->desp])->andFilterWhere(['like', 'author', $this->author])->andFilterWhere(['like', 'url', $this->url])->andFilterWhere(['like', 'bnm_users.name', $this->editor])->andFilterWhere(['like', 'thumbnail', $this->thumbnail]);
     return $dataProvider;
 }
 public function show($id)
 {
     if ($id) {
         if ($id == "photos") {
             $datas = Photo::get();
         } elseif ($id == "videos") {
             $datas = Video::get();
         } elseif ($id == "documents") {
             $datas = Document::get();
         } elseif ($id == "audios") {
             $datas = Audio::get();
         } elseif ($id == "uploadedfiles") {
             $datas = UploadedFile::get();
         }
         return view("Modvel::admin." . $this->theme . ".files.show")->with('datas', $datas)->with('headName', $this->headName);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //
     $videos = Video::all()->all();
     $users = User::all()->all();
     $faker = Faker\Factory::create();
     foreach ($videos as $video) {
         $loops = rand(1, 20);
         for ($i = 0; $i < $loops; $i++) {
             try {
                 $user = $faker->randomElement($users);
                 $user->favorites()->attach($video);
             } catch (PDOException $e) {
                 #pass
             }
         }
     }
 }
Example #25
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $paramss
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $userCourseIds = \app\components\OvcCourse::getUserCourseIds();
     $commentCount = "(SELECT COUNT(*) AS nos FROM comment AS c WHERE c.video_id = video.id)";
     $query = Video::find()->select("video.*, course.name, {$commentCount} as commentCount")->innerJoin('course', '`video`.`course_id` = `course`.`id`')->where(['video.course_id' => $userCourseIds]);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => Yii::$app->params['pageSize']]]);
     /**
      * additional columns to be sorted
      */
     $dataProvider->sort->attributes['courseName'] = ['asc' => ['course.name' => SORT_ASC], 'desc' => ['course.name' => SORT_DESC]];
     $dataProvider->sort->attributes['commentCount'] = ['asc' => ['commentCount' => SORT_ASC], 'desc' => ['commentCount' => SORT_DESC]];
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['video.id' => $this->id, 'video.course_id' => $this->course_id, 'video.user_id' => $this->user_id, 'video.created_at' => $this->created_at, 'video.modified_at' => $this->modified_at, $commentCount => $this->commentCount]);
     $query->andFilterWhere(['like', 'video.title', $this->title])->andFilterWhere(['like', 'video.description', $this->description])->andFilterWhere(['like', 'video.path', $this->path])->andFilterWhere(['like', 'course.name', $this->courseName]);
     return $dataProvider;
 }
Example #26
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     // Videos
     echo 'UPDATING VIDEOS', PHP_EOL, '===============', PHP_EOL;
     $count = 0;
     Video::withTrashed()->with('category')->chunk(200, function ($videos) use($count) {
         foreach ($videos as $v) {
             echo 'Updating Video with ID: ', $v->id, PHP_EOL;
             $v->detag();
             // quick and dirty. not 100% correct though.
             if ($v->category->shortname === 'pr0n') {
                 $v->tag('nsfw');
             } else {
                 $v->tag('sfw');
             }
             $v->tag(array_filter([$v->category->shortname, $v->category->name, $v->interpret, $v->songtitle, $v->imgsource], function ($elem) {
                 return !empty(trim($elem));
             }));
             $count++;
         }
     });
     echo PHP_EOL, PHP_EOL, 'Updated ', $count, ' Videos.', PHP_EOL, PHP_EOL, PHP_EOL;
     // User filters
     echo 'UPDATING USERS', PHP_EOL, '==============', PHP_EOL;
     $count = 0;
     $categories = Category::withTrashed()->get()->keyBy('id');
     User::withTrashed()->chunk(200, function ($users) use(&$count, $categories) {
         foreach ($users as $u) {
             echo 'Updating User: '******'Updated ', $count, ' Users.', PHP_EOL, PHP_EOL, PHP_EOL;
 }
 /**
  * Display the specified resource.
  *
  * @param  string  $shortname
  * @param int $id
  * @return \Response
  */
 public function showVideo($shortname, $id = null)
 {
     $category = Category::whereShortname($shortname)->first();
     if (is_null($category)) {
         return redirect()->back()->with('error', 'Category not found');
     }
     if (is_null($id)) {
         $id = Video::whereCategoryId($category->id)->count() - 1;
         if ($id < 0) {
             return redirect()->back()->with('error', 'Category is empty.');
         }
         $id = rand(0, $id);
         $video = Video::whereCategoryId($category->id)->skip($id)->first();
         return redirect($shortname . '/' . $video->id);
     } else {
         $video = Video::whereCategoryId($category->id)->find($id);
     }
     if (is_null($video)) {
         return redirect()->back()->with('error', 'Category is empty.');
     }
     return view('video', ['video' => $video, 'category' => true]);
 }
 public function view($aid, Request $request)
 {
     try {
         $back = RequestUtil::getUrl(BiliBiliHelper::$SERVICE_URL . "/view/{$aid}");
         if ($back['code'] != 200) {
             throw new Exception('视频未找到...');
         }
         $content = $back['content'];
         $count = Video::where('aid', '=', $aid)->count();
         if ($count == 0) {
             $video = ['aid' => intval($aid), 'title' => $content['title'], 'author' => $content['author'], 'description' => $content['description'], 'created' => $content['created'], 'created_at' => $content['created_at'], 'face' => $content['face'], 'typename' => $content['typename'], 'pages' => $content['pages'], 'list' => serialize($content['list'])];
             try {
                 Video::create($video);
             } catch (Exception $ignore) {
             }
         }
         $content['aid'] = $aid;
         return view('play')->with('video', $content);
     } catch (\Exception $e) {
         return $this->returnError($e->getMessage());
     }
 }
Example #29
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request, $id)
 {
     $user = auth()->check() ? auth()->user() : null;
     $xhr = $request->ajax();
     if (is_null($user)) {
         return $xhr ? "Not logged in" : redirect()->back()->with('error', 'Not logged in');
     }
     if (!$request->has('comment')) {
         return $xhr ? "You need to enter a comment" : redirect()->back()->with('error', 'You need to enter a comment');
     }
     if (mb_strlen(trim($request->get('comment'))) > 1000) {
         return $xhr ? "Comment to long" : redirect()->back()->with('error', 'Comment to long');
     }
     $video = Video::findOrFail($id);
     $com = new Comment();
     $com->content = trim($request->get('comment'));
     $com->user()->associate($user);
     $com->video()->associate($video);
     $com->save();
     $sent = [];
     foreach ($com->getMentioned() as $mentioned) {
         Message::send($user->id, $mentioned->id, $user->username . ' mentioned you in a comment', view('messages.commentmention', ['video' => $video, 'user' => $user, 'comment' => $com]));
         $sent[] = $mentioned;
     }
     foreach ($com->answered() as $answered) {
         if (array_search($answered, $sent) !== false) {
             continue;
         }
         Message::send($user->id, $answered->id, $user->username . ' answered on your comment', view('messages.commentanswer', ['video' => $video, 'user' => $user, 'comment' => $com]));
         $sent[] = $answered;
     }
     if ($user->id != $video->user->id) {
         if (array_search($video->user, $sent) === false) {
             Message::send($user->id, $video->user->id, $user->username . ' commented on your video', view('messages.videocomment', ['video' => $video, 'user' => $user, 'comment' => $com]));
         }
     }
     return $xhr ? view('partials.comment', ['comment' => $com, 'mod' => $user->can('delete_comment')]) : redirect()->back()->with('success', 'Comment successfully saved');
 }
Example #30
0
 public function actionIndex($type, $url)
 {
     if ($type != 'photo' && $type != 'video') {
         throw new HttpException(404);
     }
     if ($type == 'video') {
         $category = Category::find()->where('url = :url', [':url' => $url])->one();
     }
     if ($type == 'photo') {
         $category = CategoryPhoto::find()->where('url = :url', [':url' => $url])->one();
     }
     if ($category == null) {
         throw new HttpException(404);
     }
     if ($type == 'video') {
         $videos = Video::find()->where('category_id = :category_id && publish = :publish', [':category_id' => $category->id, ':publish' => 1])->orderBy('id DESC')->all();
         return $this->render('video', ['videos' => $videos, 'category' => $category]);
     }
     if ($type == 'photo') {
         $photo = PhotoCatalog::find()->where('category_id = :category_id && publish = :publish', [':category_id' => $category->id, ':publish' => 1])->orderBy('id DESC')->all();
         return $this->render('photo', ['photos' => $photo, 'category' => $category]);
     }
 }