koel/app/Http/Controllers/API/MediaInformation/SongController.php

28 lines
871 B
PHP
Raw Normal View History

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;
2022-07-29 06:47:10 +00:00
use App\Http\Controllers\Controller;
2018-08-18 13:19:40 +00:00
use App\Models\Song;
use App\Services\MediaInformationService;
use App\Services\YouTubeService;
2018-08-18 13:19:40 +00:00
class SongController extends Controller
{
public function __construct(
2022-07-29 06:47:10 +00:00
private MediaInformationService $mediaInformationService,
private YouTubeService $youTubeService
) {
}
2018-08-18 13:19:40 +00:00
public function show(Song $song)
{
return response()->json([
'lyrics' => nl2br($song->lyrics), // backward compat
'album_info' => $this->mediaInformationService->getAlbumInformation($song->album)?->toArray() ?: [],
'artist_info' => $this->mediaInformationService->getArtistInformation($song->artist)?->toArray() ?: [],
'youtube' => $this->youTubeService->searchVideosRelatedToSong($song),
2018-08-18 13:19:40 +00:00
]);
}
}