2015-12-13 04:42:28 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\API;
|
|
|
|
|
|
|
|
use App\Models\Song;
|
|
|
|
|
|
|
|
class SongController extends Controller
|
|
|
|
{
|
|
|
|
/**
|
2015-12-20 12:17:35 +00:00
|
|
|
* Get extra information about a song via Last.fm.
|
2015-12-19 16:36:44 +00:00
|
|
|
*
|
2015-12-27 13:29:03 +00:00
|
|
|
* @param Song $song
|
2015-12-19 16:36:44 +00:00
|
|
|
*
|
|
|
|
* @return \Illuminate\Http\JsonResponse
|
|
|
|
*/
|
2015-12-27 13:29:03 +00:00
|
|
|
public function getInfo(Song $song)
|
2015-12-19 16:36:44 +00:00
|
|
|
{
|
|
|
|
return response()->json([
|
|
|
|
'lyrics' => $song->lyrics,
|
|
|
|
'album_info' => $song->album->getInfo(),
|
|
|
|
'artist_info' => $song->album->artist->getInfo(),
|
|
|
|
]);
|
|
|
|
}
|
2015-12-20 12:17:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Scrobble a song.
|
|
|
|
*
|
2015-12-27 14:06:10 +00:00
|
|
|
* @param Song $song
|
2015-12-20 12:17:35 +00:00
|
|
|
* @param string $timestamp The UNIX timestamp when the song started playing.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Http\JsonResponse
|
|
|
|
*/
|
2015-12-27 13:29:03 +00:00
|
|
|
public function scrobble(Song $song, $timestamp)
|
2015-12-20 12:17:35 +00:00
|
|
|
{
|
2015-12-27 13:29:03 +00:00
|
|
|
return response()->json($song->scrobble($timestamp));
|
2015-12-20 12:17:35 +00:00
|
|
|
}
|
2015-12-13 04:42:28 +00:00
|
|
|
}
|