Add station URL and playlist download URLs to NowPlaying/Station APIs.
This commit is contained in:
parent
14c8c6fb24
commit
74733c7307
|
@ -54,6 +54,26 @@ class Station implements ResolvableUrlInterface
|
|||
*/
|
||||
public $listen_url;
|
||||
|
||||
/**
|
||||
* The public URL of the station.
|
||||
* @OA\Property(example="http://example.com/")
|
||||
*/
|
||||
public ?string $url = null;
|
||||
|
||||
/**
|
||||
* The playlist download URL in PLS format.
|
||||
* @OA\Property(example="http://example.com/public/example_station/playlist.pls")
|
||||
* @var string|UriInterface
|
||||
*/
|
||||
public $playlist_pls_url;
|
||||
|
||||
/**
|
||||
* The playlist download URL in M3U format.
|
||||
* @OA\Property(example="http://example.com/public/example_station/playlist.m3u")
|
||||
* @var string|UriInterface
|
||||
*/
|
||||
public $playlist_m3u_url;
|
||||
|
||||
/**
|
||||
* If the station is public (i.e. should be shown in listings of all stations)
|
||||
* @OA\Property(example=true)
|
||||
|
@ -81,6 +101,9 @@ class Station implements ResolvableUrlInterface
|
|||
{
|
||||
$this->listen_url = (string)Router::resolveUri($base, $this->listen_url, true);
|
||||
|
||||
$this->playlist_pls_url = (string)Router::resolveUri($base, $this->playlist_pls_url, true);
|
||||
$this->playlist_m3u_url = (string)Router::resolveUri($base, $this->playlist_m3u_url, true);
|
||||
|
||||
foreach ($this->mounts as $mount) {
|
||||
if ($mount instanceof ResolvableUrlInterface) {
|
||||
$mount->resolveUrls($base);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Entity\ApiGenerator;
|
||||
|
||||
use App\Entity;
|
||||
use App\Http\Router;
|
||||
use App\Radio\Adapters;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
|
||||
|
@ -10,9 +11,12 @@ class StationApiGenerator
|
|||
{
|
||||
protected Adapters $adapters;
|
||||
|
||||
public function __construct(Adapters $adapters)
|
||||
protected Router $router;
|
||||
|
||||
public function __construct(Adapters $adapters, Router $router)
|
||||
{
|
||||
$this->adapters = $adapters;
|
||||
$this->router = $router;
|
||||
}
|
||||
|
||||
public function __invoke(
|
||||
|
@ -30,9 +34,19 @@ class StationApiGenerator
|
|||
$response->description = (string)$station->getDescription();
|
||||
$response->frontend = (string)$station->getFrontendType();
|
||||
$response->backend = (string)$station->getBackendType();
|
||||
$response->url = $station->getUrl();
|
||||
$response->is_public = $station->getEnablePublicPage();
|
||||
$response->listen_url = $fa->getStreamUrl($station, $baseUri);
|
||||
|
||||
$response->playlist_pls_url = $this->router->named(
|
||||
'public:playlist',
|
||||
['station_id' => $station->getShortName(), 'format' => 'pls']
|
||||
);
|
||||
$response->playlist_m3u_url = $this->router->named(
|
||||
'public:playlist',
|
||||
['station_id' => $station->getShortName(), 'format' => 'm3u']
|
||||
);
|
||||
|
||||
$mounts = [];
|
||||
if ($fa->supportsMounts() && $station->getMounts()->count() > 0) {
|
||||
foreach ($station->getMounts() as $mount) {
|
||||
|
|
Loading…
Reference in New Issue