mirror of
https://github.com/koel/koel
synced 2024-12-28 21:43:07 +00:00
28 lines
679 B
PHP
28 lines
679 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\API;
|
|
|
|
use App\Http\Requests\API\ViewSongRequest;
|
|
use App\Models\Album;
|
|
use iTunes;
|
|
|
|
class iTunesController extends Controller
|
|
{
|
|
/**
|
|
* View a song on iTunes store.
|
|
*
|
|
* @param ViewSongRequest $request
|
|
* @param Album $album
|
|
*
|
|
* @return \Illuminate\Http\RedirectResponse
|
|
*/
|
|
public function viewSong(ViewSongRequest $request, Album $album)
|
|
{
|
|
$url = iTunes::getTrackUrl($request->q, $album->name, $album->artist->name);
|
|
if ($url) {
|
|
return redirect($url);
|
|
} else {
|
|
abort(404, "Koel can't find such a song on iTunes Store.");
|
|
}
|
|
}
|
|
}
|