diff --git a/Changelog b/Changelog index 77501dfa4..f441ade63 100755 --- a/Changelog +++ b/Changelog @@ -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 diff --git a/app/Http/Controllers/SeriesController.php b/app/Http/Controllers/SeriesController.php new file mode 100644 index 000000000..53ed3e968 --- /dev/null +++ b/app/Http/Controllers/SeriesController.php @@ -0,0 +1,144 @@ +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(); + } + } +} diff --git a/routes/web.php b/routes/web.php index 6ab59a989..6bbaf2136 100644 --- a/routes/web.php +++ b/routes/web.php @@ -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');