mirror of
https://github.com/koel/koel
synced 2024-12-22 18:43:21 +00:00
47 lines
1,022 B
PHP
47 lines
1,022 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Http\Integrations\iTunes\Requests;
|
||
|
|
||
|
use App\Models\Album;
|
||
|
use App\Models\Artist;
|
||
|
use Saloon\Enums\Method;
|
||
|
use Saloon\Http\Request;
|
||
|
|
||
|
class GetTrackRequest extends Request
|
||
|
{
|
||
|
protected Method $method = Method::GET;
|
||
|
|
||
|
public function __construct(private string $trackName, private Album $album)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
/** @return array<mixed> */
|
||
|
protected function defaultQuery(): array
|
||
|
{
|
||
|
$term = $this->trackName;
|
||
|
|
||
|
if ($this->album->name !== Album::UNKNOWN_NAME) {
|
||
|
$term .= ' ' . $this->album->name;
|
||
|
}
|
||
|
|
||
|
if (
|
||
|
$this->album->artist->name !== Artist::UNKNOWN_NAME
|
||
|
&& $this->album->artist->name !== Artist::VARIOUS_NAME
|
||
|
) {
|
||
|
$term .= ' ' . $this->album->artist->name;
|
||
|
}
|
||
|
|
||
|
return [
|
||
|
'term' => $term,
|
||
|
'media' => 'music',
|
||
|
'entity' => 'song',
|
||
|
'limit' => 1,
|
||
|
];
|
||
|
}
|
||
|
|
||
|
public function resolveEndpoint(): string
|
||
|
{
|
||
|
return '/';
|
||
|
}
|
||
|
}
|