2016-07-14 08:47:50 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\API;
|
|
|
|
|
2017-12-09 18:34:27 +00:00
|
|
|
use App\Http\Requests\API\YouTubeSearchRequest;
|
2016-07-14 08:47:50 +00:00
|
|
|
use App\Models\Song;
|
2018-08-19 11:08:16 +00:00
|
|
|
use App\Services\YouTubeService;
|
2017-06-04 01:30:45 +00:00
|
|
|
use Illuminate\Http\JsonResponse;
|
2016-07-14 08:47:50 +00:00
|
|
|
|
2018-12-09 21:24:43 +00:00
|
|
|
/**
|
|
|
|
* @group YouTube integration
|
|
|
|
*/
|
2016-07-14 08:47:50 +00:00
|
|
|
class YouTubeController extends Controller
|
|
|
|
{
|
2018-08-19 11:08:16 +00:00
|
|
|
private $youTubeService;
|
|
|
|
|
|
|
|
public function __construct(YouTubeService $youTubeService)
|
|
|
|
{
|
|
|
|
$this->youTubeService = $youTubeService;
|
|
|
|
}
|
|
|
|
|
2016-07-14 08:47:50 +00:00
|
|
|
/**
|
2018-12-09 21:24:43 +00:00
|
|
|
* Search for YouTube videos.
|
|
|
|
*
|
|
|
|
* Search YouTube for videos related to a song (using its title and artist name).
|
|
|
|
*
|
|
|
|
* @bodyParam pageToken string The [`nextPageToken`](https://developers.google.com/youtube/v3/guides/implementation/pagination), if applicable.
|
|
|
|
* @responseFile responses/youTube.searchVideosRelatedToSong.json
|
2016-07-14 08:47:50 +00:00
|
|
|
*
|
2017-06-04 01:30:45 +00:00
|
|
|
* @return JsonResponse
|
2016-07-14 08:47:50 +00:00
|
|
|
*/
|
2017-12-09 18:34:27 +00:00
|
|
|
public function searchVideosRelatedToSong(YouTubeSearchRequest $request, Song $song)
|
2016-07-14 08:47:50 +00:00
|
|
|
{
|
2018-08-19 11:08:16 +00:00
|
|
|
return response()->json($this->youTubeService->searchVideosRelatedToSong($song, $request->pageToken));
|
2016-07-14 08:47:50 +00:00
|
|
|
}
|
|
|
|
}
|