mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 04:01:24 +00:00
02ad342bac
[ci skip] [skip ci]
148 lines
5.5 KiB
PHP
148 lines
5.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\UserSerie;
|
|
use App\Models\Video;
|
|
use Blacklight\Releases;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Arr;
|
|
|
|
class SeriesController extends BasePageController
|
|
{
|
|
/**
|
|
* @param string $id
|
|
* @param \Illuminate\Http\Request $request
|
|
*
|
|
* @throws \Exception
|
|
*/
|
|
public function index($id = '', Request $request)
|
|
{
|
|
$this->setPrefs();
|
|
$releases = new Releases();
|
|
$title = 'Series';
|
|
$meta_title = 'View TV Series';
|
|
$meta_keywords = 'view,series,tv,show,description,details';
|
|
$meta_description = 'View TV Series';
|
|
|
|
if ($id && ctype_digit($id)) {
|
|
$category = -1;
|
|
if ($request->has('t') && ctype_digit($request->input('t'))) {
|
|
$category = $request->input('t');
|
|
}
|
|
|
|
$catarray = [];
|
|
$catarray[] = $category;
|
|
|
|
$page = $request->has('page') && is_numeric($request->input('page')) ? $request->input('page') : 1;
|
|
$offset = ($page - 1) * config('nntmux.items_per_page');
|
|
|
|
$rel = $releases->tvSearch(['id' => $id], '', '', '', $offset, 1000, '', $catarray, -1);
|
|
|
|
$show = Video::getByVideoID($id);
|
|
|
|
if (! $show) {
|
|
$this->smarty->assign('nodata', 'No video information for this series.');
|
|
} elseif (! $rel) {
|
|
$this->smarty->assign('nodata', 'No releases for this series.');
|
|
} else {
|
|
$myshows = UserSerie::getShow($this->userdata->id, $show['id']);
|
|
|
|
// Sort releases by season, episode, date posted.
|
|
$series = $episode = $posted = [];
|
|
foreach ($rel as $rlk => $rlv) {
|
|
$series[$rlk] = $rlv->series;
|
|
$episode[$rlk] = $rlv->episode;
|
|
$posted[$rlk] = $rlv->postdate;
|
|
}
|
|
array_multisort($series, SORT_DESC, $episode, SORT_DESC, $posted, SORT_DESC, $rel->toArray());
|
|
|
|
$series = [];
|
|
foreach ($rel as $r) {
|
|
$series[$r->series][$r->episode][] = $r;
|
|
}
|
|
|
|
$this->smarty->assign('seasons', Arr::sortRecursive($series));
|
|
$this->smarty->assign('show', $show);
|
|
$this->smarty->assign('myshows', $myshows);
|
|
|
|
//get series name(s), description, country and genre
|
|
$seriestitles = $seriessummary = $seriescountry = [];
|
|
$seriestitles[] = $show['title'];
|
|
|
|
if (! empty($show['summary'])) {
|
|
$seriessummary[] = $show['summary'];
|
|
}
|
|
|
|
if (! empty($show['countries_id'])) {
|
|
$seriescountry[] = $show['countries_id'];
|
|
}
|
|
|
|
$seriestitles = implode('/', array_map('trim', $seriestitles));
|
|
$this->smarty->assign('seriestitles', $seriestitles);
|
|
$this->smarty->assign('seriessummary', $seriessummary ? array_shift($seriessummary) : '');
|
|
$this->smarty->assign('seriescountry', $seriescountry ? array_shift($seriescountry) : '');
|
|
|
|
$title = 'Series';
|
|
$meta_title = 'View TV Series';
|
|
$meta_keywords = 'view,series,tv,show,description,details';
|
|
$meta_description = 'View TV Series';
|
|
|
|
if ($category !== -1) {
|
|
$catid = $category;
|
|
} else {
|
|
$catid = '';
|
|
}
|
|
$this->smarty->assign('category', $catid);
|
|
$this->smarty->assign('nodata', '');
|
|
}
|
|
$content = $this->smarty->fetch('viewseries.tpl');
|
|
$this->smarty->assign([
|
|
'title' => $title,
|
|
'content' => $content,
|
|
'meta_title' => $meta_title,
|
|
'meta_keywords' => $meta_keywords,
|
|
'meta_description' => $meta_description,
|
|
]);
|
|
$this->pagerender();
|
|
} else {
|
|
$letter = ($id && preg_match('/^(0\-9|[A-Z])$/i', $id)) ? $id : '0-9';
|
|
|
|
$showname = ($request->has('title') && ! empty($request->input('title'))) ? $request->input('title') : '';
|
|
|
|
if ($showname !== '' && ! $id) {
|
|
$letter = '';
|
|
}
|
|
|
|
$masterserieslist = Video::getSeriesList($this->userdata->id, $letter, $showname);
|
|
|
|
$title = 'Series List';
|
|
$meta_title = 'View Series List';
|
|
$meta_keywords = 'view,series,tv,show,description,details';
|
|
$meta_description = 'View Series List';
|
|
|
|
$serieslist = [];
|
|
foreach ($masterserieslist as $s) {
|
|
if (preg_match('/^[0-9]/', $s['title'])) {
|
|
$thisrange = '0-9';
|
|
} else {
|
|
preg_match('/([A-Z]).*/i', $s['title'], $matches);
|
|
$thisrange = strtoupper($matches[1]);
|
|
}
|
|
$serieslist[$thisrange][] = $s;
|
|
}
|
|
ksort($serieslist);
|
|
|
|
$this->smarty->assign('serieslist', $serieslist);
|
|
$this->smarty->assign('seriesrange', range('A', 'Z'));
|
|
$this->smarty->assign('seriesletter', $letter);
|
|
$this->smarty->assign('showname', $showname);
|
|
|
|
$content = $this->smarty->fetch('viewserieslist.tpl');
|
|
|
|
$this->smarty->assign(compact('title', 'content', 'meta_title', 'meta_keywords', 'meta_description'));
|
|
$this->pagerender();
|
|
}
|
|
}
|
|
}
|