diff --git a/app/Http/Controllers/Peertube/Account.php b/app/Http/Controllers/Peertube/Account.php index aa53ac5..58af309 100644 --- a/app/Http/Controllers/Peertube/Account.php +++ b/app/Http/Controllers/Peertube/Account.php @@ -8,39 +8,59 @@ use App\Http\Controllers\Peertube\Common; class Account extends Common { private $common; + private $count; public function __construct () { $this->common = new Common; + $this->count = 25; } - public function index ($id, $cat='video-channels') { + public function index ($id, $cat='video-channels', $page=0) { $res = [ 'page' => 'account', 'style' => 'account', 'cat' => $cat, + 'paginate' => $page, + 'pagetotal' => 500, 'userinfo' => $this->common->user, ]; + $res['owner'] = $this->getOwner($id); if (!empty($res['owner'])) $res['owner']->totalVideo = 0; - $res['channel'] = $this->getChannel($id); + $res['channel'] = $this->getChannel($id, $cat, ($page*$this->count), $this->count); if (!empty($res['owner'])) { - foreach ($res['channel']->data as $k => $v) { - $res['channel']->data[$k]->video = $this->getVideo($v->name.'@'.$v->host); - $res['owner']->totalVideo += $res['channel']->data[$k]->video->total; + if ($cat == 'video-channels') { + $stats = $this->ptapi('/api/v1/accounts/'.$id.'/videos?start=0&count=0&skipCount=false&nsfw=both'); + $res['owner']->totalVideo = $stats->total; + foreach ($res['channel']->data as $k => $v) { + $res['channel']->data[$k]->video = $this->getVideo($v->name.'@'.$v->host); + $res['owner']->followersCount += $v->followersCount; + } + } + else { + $stats = $this->ptapi('/api/v1/accounts/'.$id.'/video-channels?start=0&count=20'); + $res['owner']->totalVideo = $res['channel']->total; + foreach ($stats->data as $k => $v) { + $res['channel']->data[$k]->video = $this->getVideo($v->name.'@'.$v->host); + $res['owner']->followersCount += $v->followersCount; + } } } - return view('pages.peertube.a', ['res' => $res]); + + return view('pages.peertube.a', ['res' => $res, 'cat' => $cat]); } function getOwner ($id) { return $this->ptapi('/api/v1/accounts/'.$id); } - function getChannel ($id) { - return $this->ptapi('/api/v1/accounts/'.$id.'/video-channels?start=0&count=20&sort=-updatedAt&withStats=false'); + function getChannel ($id, $cat, $start, $count) { + if ($cat == 'video-channels') $count = 5; + $sort = $cat == 'video-channels' ? '-updatedAt&withStats=false' : '-publishedAt&skipCount=false&nsfw=both'; + return $this->ptapi('/api/v1/accounts/'.$id.'/'.$cat.'?start='.$start.'&count='.$count.'&sort='.$sort); } function getVideo ($id) { - return $this->ptapi('/api/v1/video-channels/'.$id.'/videos?start=0&count=5&sort=-publishedAt&nsfw=both'); + return $this->ptapi('/api/v1/video-channels/'.$id.'/videos?start=0&count=5&sort=-publishedAt&skipCount=false&nsfw=both'); } } diff --git a/resources/views/layout/component/a/links.blade.php b/resources/views/layout/component/a/links.blade.php index 6299017..7f6b0f3 100644 --- a/resources/views/layout/component/a/links.blade.php +++ b/resources/views/layout/component/a/links.blade.php @@ -2,10 +2,10 @@
- チャンネル + チャンネル - 動画 + 動画
diff --git a/resources/views/layout/component/a/videos.blade.php b/resources/views/layout/component/a/videos.blade.php new file mode 100644 index 0000000..da5878b --- /dev/null +++ b/resources/views/layout/component/a/videos.blade.php @@ -0,0 +1,10 @@ +
+
+ @foreach ($res['channel']->data as $v) + @include('layout.component.common.videominature') + @endforeach +
+ @include('layout.component.common.paginate', [ + 'root' => '/a/'.$res['owner']->name.($res['owner']->host != 'video.076.ne.jp' ? '@'.$res['owner']->host : '').'/'.$res['cat'] + ]) +
diff --git a/resources/views/pages/peertube/a.blade.php b/resources/views/pages/peertube/a.blade.php index 195abe7..6a8d49f 100644 --- a/resources/views/pages/peertube/a.blade.php +++ b/resources/views/pages/peertube/a.blade.php @@ -6,7 +6,11 @@
@include('layout.component.a.info') @include('layout.component.a.links') - @include('layout.component.a.channels') + @if ($cat == 'videos') + @include('layout.component.a.videos') + @else + @include('layout.component.a.channels') + @endif
diff --git a/routes/web.php b/routes/web.php index 3edfbaa..fe7ecd7 100644 --- a/routes/web.php +++ b/routes/web.php @@ -5,7 +5,7 @@ use Illuminate\Support\Facades\Route; Route::any('/', 'Peertube\Home@index'); Route::any('/home', 'Peertube\Home@index'); -Route::any('/a/{id}/{cat?}', 'Peertube\Account@index'); +Route::any('/a/{id}/{cat?}/{page?}', 'Peertube\Account@index'); Route::any('/c/{id}/{cat?}/{page?}', 'Peertube\Channel@index'); Route::any('/w/{id}', 'Peertube\Watch@index');