From 4aec6d22f536be0e21aed7a5e4cbf9464a3e59f0 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: Mon, 28 Jun 2021 15:13:35 +0900 Subject: [PATCH 1/4] =?UTF-8?q?=E3=81=94=E3=82=81=E3=82=93=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../theme/techsuwa/component/{footer.php => footer.blade.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename resources/views/theme/techsuwa/component/{footer.php => footer.blade.php} (100%) diff --git a/resources/views/theme/techsuwa/component/footer.php b/resources/views/theme/techsuwa/component/footer.blade.php similarity index 100% rename from resources/views/theme/techsuwa/component/footer.php rename to resources/views/theme/techsuwa/component/footer.blade.php From 4c8b9d404ca980830a5f75b903dab87c7d2a8cbd 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: Mon, 28 Jun 2021 16:03:50 +0900 Subject: [PATCH 2/4] =?UTF-8?q?076=E5=8B=95=E7=94=BB=E3=81=AE=E3=82=B3?= =?UTF-8?q?=E3=83=A1=E3=83=B3=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Video/Prayer.php | 76 +++++++++++++++++++++++++++ resources/js/components/comments.vue | 4 +- 2 files changed, 78 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Video/Prayer.php b/app/Http/Controllers/Video/Prayer.php index 4e2aac5..25374c6 100644 --- a/app/Http/Controllers/Video/Prayer.php +++ b/app/Http/Controllers/Video/Prayer.php @@ -42,14 +42,22 @@ class Prayer { } } + $res->kvcomment = array(); + $kvslug = explode('/', $res->kerotube); + if (isset($kvslug[5])) { + $res->kvcomment = $this->getKeroCome($kvslug[5], ''); + } + if ($res->ytcomment) $res->ytcomment = $this->backupYTComment($slugger, $res->ytcomment); $res->nicocomment = array(); $res->bccomment = array(); $res->lbcomment = array(); + if ($res->kvcomment) $res->kvcomment = $this->backupKeroComment($slugger, $res->kvcomment); foreach ($comments as $k => $c) { $c->replyCount = 0; $c->isvideo = 't'; + $c->src = 'TS'; if (!is_null($c->user_id) && !empty(userDetail($c->user_id))) { $det = userDetail($c->user_id); @@ -74,13 +82,63 @@ class Prayer { $res->comments['total'] = count($comments); $res->comments['come'] = $comments; $res->comments['total'] += (isset($res->ytcomment['total']) ? $res->ytcomment['total'] : 0); + $res->comments['total'] += (isset($res->kvcomment['total']) ? $res->kvcomment['total'] : 0); if (isset($res->ytcomment['come'])) $res->comments['come'] = array_merge($res->comments['come'], $res->ytcomment['come']); + if (isset($res->kvcomment['come'])) $res->comments['come'] = array_merge($res->comments['come'], $res->kvcomment['come']); DB::table('vid_video')->where('vid', $vid)->update(['view' => $res->view+1]); return view('pages.site.video.prayer', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user]); } + function getKeroCome ($slug, $tslug) { + $come = []; + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, env('KERO_URI').'/api/v1/videos/'.$slug.'/comment-threads'); + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + + $get = curl_exec($ch); + $err = curl_error($ch); + curl_close($ch); + + if (!$get) return $err; + $get = json_decode($get); + + $come = array(); + $come['come'] = array(); + + if (isset($get->error) || !$get) { + if ($tslug != '') { + if (!$get = DB::table('vid_kerocomment')->where('vid', $tslug)->first()) return array(); + $come = unserialize($get->come); + return $come; + } + } + + if (isset($get->data)) { + foreach ($get->data as $g) { + $g->comments = new \stdClass(); + $g->comments->id = $g->id; + $g->comments->name = $g->account->displayName; + $g->comments->channel = $g->account->url; + $g->comments->icon = env('KERO_URI').$g->account->avatar->path; + $g->comments->message = strip_tags($g->text, array('
')); + $g->comments->createdTS = strtotime($g->createdAt); + $g->comments->created = date('Y年m月d日 H:i:s', strtotime($g->createdAt)); + $g->comments->replyCount = (isset($g->totalReplies) ? $g->totalReplies : 0); + $g->comments->isvideo = 'n'; + $g->comments->src = '076'; + + $come['come'][] = $g->comments; + } + } + + $come['total'] = $get->totalNotDeletedComments; + + return $come; + } + function checkYouTubeCome ($res, $slug, $next='') { $come = $this->getYouTubeCome($slug, '', $next); foreach ($come['come'] as $com) { $res['come'][] = $com; } @@ -124,6 +182,7 @@ class Prayer { $g->comment->message = strip_tags($g->snippet->topLevelComment->snippet->textDisplay, array('
')); $g->comment->replyCount = (isset($g->snippet->totalReplyCount) ? $g->snippet->totalReplyCount : 0); $g->comment->isvideo = 'n'; + $g->comment->src = 'YT'; if (isset($g->replies)) { $g->comment->replies = array(); @@ -176,4 +235,21 @@ class Prayer { return $com; } + + function backupKeroComment ($slug, $com) { + foreach ($com['come'] as $c) { + $icon = strstr($c->icon, 'avatars/'); + $icon = str_replace('avatars/', '', $icon); + if ($icon != '.jpg') { + $isicon = array_diff(scandir(dirname(__DIR__, 4).'/storage/app/public/kero_icon'), array('..', '.')); + if (!in_array($icon, $isicon)) passthru('wget -O '.dirname(__DIR__, 4).'/storage/app/public/kero_icon/'.$icon.' '.$c->icon); + $c->icon = '/storage/kero_icon/'.$icon; + } + } + + if ($chk = DB::table('vid_kerocomment')->where('vid', $slug)->first()) DB::table('vid_kerocomment')->where('vid', $slug)->update(['come' => serialize($com)]); + else DB::table('vid_kerocomment')->insert(['vid' => $slug, 'come' => serialize($com)]); + + return $com; + } } \ No newline at end of file diff --git a/resources/js/components/comments.vue b/resources/js/components/comments.vue index 05d6985..4a6fd77 100644 --- a/resources/js/components/comments.vue +++ b/resources/js/components/comments.vue @@ -44,7 +44,7 @@