From 48844f985b892e498341ed6fb97a9401506da37f 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: Thu, 24 Feb 2022 14:01:27 +0900 Subject: [PATCH] =?UTF-8?q?=E5=86=8D=E7=94=9F=E3=83=AA=E3=82=B9=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Watch/Playlist.php | 82 ++++++++ public/css/watch.css | 183 +++++++++++++++++- .../layout/component/w/playlist.blade.php | 32 +++ .../w/playlist/components/info.blade.php | 12 ++ .../w/playlist/components/miniature.blade.php | 35 ++++ .../w/playlist/watchplaylist.blade.php | 6 + resources/views/pages/peertube/w/p.blade.php | 14 ++ routes/web.php | 6 +- 8 files changed, 368 insertions(+), 2 deletions(-) create mode 100644 app/Http/Controllers/Watch/Playlist.php create mode 100644 resources/views/layout/component/w/playlist.blade.php create mode 100644 resources/views/layout/component/w/playlist/components/info.blade.php create mode 100644 resources/views/layout/component/w/playlist/components/miniature.blade.php create mode 100644 resources/views/layout/component/w/playlist/watchplaylist.blade.php create mode 100644 resources/views/pages/peertube/w/p.blade.php diff --git a/app/Http/Controllers/Watch/Playlist.php b/app/Http/Controllers/Watch/Playlist.php new file mode 100644 index 0000000..e610a51 --- /dev/null +++ b/app/Http/Controllers/Watch/Playlist.php @@ -0,0 +1,82 @@ +common = new Common; + } + + public function index ($id, Request $r) { + $res = [ + 'page' => 'playlist', + 'style' => 'watch', + 'id' => $id, + 'pos' => isset($r->playlistPosition) ? (int)$r->playlistPosition : 1, + 'resume' => isset($r->resume) ? (bool)$r->resume : true, + 'userinfo' => $this->common->user, + ]; + + $det = $this->getDetail($id); + $res['playlist'] = $det; + $res['plvid'] = $this->getVideos($det->uuid, 0, $det->videosLength); + + if ($res['pos'] < 1) $res['pos'] = 1; + if ($res['pos'] > $det->videosLength) $res['pos'] = $det->videosLength; + + $id = 0; + foreach ($res['plvid']->data as $k => $v) { + if ($v->position == $res['pos']) { + $id = $v->video->uuid; + $res['detail'] = $this->getVideo($id); + } + + $res['plvid']->data[$k]->video->nameShort = strlen($res['plvid']->data[$k]->video->name) > 45 ? substr($res['plvid']->data[$k]->video->name, 0, 45).'...' : $res['plvid']->data[$k]->video->name; + } + + $res = $this->getComment($id, $res); + + $tags = []; + if (!is_null($res['detail']->tags)) $tags = $res['detail']->tags; + else $tags = explode(' ', $res['detail']->title); + + $res['recommend'] = $this->getRecommend($tags); + return view('pages.peertube.w.p', ['res' => $res]); + } + + function getDetail ($id) { + return $this->ptapi('/api/v1/video-playlists/'.$id); + } + + function getVideos ($uuid, $start, $count) { + return $this->ptapi('/api/v1/video-playlists/'.$uuid.'/videos?start='.$start.'&count='.$count); + } + + function getVideo ($uuid) { + return $this->ptapi('/api/v1/videos/'.$uuid); + } + + function getRecommend ($tags) { + $tag = ''; + foreach ($tags as $t) { + $tag .= 'tagsOneOf='.urlencode($t).'&'; + } + return $this->ptapi('/api/v1/search/videos?start=0&count=6&nsfw=both&'.$tag.'sort=-publishedAt&searchTarget=local'); + } + + function getComment ($id, $res) { + $get = null; + + $res['comment'] = $this->ptapi('/api/v1/videos/'.$id.'/comment-threads'); + foreach ($res['comment']->data as $co) { + $co->src = 'PT'; + } + + return $res; + } +} diff --git a/public/css/watch.css b/public/css/watch.css index a728fb7..eda7ba6 100755 --- a/public/css/watch.css +++ b/public/css/watch.css @@ -9,4 +9,185 @@ .avatar-and-textarea my-actor-avatar { margin-inline-end: 10px; -} \ No newline at end of file +} + +.playlist { + min-width: 200px; + max-width: 470px; + height: 66vh; + background-color: var(--mainBackgroundColor); + overflow-y: auto; + border-bottom: 1px solid rgba(0,0,0,.1); +} + +.playlist .playlist-info { + padding: 5px 30px; + background-color: #31363b; +} + +.playlist .playlist-info .playlist-display-name { + font-size: 18px; + font-weight: 600; + margin-bottom: 5px; +} + +.playlist .playlist-info .playlist-by-index { + color: var(--greyForegroundColor); + display: flex; +} + +.playlist .playlist-info .playlist-by-index .playlist-by { + margin-inline-end: 5px; +} + +.playlist .playlist-info .playlist-controls { + display: flex; + margin: 10px 0; +} + +.playlist .playlist-info .playlist-controls my-global-icon:not(:last-child) { + margin-inline-end: .5rem; +} + +.playlist .playlist-info .playlist-controls my-global-icon:not(.active) { + opacity: .5; +} + +.playlist .playlist-info .playlist-controls my-global-icon { + cursor: pointer; +} + +.video { + border-bottom: 1px solid rgba(255,255,255,.1); + color: var(--mainForegroundColor); + display: flex; + min-width: 0; + align-items: center; + cursor: pointer; +} + +.video.active { + background-color: var(--mainColor); +} + +.video .position { + margin-inline-end: 10px; + font-weight: 600; + color: var(--greyForegroundColor); + min-width: 25px; +} + +.playlist my-video-playlist-element-miniature .video .position { + margin-inline-end: 0; +} + +my-video-thumbnail, .fake-thumbnail { + margin-inline-end: 10px; + display: flex; +} + +.playlist my-video-playlist-element-miniature my-video-thumbnail .video-thumbnail { + width: 90px; + height: 50px; +} + +my-video-thumbnail .video-thumbnail { + width: 130px; + height: 72px; +} + +.video-thumbnail-loli img { + width: 90px; + height: 50px; +} + +.video-thumbnail-label-overlay { + position: absolute; + padding: 0 5px; + left: 5px; + top: 5px; + font-weight: 700; +} + +.video-thumbnail-duration-overlay, .video-thumbnail-live-overlay { + position: absolute; + padding: 0 3px; + right: 5px; + bottom: 5px; +} + +.video-thumbnail-watch-later-overlay, .video-thumbnail-label-overlay, .video-thumbnail-duration-overlay, .video-thumbnail-live-overlay { + display: inline-block; + background-color: #000000b3; + color: #fff; + border-radius: 3px; + font-size: 12px; + font-weight: 600; + line-height: 1.1; + z-index: 10; +} + +.video-thumbnail .play-overlay .icon { + width: 0; + height: 0; + position: absolute; + left: 50%; + top: 50%; + transform: translate(-50%,-50%) scale(.5); + border-top: 13px solid transparent; + border-bottom: 13px solid transparent; + border-left: 18px solid rgba(255,255,255,.95); +} + +.video-thumbnail .play-overlay, .video-thumbnail .play-overlay .icon { + transition: all .2s ease; +} + +.video-thumbnail .play-overlay { + position: absolute; + right: 0; + bottom: 0; + width: inherit; + height: inherit; + opacity: 0; + background-color: #0000004d; +} + +.video .video-info { + display: flex; + flex-direction: column; + align-self: flex-start; + min-width: 0; +} + +.video .video-info .video-info-header { + display: flex; + align-self: baseline; +} + +.video .video-info .video-info-header a { + color: #fcfcfc; + width: auto; + padding-right: 5px; +} + +.playlist my-video-playlist-element-miniature .video .video-info .video-info-name { + font-size: 15px; +} + +.video .video-info-name { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + font-size: 18px; + font-weight: 600; + display: inline-block; +} + +.video .video-info .video-info-account, .video .video-info .video-info-timestamp { + color: var(--greyForegroundColor); +} + +my-global-icon { + width: inherit; +} diff --git a/resources/views/layout/component/w/playlist.blade.php b/resources/views/layout/component/w/playlist.blade.php new file mode 100644 index 0000000..cde2ab8 --- /dev/null +++ b/resources/views/layout/component/w/playlist.blade.php @@ -0,0 +1,32 @@ +
+
+
+ +
+
+ @include('layout.component.w.playlist.watchplaylist') +
diff --git a/resources/views/layout/component/w/playlist/components/info.blade.php b/resources/views/layout/component/w/playlist/components/info.blade.php new file mode 100644 index 0000000..0bf4577 --- /dev/null +++ b/resources/views/layout/component/w/playlist/components/info.blade.php @@ -0,0 +1,12 @@ +
+
+ {{ $res['playlist']->displayName }} + {{ ptPrivacy($res['playlist']->privacy->id) }} +
+
+
{{ $res['playlist']->videoChannel->displayName }}
+
+ {{ $res['pos'] }}/{{ $res['playlist']->videosLength }} +
+
+
diff --git a/resources/views/layout/component/w/playlist/components/miniature.blade.php b/resources/views/layout/component/w/playlist/components/miniature.blade.php new file mode 100644 index 0000000..81827f2 --- /dev/null +++ b/resources/views/layout/component/w/playlist/components/miniature.blade.php @@ -0,0 +1,35 @@ +@foreach ($res['plvid']->data as $p) +
+ +
+ {{ $p->position }} + + + +
{{ ptDuration($p->video->duration) }}
+
+
+
+ + + + {{ date('Y年m月d日', strtotime($p->video->originallyPublishedAt)) }} + + + • + + {{ $p->video->views }} 回再生 + + + + + +
+
+
+
+@endforeach diff --git a/resources/views/layout/component/w/playlist/watchplaylist.blade.php b/resources/views/layout/component/w/playlist/watchplaylist.blade.php new file mode 100644 index 0000000..637d4bb --- /dev/null +++ b/resources/views/layout/component/w/playlist/watchplaylist.blade.php @@ -0,0 +1,6 @@ + +
+ @include('layout.component.w.playlist.components.info') + @include('layout.component.w.playlist.components.miniature') +
+
diff --git a/resources/views/pages/peertube/w/p.blade.php b/resources/views/pages/peertube/w/p.blade.php new file mode 100644 index 0000000..8c173e9 --- /dev/null +++ b/resources/views/pages/peertube/w/p.blade.php @@ -0,0 +1,14 @@ +@extends('layout') + +@section('content') +
+
+ +
+ @include('layout.component.w.playlist') + @include('layout.component.w.info') +
+
+
+
+@endsection diff --git a/routes/web.php b/routes/web.php index 596564a..5e13d13 100644 --- a/routes/web.php +++ b/routes/web.php @@ -7,7 +7,11 @@ Route::get('/home', 'Home@index'); Route::get('/a/{id}/{cat?}/{page?}', 'Account@index'); Route::get('/c/{id}/{cat?}/{page?}', 'Channel@index'); -Route::get('/w/{id}', 'Watch@index'); + +Route::group(['prefix' => 'w'], function () { + Route::get('/{id}', 'Watch@index'); + Route::get('/p/{id}', 'Watch\Playlist@index'); +}); Route::get('/logout', 'Logout@logout'); Route::group(['prefix' => 'login'], function () {