mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:08:56 +00:00
Add SeriesController
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
2018-04-16 DariusIII
|
||||
* Chg: Add SeriesController
|
||||
* Chg: Add controller for send to functions
|
||||
* Chg: Optimize queue controller
|
||||
* Chg: Add NZBGetController and route
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\UserSerie;
|
||||
use App\Models\Video;
|
||||
use Blacklight\Releases;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class SeriesController extends BasePageController
|
||||
{
|
||||
/**
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$this->setPrefs();
|
||||
$releases = new Releases(['Settings' => $this->settings]);
|
||||
|
||||
if ($request->has('id') && ctype_digit($request->input('id'))) {
|
||||
$category = -1;
|
||||
if ($request->has('t') && ctype_digit($request->input('t'))) {
|
||||
$category = $request->input('t');
|
||||
}
|
||||
|
||||
$catarray = [];
|
||||
$catarray[] = $category;
|
||||
|
||||
$rel = $releases->tvSearch(['id' => $request->input('id')], '', '', '', 0, 1000, '', $catarray, -1);
|
||||
$show = Video::getByVideoID($request->input('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(Auth::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);
|
||||
|
||||
$series = [];
|
||||
foreach ($rel as $r) {
|
||||
$series[$r['series']][$r['episode']][] = $r;
|
||||
}
|
||||
|
||||
$this->smarty->assign('seasons', $series);
|
||||
$this->smarty->assign('show', $show);
|
||||
$this->smarty->assign('myshows', $myshows);
|
||||
|
||||
//get series name(s), description, country and genre
|
||||
$seriestitles = $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', array_shift($seriessummary));
|
||||
$this->smarty->assign('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 = ($request->has('id') && preg_match('/^(0\-9|[A-Z])$/i', $request->input('id'))) ? $request->input('id') : '0-9';
|
||||
|
||||
$showname = ($request->has('title') && ! empty($request->input('title'))) ? $request->input('title') : '';
|
||||
|
||||
if ($showname !== '' && ! $request->has('id')) {
|
||||
$letter = '';
|
||||
}
|
||||
|
||||
$masterserieslist = Video::getSeriesList(Auth::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([
|
||||
'title' => $title,
|
||||
'content' => $content,
|
||||
'meta_title' => $meta_title,
|
||||
'meta_keywords' => $meta_keywords,
|
||||
'meta_description' => $meta_description,
|
||||
]);
|
||||
$this->pagerender();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -184,3 +184,7 @@ Route::post('sendtoqueue', 'SendReleaseController@queue');
|
||||
Route::get('sendtocouch', 'SendReleaseController@couchPotato');
|
||||
|
||||
Route::post('sendtocouch', 'SendReleaseController@couchPotato');
|
||||
|
||||
Route::get('series', 'SeriesController@index');
|
||||
|
||||
Route::post('series', 'SeriesController@index');
|
||||
|
||||
Reference in New Issue
Block a user