<?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 Home extends Common {
  private $common;

  public function __construct () {
    $this->common = new Common;
  }

  public function index () {
    $res = [
      'page' => 'home',
      'style' => 'videoslist',
      'userinfo' => $this->common->user,
    ];

    $res['new']  = $this->getNewest();
    $res['hot']  = $this->getPopularest();
    return view('pages.peertube.home', ['res' => $res]);
  }

  function getNewest () {
    return $this->ptapi('/api/v1/videos?start=0&count=8&sort=-publishedAt&skipCount=true&isLocal=true&nsfw=both');
  }

  function getPopularest () {
    return $this->ptapi('/api/v1/videos?start=0&count=8&sort=-trending&skipCount=true&isLocal=true&nsfw=both');
  }
}
