41 行
1.0 KiB
PHP
41 行
1.0 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 Watch extends Common {
|
|
private $common;
|
|
|
|
public function __construct () {
|
|
$this->common = new Common;
|
|
}
|
|
|
|
public function index ($id) {
|
|
$res = [];
|
|
$res['page'] = 'watch';
|
|
$res['detail'] = $this->getDetail($id);
|
|
$res['comment'] = $this->getComment($id);
|
|
$res['recommend'] = $this->getRecommend($res['detail']->tags);
|
|
return view('pages.peertube.w', ['res' => $res]);
|
|
}
|
|
|
|
function getDetail ($id) {
|
|
return $this->ptapi_get('/api/v1/videos/'.$id);
|
|
}
|
|
|
|
public function getRecommend ($tags) {
|
|
$tag = '';
|
|
foreach ($tags as $t) {
|
|
$tag .= 'tagsOneOf='.urlencode($t).'&';
|
|
}
|
|
return $this->ptapi_get('/api/v1/search/videos?start=0&count=6&nsfw=both&'.$tag.'sort=-publishedAt&searchTarget=local');
|
|
}
|
|
|
|
public function getComment ($id) {
|
|
return $this->ptapi_get('/api/v1/videos/'.$id.'/comment-threads');
|
|
}
|
|
}
|