common = new Common; $this->res = [ 'page' => 'search', 'style' => 'search', 'userinfo' => $this->common->user, 'version' => $this->common->version, ]; } public function index (Request $r) { $this->updateFilter($r->all()); $filter = $this->formatFilter(); $this->res['searchterm'] = $this->filter['search']; $this->res['res'] = []; $this->res['res']['video-channels'] = $this->get('video-channels', 0, 2, $filter); $this->res['res']['video-playlists'] = $this->get('video-playlists', 0, 2, $filter); $this->res['res']['videos'] = $this->get('videos', 0, 2, $filter); $this->res['totalres'] = 0; foreach ($this->res['res'] as $v) $this->res['totalres'] += $v->total; return view('pages.peertube.search', ['res' => $this->res]); } public function updateFilter ($v) { $this->filter['search'] = isset($v['search']) ? $v['search'] : ''; $this->filter['searchTarget'] = 'local'; $this->filter['sort'] = isset($v['sort']) ? '-'.$v['sort'] : '-match'; // 並び替え、match | publishedAt | views $this->filter['isLive'] = isset($v['isLive']) ? $v['isLive'] : null; // 表示、null | true | false $this->filter['nsfw'] = isset($v['nsfw']) ? $v['nsfw'] : null; // センシティブなコンテンツを表示、both | false $this->filter['startDate'] = isset($v['startDate']) ? $v['startDate'] : null; // 投稿日、null | フォーマット=「yyyy-mm-ddT15:00:000Z」 $this->filter['originallyPublishedStartDate'] = isset($v['originallyPublishedStartDate']) ? $v['originallyPublishedStartDate'] : null; // 動画が投稿された年→から、フォーマット=「yyyy-12-31T15:00:000.Z」 $this->filter['originallyPublishedEndDate'] = isset($v['originallyPublishedEndDate']) ? $v['originallyPublishedEndDate'] : null; // 動画が投稿された年→まで、フォーマット=「yyyy-12-31T15:00:000.Z」 $this->filter['durationMin'] = isset($v['durationMin']) ? $v['durationMin'] : null; // 再生時間、中間の場合=240、長いの場合=600 $this->filter['durationMax'] = isset($v['durationMax']) ? $v['durationMax'] : null; // 再生時間、短いの場合=240、中間の場合=600 $this->filter['categoryOneOf'] = isset($v['categoryOneOf']) ? $v['categoryOneOf'] : null; // カテゴリ、カテゴリのINT $this->filter['licenseOneOf'] = isset($v['licenseOneOf']) ? $v['licenseOneOf'] : null; // ライセンス、ライセンスのINT $this->filter['languageOneOf'] = isset($v['languageOneOf']) ? $v['languageOneOf'] : null; // 言語、2文字言語コード $this->filter['tagsOneOf'] = isset($v['tagsOneOf']) ? $v['tagsOneOf'] : null; // これらのタグ全て、単語(複数場合:&tagsOneOf=sa1&tagsOneOf=sa2) $this->filter['tagsAllOf'] = isset($v['tagsAllOf']) ? $v['tagsAllOf'] : null; // これらのタグのうち1つ、単語(複数場合:&tagsAllOf=sa1&tagsAllOf=sa2) $this->filter['host'] = isset($v['host']) ? $v['host'] : null; // インスタンス、ドメイン名 } function formatFilter () { $filter = ''; foreach ($this->filter as $k => $v) { if (!is_null($v)) $filter .= '&'.$k.'='.$v; } return $filter; } function get ($type, $start, $count, $filter) { return $this->ptapi('/api/v1/search/'.$type.'?start='.$start.'&count='.$count.$filter); } }