2021-12-15 18:43:03 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Peertube;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use App\Http\Controllers\Peertube\Common;
|
|
|
|
// use Illuminate\Support\Facades\Log;
|
|
|
|
|
|
|
|
class Channel extends Common {
|
|
|
|
private $common;
|
|
|
|
private $count;
|
|
|
|
|
|
|
|
public function __construct () {
|
|
|
|
$this->common = new Common;
|
|
|
|
$this->count = 25;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function index ($id, $cat='videos', $page=0) {
|
2021-12-16 01:25:29 +09:00
|
|
|
$res = [
|
|
|
|
'page' => 'channel',
|
2021-12-16 16:31:55 +09:00
|
|
|
'style' => 'channel',
|
2021-12-16 01:25:29 +09:00
|
|
|
'cat' => $cat,
|
|
|
|
'paginate' => $page,
|
2021-12-16 13:02:06 +09:00
|
|
|
'pagetotal' => 500,
|
2021-12-16 01:25:29 +09:00
|
|
|
'userinfo' => $this->common->user,
|
|
|
|
];
|
2021-12-15 18:43:03 +09:00
|
|
|
$res['channel'] = $this->getChannel($id);
|
2021-12-16 16:16:20 +09:00
|
|
|
$res['video'] = $cat == 'video-playlists' ? $this->getPlaylist($id, ($page*$this->count), $this->count) : $this->getVideo($id, ($page*$this->count), $this->count);
|
2021-12-16 13:02:06 +09:00
|
|
|
$res['pagetotal'] = $res['video']->total;
|
2021-12-15 18:43:03 +09:00
|
|
|
return view('pages.peertube.c', ['res' => $res]);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getChannel ($id) {
|
|
|
|
return $this->ptapi_get('/api/v1/video-channels/'.$id);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getVideo ($id, $start, $count) {
|
|
|
|
return $this->ptapi_get('/api/v1/video-channels/'.$id.'/videos?start='.$start.'&count='.$count.'&sort=-publishedAt&skipCount=false&nsfw=both');
|
|
|
|
}
|
2021-12-16 16:16:20 +09:00
|
|
|
|
|
|
|
function getPlaylist ($id, $start, $count) {
|
|
|
|
return $this->ptapi_get('/api/v1/video-channels/'.$id.'/video-playlists?start='.$start.'&count='.$count);
|
|
|
|
}
|
2021-12-15 18:43:03 +09:00
|
|
|
}
|