076動画のコメント

このコミットが含まれているのは:
テクニカル諏訪子 2021-06-28 16:03:50 +09:00
コミット 4c8b9d404c
2個のファイルの変更78行の追加2行の削除

ファイルの表示

@ -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('<br />'));
$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('<br />'));
$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;
}
}

ファイルの表示

@ -44,7 +44,7 @@
<span v-else>
<ul class="commentlist" v-for="(c, i) in comment.come" :key="`comment-${i}`">
<li class="comment even thread-even depth-1" :id="`li-comment-${c.id}`">
<div class="commentnumber">{{ Number(i)+1 }}{{ (c.isvideo == 'n' ? '(YT)' : '(TS)') }}</div>
<div class="commentnumber">{{ Number(i)+1 }}({{ c.src }})</div>
<div :id="`comment-${c.id}`" :ref="`comment-${c.id}`">
<div>
<cite class="fn">
@ -66,7 +66,7 @@
<span v-if="c.replies">
<ul class="commentlist" v-for="(r, j) in c.replies" :key="`comment-${i}-reply-${j}`">
<li class="comment even thread-even depth-2" :id="`li-comment-${r.id}`">
<div class="commentnumber">{{ i+1 }}/{{ j+1 }}{{ (c.isvideo == 'n' ? '(YT)' : '(TS)') }}</div>
<div class="commentnumber">{{ i+1 }}/{{ j+1 }}({{ c.src }})</div>
<div :id="`comment-${r.id}`">
<div>
<cite class="fn">