From a89599a6861bc501ec23544e7eed6176037fc2c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=86=E3=82=AF=E3=83=8B=E3=82=AB=E3=83=AB=E8=AB=8F?= =?UTF-8?q?=E8=A8=AA=E5=AD=90?= Date: Wed, 22 Dec 2021 21:14:19 +0900 Subject: [PATCH] =?UTF-8?q?=E5=A4=96=E9=83=A8=E3=82=B3=E3=83=A1=E3=83=B3?= =?UTF-8?q?=E3=83=88=EF=BC=88=E3=83=86=E3=82=AF=E8=AB=8F=E8=A8=AA=E9=99=90?= =?UTF-8?q?=E5=AE=9A=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Peertube/Common.php | 1 + app/Http/Controllers/Peertube/Watch.php | 103 +++++++++++++++++- app/helpers.php | 47 +++++++- .../peertube/w/info/comments.blade.php | 39 +++++-- .../component/peertube/w/player.blade.php | 2 +- 5 files changed, 179 insertions(+), 13 deletions(-) diff --git a/app/Http/Controllers/Peertube/Common.php b/app/Http/Controllers/Peertube/Common.php index 82f54b6..deb38b0 100644 --- a/app/Http/Controllers/Peertube/Common.php +++ b/app/Http/Controllers/Peertube/Common.php @@ -52,6 +52,7 @@ class Common extends Engine { } public function ptapi ($url, $param='', $method='get', $contenttype='json') { + set_time_limit(0); $this->access_token = isset($_COOKIE['access_token']) ? $_COOKIE['access_token'] : null; $this->refresh_token = isset($_COOKIE['refresh_token']) ? $_COOKIE['refresh_token'] : null; $header = ['Content-Type: application/'.$contenttype, 'Host: '.str_replace('https://', '', env('PEER_URI'))]; diff --git a/app/Http/Controllers/Peertube/Watch.php b/app/Http/Controllers/Peertube/Watch.php index 00df08f..116a087 100644 --- a/app/Http/Controllers/Peertube/Watch.php +++ b/app/Http/Controllers/Peertube/Watch.php @@ -20,7 +20,7 @@ class Watch extends Common { 'userinfo' => $this->common->user, ]; $res['detail'] = $this->getDetail($id); - $res['comment'] = $this->getComment($id); + $res = $this->getComment($id, $res); $tags = []; if (!is_null($res['detail']->tags)) $tags = $res['detail']->tags; @@ -42,7 +42,104 @@ class Watch extends Common { return $this->ptapi('/api/v1/search/videos?start=0&count=6&nsfw=both&'.$tag.'sort=-publishedAt&searchTarget=local'); } - function getComment ($id) { - return $this->ptapi('/api/v1/videos/'.$id.'/comment-threads'); + function getComment ($id, $res) { + $get = null; + + // PeerTube + $res['comment'] = $this->ptapi('/api/v1/videos/'.$id.'/comment-threads'); + foreach ($res['comment']->data as $co) { + $co->src = 'PT'; + } + + // テク諏訪 + if ( + null !== ($get = DB::table('vid_video')->where('kerotube', env('PEER_URI').'/w/'.$res['detail']->uuid)->first()) || + null !== ($get = DB::table('vid_video')->where('kerotube', env('PEER_URI').'/w/'.$res['detail']->shortUUID)->first()) + ) { + if (null !== ($ts = DB::table('blg_comments')->where('video_id', $get->vid)->orderBy('created', 'desc')->get()->toArray())) { + foreach ($ts as $t) { + if (!is_null($t->user_id)) { + if (null !== ($user = DB::table('users')->where('id', $t->user_id)->first())) { + $t->user_id = new \stdClass(); + $t->user_id->id = $user->id; + $t->user_id->name = $user->username; + if (null !== ($user = DB::table('usr_profile')->where('user_id', $t->user_id->id)->first())) { + $t->user_id->avatar = $user->avatar; + $t->user_id->displayName = $user->display_name; + $t->user_id->gender = $user->gender; + $t->user_id->nameStyle = $user->name_style; + } + } + } + + $obj = new \stdClass(); + $acc = new \stdClass(); + $ava = !is_null($t->user_id) && !is_null($t->user_id->avatar) ? new \stdClass() : null; + if (!is_null($ava)) $ava->path = env('APP_URL').'/'.(!is_null($t->user_id) && !is_null($t->user_id->avatar) ? $t->user_id->avatar : 'img/noicon.jpg'); + + $acc->url = !is_null($t->user_id) ? '/profile/'.$t->user_id->id : ''; + $acc->name = !is_null($t->user_id) ? $t->user_id->name : (!is_null($t->name) ? $t->name : '名無しのテクニシャン'); + $acc->host = 'technicalsuwako.jp'; + $acc->displayName = !is_null($t->user_id) ? $t->user_id->displayName : '名無しのテクニシャン'; + $acc->gender = !is_null($t->user_id) ? $t->user_id->gender : null; + $acc->user_id = $t->user_id; + $acc->avatar = $ava; + $acc->nameStyle = !is_null($t->user_id) ? $t->user_id->nameStyle : null; + + $obj->id = $t->id; + $obj->threadId = $t->id; + $obj->isDeleted = false; + $obj->src = 'TS'; + $obj->text = $t->message; + $obj->createdAt = date('Y-m-d H:i:s', $t->created); + $obj->updatedAt = date('Y-m-d H:i:s', $t->created); + $obj->account = $acc; + + $res['comment']->data[] = $obj; + $res['comment']->total++; + $res['comment']->totalNotDeletedComments++; + } + } + } + + if (!is_null($get)) { + // YouTube + if (null !== ($yt = DB::table('vid_ytcomment')->where('vid', $get->vid)->first())) { + $yt = unserialize($yt->come); + foreach ($yt['come'] as $t) { + $obj = new \stdClass(); + $acc = new \stdClass(); + $ava = !is_null($t->icon) ? new \stdClass() : null; + if (!is_null($ava)) $ava->path = env('APP_URL').(!is_null($t->icon) ? $t->icon : 'img/noicon.jpg'); + + $acc->url = str_replace('www.youtube.com', 'youtube.076.ne.jp', $t->channel); + $acc->name = $t->name; + $acc->host = 'youtube.076.ne.jp'; + $acc->avatar = $ava; + $acc->displayName = $t->name; + + $obj->id = $t->id; + $obj->threadId = $t->id; + $obj->isDeleted = false; + $obj->src = 'YT'; + $obj->text = $t->message; + $obj->createdAt = date('Y-m-d H:i:s', $t->createdTS); + $obj->updatedAt = date('Y-m-d H:i:s', $t->createdTS); + $obj->account = $acc; + + $res['comment']->data[] = $obj; + $res['comment']->total++; + $res['comment']->totalNotDeletedComments++; + } + } + + // Odysee + // $odysee = $get->odysee; + + // 作成日順番 + usort($res['comment']->data, function ($a, $b) { return strtotime($b->createdAt) - strtotime($a->createdAt); }); + } + + return $res; } } diff --git a/app/helpers.php b/app/helpers.php index 3d6f4e1..0370839 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -41,12 +41,57 @@ function checkLegit ($t) { return $check->id; } +function ptComeSrc ($v) { + $res = new \stdClass(); + $res->bg = '#'; + $res->fg = '#fcfcfc'; + $res->tx = '不明'; + + switch ($v) { + case 'PT': + $res->bg .= 'ffad5c'; + $res->tx = 'PeerTube'; + break; + case 'TS': + $res->bg .= 'cb81ea'; + $res->tx = 'テク諏訪'; + break; + case 'YT': + $res->bg .= 'f50057'; + $res->tx = 'YouTube'; + break; + case 'OD': + $res->bg .= '33b58f'; + $res->tx = 'LBRY'; + break; + default: + $res->bg = 'transparent'; + break; + } + + return $res; +} + function ptFullHandle ($v) { return $v->name.($v->host != str_replace('https://', '', env('PEER_URI')) ? '@'.$v->host : ''); } function ptAvatar ($v) { - return isset($v->avatar) && !is_null($v->avatar) ? env('PEER_URI').$v->avatar->path : '/img/noicon.jpg'; + $placeholder = '/img/noicon.jpg'; + $res = ''; + + if (isset($v->avatar)) { + if (is_null($v->avatar)) return $placeholder; + $ava = $v->avatar->path; + $ava = str_replace(env('APP_URL'), '', $ava); + $res = str_starts_with(env('APP_URL'), $ava) ? env('PEER_URI') : ''; + if ($ava == '/') return '/img/noicon.jpg'; + else if (str_starts_with($ava, '/lazy-static')) $res = env('PEER_URI'); + + return $res.$ava; + } + + return '/img/noicon.jpg'; } function userDetail ($id, $kero=null) { diff --git a/resources/views/theme/techsuwa/component/peertube/w/info/comments.blade.php b/resources/views/theme/techsuwa/component/peertube/w/info/comments.blade.php index 187df9f..10d1298 100644 --- a/resources/views/theme/techsuwa/component/peertube/w/info/comments.blade.php +++ b/resources/views/theme/techsuwa/component/peertube/w/info/comments.blade.php @@ -52,13 +52,34 @@
diff --git a/resources/views/theme/techsuwa/component/peertube/w/player.blade.php b/resources/views/theme/techsuwa/component/peertube/w/player.blade.php index f2c5d7e..4b57285 100644 --- a/resources/views/theme/techsuwa/component/peertube/w/player.blade.php +++ b/resources/views/theme/techsuwa/component/peertube/w/player.blade.php @@ -12,7 +12,7 @@ playsinline="playsinline" tabindex="-1" poster="https://video.076.ne.jp{{ $res['detail']->previewPath }}" - style="width: 813px; height: 458px;" + style="width: 100%; max-height: 720px;" controls="" > @if (!empty($res['detail']->streamingPlaylists))