2018-08-18 13:19:40 +00:00
|
|
|
<?php
|
2018-08-18 13:20:02 +00:00
|
|
|
|
2018-08-18 13:19:40 +00:00
|
|
|
namespace App\Http\Controllers\API\MediaInformation;
|
|
|
|
|
|
|
|
use App\Models\Song;
|
2018-08-19 11:08:16 +00:00
|
|
|
use App\Services\MediaInformationService;
|
|
|
|
use App\Services\YouTubeService;
|
2018-08-18 13:19:40 +00:00
|
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
|
2018-12-09 21:24:43 +00:00
|
|
|
/**
|
|
|
|
* @group 5. Media information
|
|
|
|
*/
|
2018-08-18 13:19:40 +00:00
|
|
|
class SongController extends Controller
|
|
|
|
{
|
2018-08-19 11:08:16 +00:00
|
|
|
private $youTubeService;
|
|
|
|
|
|
|
|
public function __construct(MediaInformationService $mediaInformationService, YouTubeService $youTubeService)
|
|
|
|
{
|
|
|
|
parent::__construct($mediaInformationService);
|
|
|
|
$this->youTubeService = $youTubeService;
|
|
|
|
}
|
|
|
|
|
2018-08-18 13:19:40 +00:00
|
|
|
/**
|
2020-04-07 21:41:30 +00:00
|
|
|
* Get song's extra information.
|
2018-12-09 21:24:43 +00:00
|
|
|
*
|
|
|
|
* Get a song's extra information. The response of this request is a superset of both corresponding
|
|
|
|
* `album/{album}/info` and `artist/{artist}/info` requests, combined with the song's lyrics and related YouTube
|
|
|
|
* videos, if applicable. This means you can (and should) cache this information somewhere ;)
|
|
|
|
*
|
|
|
|
* @responseFile responses/mediaInformation.song.show.json
|
2018-08-18 13:19:40 +00:00
|
|
|
*
|
|
|
|
* @return JsonResponse
|
|
|
|
*/
|
|
|
|
public function show(Song $song)
|
|
|
|
{
|
|
|
|
return response()->json([
|
|
|
|
'lyrics' => $song->lyrics,
|
|
|
|
'album_info' => $this->mediaInformationService->getAlbumInformation($song->album),
|
|
|
|
'artist_info' => $this->mediaInformationService->getArtistInformation($song->artist),
|
2018-08-19 11:08:16 +00:00
|
|
|
'youtube' => $this->youTubeService->searchVideosRelatedToSong($song),
|
2018-08-18 13:19:40 +00:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|