Podcasts
This commit is contained in:
@@ -5,7 +5,6 @@ namespace App\Http\Controllers;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', true);
|
||||
|
||||
@@ -36,6 +35,22 @@ QUERY;
|
||||
* Lijst van alle podcasts
|
||||
*/
|
||||
public function overview(Request $request) {
|
||||
return $this->getPodcastList($request, null, []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lijst van alle podcasts voor een specifiek programma
|
||||
*/
|
||||
public function program(Request $request, $program) {
|
||||
if((int)$program <= 0) {
|
||||
return abort(404);
|
||||
}
|
||||
|
||||
return $this->getPodcastList($request, '`podcast_meta`.`program` = :program', ['program' => (int)$program]);
|
||||
}
|
||||
|
||||
private function getPodcastList(Request $request, $filter, $params)
|
||||
{
|
||||
$count = (int)$request->get('aantal', 15);
|
||||
$page = (int)$request->get('pagina', 1);
|
||||
if($count <= 0 || $page <= 0) {
|
||||
@@ -44,8 +59,10 @@ QUERY;
|
||||
|
||||
$start = ($page - 1) * $count;
|
||||
$podcasts = app('db')->select(self::$BASE_SQL
|
||||
. ($filter ? ' AND (' . $filter . ')' : '')
|
||||
. ' ORDER BY `podcast_meta`.`creationdt` DESC, `podcast_meta`.`id` DESC'
|
||||
. ' LIMIT ' . (int)$start . ', ' . (int)$count);
|
||||
. ' LIMIT ' . (int)$start . ', ' . (int)$count,
|
||||
$params);
|
||||
|
||||
$result = array();
|
||||
foreach($podcasts as $podcast) {
|
||||
@@ -58,11 +75,11 @@ QUERY;
|
||||
/**
|
||||
* Download specifieke podcast
|
||||
*/
|
||||
public function download(Request $request, int $id) {
|
||||
public function download(Request $request, $id) {
|
||||
$queryResult = app('db')->select(self::$BASE_SQL
|
||||
. ' AND `podcast`.`id` = :id '
|
||||
. ' LIMIT 0, 1',
|
||||
['id' => $id]);
|
||||
['id' => (int)$id]);
|
||||
|
||||
if(count($queryResult) == 0) { return abort(404); }
|
||||
|
||||
@@ -75,7 +92,7 @@ QUERY;
|
||||
'6FM Gemist - ' . $podcast->title . '.mp3');
|
||||
}
|
||||
|
||||
public function stream(Request $request, int $id) {
|
||||
public function stream(Request $request, $id) {
|
||||
$queryResult = app('db')->select(self::$BASE_SQL
|
||||
. ' AND `podcast`.`id` = :id '
|
||||
. ' LIMIT 0, 1',
|
||||
|
||||
@@ -25,9 +25,9 @@ $app->get('agenda/kalender[/{year:\d\d\d\d}/{month:\d\d?}]', 'AgendaController@c
|
||||
$app->get('agenda/details/{id:\d+}', 'AgendaController@item' );
|
||||
|
||||
$app->get('podcast/overzicht', 'PodcastController@overview' );
|
||||
// podcast/programma/1234[?aantal=&pagina=]
|
||||
$app->get('podcast/download/{id:\d+}/[{title}]', 'PodcastController@download' );
|
||||
$app->get('podcast/stream/{id:\d+}/[{title}]', 'PodcastController@stream' );
|
||||
$app->get('podcast/programma/{id:\d+}', 'PodcastController@program' );
|
||||
$app->get('podcast/download/{id:\d+}', 'PodcastController@download' );
|
||||
$app->get('podcast/stream/{id:\d+}', 'PodcastController@stream' );
|
||||
|
||||
$app->get('programma/schema/nustraks', 'ProgramController@comingup' );
|
||||
$app->get('programma/schema/week[/{shiftWeeks:-?\d+}]', 'ProgramController@schedule' );
|
||||
|
||||
Reference in New Issue
Block a user