39 lines
763 B
PHP
39 lines
763 B
PHP
<?php
|
|
|
|
// retrieve album info
|
|
$app->get('/apiv1/music/album-info/:albumid', function($albumid) use($app) {
|
|
|
|
if (!ctype_digit($albumid)) {
|
|
echo 'Don\'t do that';
|
|
return;
|
|
}
|
|
|
|
$album = $app->album->where('id', $albumid)->first();
|
|
|
|
if ($album) {
|
|
echo json_encode($album);
|
|
} else {
|
|
$app->notFound();
|
|
}
|
|
|
|
})->name('apiv1.music.album-info');
|
|
|
|
// retrieve an album's songs
|
|
$app->get('/apiv1/music/album-songs/:albumid', function($albumid) use($app) {
|
|
|
|
if (!ctype_digit($albumid)) {
|
|
echo 'Don\'t do that';
|
|
return;
|
|
}
|
|
|
|
$album = $app->album->where('id', $albumid)->first();
|
|
|
|
if ($album) {
|
|
$json = ['songs' => $album->songs];
|
|
echo json_encode($json);
|
|
} else {
|
|
$app->notFound();
|
|
}
|
|
|
|
})->name('apiv1.music.album-songs');
|