43 行
1.2 KiB
PHP
43 行
1.2 KiB
PHP
<?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 Account extends Common {
|
|
private $common;
|
|
|
|
public function __construct () {
|
|
$this->common = new Common;
|
|
}
|
|
|
|
public function index ($id) {
|
|
$res = [];
|
|
$res['page'] = 'account';
|
|
$res['owner'] = $this->getOwner($id);
|
|
if (!empty($res['owner'])) $res['owner']->totalVideo = 0;
|
|
$res['channel'] = $this->getChannel($id);
|
|
if (!empty($res['owner'])) {
|
|
foreach ($res['channel']->data as $k => $v) {
|
|
$res['channel']->data[$k]->video = $this->getVideo($v->name);
|
|
$res['owner']->totalVideo += $res['channel']->data[$k]->video->total;
|
|
}
|
|
}
|
|
return view('pages.peertube.a', ['res' => $res]);
|
|
}
|
|
|
|
function getOwner ($id) {
|
|
return $this->ptapi_get('/api/v1/accounts/'.$id);
|
|
}
|
|
|
|
function getChannel ($id) {
|
|
return $this->ptapi_get('/api/v1/accounts/'.$id.'/video-channels?start=0&count=20&sort=-updatedAt&withStats=false');
|
|
}
|
|
|
|
public function getVideo ($id) {
|
|
return $this->ptapi_get('/api/v1/video-channels/'.$id.'/videos?start=0&count=5&sort=-publishedAt&nsfw=both');
|
|
}
|
|
}
|