2015-01-02 08:16:54 +00:00
|
|
|
<?php
|
2020-10-14 22:19:31 +00:00
|
|
|
|
2020-12-08 18:40:33 +00:00
|
|
|
/** @noinspection PhpMissingFieldTypeInspection */
|
|
|
|
|
2018-08-04 22:05:14 +00:00
|
|
|
namespace App\Entity;
|
2015-01-02 08:16:54 +00:00
|
|
|
|
2019-09-04 18:00:51 +00:00
|
|
|
use App\Annotations\AuditLog;
|
2020-12-03 04:18:06 +00:00
|
|
|
use App\Environment;
|
2020-11-10 03:06:48 +00:00
|
|
|
use App\Normalizer\Annotation\DeepNormalize;
|
2019-08-07 04:33:55 +00:00
|
|
|
use App\Radio\Adapters;
|
2020-12-11 02:43:58 +00:00
|
|
|
use App\Utilities\File;
|
2019-08-07 04:33:55 +00:00
|
|
|
use App\Validator\Constraints as AppAssert;
|
2020-10-05 06:27:12 +00:00
|
|
|
use DateTimeZone;
|
2018-12-22 00:01:04 +00:00
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
|
|
use Doctrine\Common\Collections\Collection;
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
2021-04-23 22:12:47 +00:00
|
|
|
use InvalidArgumentException;
|
2021-03-31 16:42:24 +00:00
|
|
|
use League\Flysystem\UnixVisibility\PortableVisibilityConverter;
|
2019-08-07 04:33:55 +00:00
|
|
|
use OpenApi\Annotations as OA;
|
2021-04-23 22:12:47 +00:00
|
|
|
use RuntimeException;
|
2021-05-30 18:55:26 +00:00
|
|
|
use Stringable;
|
2020-11-10 03:06:48 +00:00
|
|
|
use Symfony\Component\Serializer\Annotation as Serializer;
|
2019-08-07 04:33:55 +00:00
|
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
2015-01-02 08:16:54 +00:00
|
|
|
|
2021-05-30 18:55:26 +00:00
|
|
|
/** @OA\Schema(type="object", schema="Station") */
|
|
|
|
#[
|
|
|
|
ORM\Entity,
|
|
|
|
ORM\Table(name: 'station'),
|
|
|
|
ORM\Index(columns: ['short_name'], name: 'idx_short_name'),
|
|
|
|
ORM\HasLifecycleCallbacks,
|
|
|
|
AuditLog\Auditable,
|
|
|
|
AppAssert\StationPortChecker,
|
|
|
|
AppAssert\UniqueEntity(fields: ['short_name'])
|
|
|
|
]
|
|
|
|
class Station implements Stringable
|
2015-01-02 08:16:54 +00:00
|
|
|
{
|
2021-05-30 18:55:26 +00:00
|
|
|
use Traits\HasAutoIncrementId;
|
2020-10-14 22:19:31 +00:00
|
|
|
use Traits\TruncateStrings;
|
|
|
|
|
2018-09-09 18:23:03 +00:00
|
|
|
public const DEFAULT_REQUEST_DELAY = 5;
|
|
|
|
public const DEFAULT_REQUEST_THRESHOLD = 15;
|
2018-10-27 00:14:32 +00:00
|
|
|
public const DEFAULT_DISCONNECT_DEACTIVATE_STREAMER = 0;
|
2018-09-09 18:23:03 +00:00
|
|
|
public const DEFAULT_API_HISTORY_ITEMS = 5;
|
2018-08-18 23:01:03 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
2021-05-30 18:55:26 +00:00
|
|
|
* @OA\Property(
|
|
|
|
* description="The full display name of the station.",
|
|
|
|
* example="AzuraTest Radio"
|
|
|
|
* )
|
2017-08-17 18:28:48 +00:00
|
|
|
*/
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\Column(length: 100)]
|
|
|
|
#[Assert\NotBlank]
|
|
|
|
protected ?string $name = null;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
|
|
|
/**
|
2021-05-30 18:55:26 +00:00
|
|
|
* @OA\Property(
|
|
|
|
* description="The URL-friendly name for the station, typically auto-generated from the full station name.",
|
|
|
|
* example="azuratest_radio"
|
|
|
|
* )
|
2017-12-08 09:51:08 +00:00
|
|
|
*/
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\Column(length: 100)]
|
|
|
|
#[Assert\NotBlank]
|
|
|
|
protected ?string $short_name = null;
|
2017-12-08 09:51:08 +00:00
|
|
|
|
2018-03-24 07:38:27 +00:00
|
|
|
/**
|
2021-05-30 18:55:26 +00:00
|
|
|
* @OA\Property(
|
|
|
|
* description="If set to 'false', prevents the station from broadcasting but leaves it in the database.",
|
|
|
|
* example=true
|
|
|
|
* )
|
2018-03-24 07:38:27 +00:00
|
|
|
*/
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\Column]
|
|
|
|
protected bool $is_enabled = true;
|
2018-03-24 07:38:27 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
2021-05-30 18:55:26 +00:00
|
|
|
* @OA\Property(
|
|
|
|
* description="The frontend adapter (icecast,shoutcast,remote,etc)",
|
|
|
|
* example="icecast"
|
|
|
|
* )
|
2017-08-17 18:28:48 +00:00
|
|
|
*/
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\Column(length: 100)]
|
|
|
|
#[Assert\Choice(choices: [Adapters::FRONTEND_ICECAST, Adapters::FRONTEND_REMOTE, Adapters::FRONTEND_SHOUTCAST])]
|
|
|
|
protected ?string $frontend_type = Adapters::FRONTEND_ICECAST;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
|
|
|
/**
|
2021-05-30 18:55:26 +00:00
|
|
|
* @OA\Property(
|
|
|
|
* type="array",
|
|
|
|
* description="An array containing station-specific frontend configuration",
|
|
|
|
* @OA\Items()
|
|
|
|
* )
|
2017-08-17 18:28:48 +00:00
|
|
|
*/
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\Column(type: 'json', nullable: true)]
|
|
|
|
protected ?array $frontend_config = null;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
|
|
|
/**
|
2021-05-30 18:55:26 +00:00
|
|
|
* @OA\Property(
|
|
|
|
* description="The backend adapter (liquidsoap,etc)",
|
|
|
|
* example="liquidsoap"
|
|
|
|
* )
|
2017-08-17 18:28:48 +00:00
|
|
|
*/
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\Column(length: 100)]
|
|
|
|
#[Assert\Choice(choices: [Adapters::BACKEND_LIQUIDSOAP, Adapters::BACKEND_NONE])]
|
|
|
|
protected ?string $backend_type = Adapters::BACKEND_LIQUIDSOAP;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
|
|
|
/**
|
2021-05-30 18:55:26 +00:00
|
|
|
* @OA\Property(
|
|
|
|
* type="array",
|
|
|
|
* description="An array containing station-specific backend configuration",
|
|
|
|
* @OA\Items()
|
|
|
|
* )
|
2017-08-17 18:28:48 +00:00
|
|
|
*/
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\Column(type: 'json', nullable: true)]
|
|
|
|
protected ?array $backend_config = null;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\Column(length: 150)]
|
|
|
|
#[AuditLog\AuditIgnore]
|
|
|
|
protected ?string $adapter_api_key = null;
|
2017-09-07 03:53:25 +00:00
|
|
|
|
2021-05-30 18:55:26 +00:00
|
|
|
/** @OA\Property(example="A sample radio station.") */
|
|
|
|
#[ORM\Column(type: 'text')]
|
|
|
|
protected ?string $description = null;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
2021-05-30 18:55:26 +00:00
|
|
|
/** @OA\Property(example="https://demo.azuracast.com/") */
|
|
|
|
#[ORM\Column(length: 255)]
|
|
|
|
protected ?string $url = null;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
2021-05-30 18:55:26 +00:00
|
|
|
/** @OA\Property(example="Various") */
|
|
|
|
#[ORM\Column(length: 150)]
|
|
|
|
protected ?string $genre = null;
|
2018-11-26 08:16:55 +00:00
|
|
|
|
2021-05-30 18:55:26 +00:00
|
|
|
/** @OA\Property(example="/var/azuracast/stations/azuratest_radio") */
|
|
|
|
#[ORM\Column(length: 255)]
|
|
|
|
protected ?string $radio_base_dir = null;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\Column(type: 'array', nullable: true)]
|
|
|
|
#[AuditLog\AuditIgnore]
|
|
|
|
protected mixed $nowplaying;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\Column]
|
|
|
|
#[AuditLog\AuditIgnore]
|
|
|
|
protected ?int $nowplaying_timestamp = null;
|
2017-09-07 03:53:25 +00:00
|
|
|
|
2021-05-30 18:55:26 +00:00
|
|
|
/** @OA\Property(type="array", @OA\Items()) */
|
|
|
|
#[ORM\Column(type: 'json')]
|
|
|
|
protected ?array $automation_settings = null;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\Column]
|
|
|
|
#[AuditLog\AuditIgnore]
|
|
|
|
protected ?int $automation_timestamp = 0;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
|
|
|
/**
|
2021-05-30 18:55:26 +00:00
|
|
|
* @OA\Property(
|
|
|
|
* description="Whether listeners can request songs to play on this station.",
|
|
|
|
* example=true
|
|
|
|
* )
|
2017-08-17 18:28:48 +00:00
|
|
|
*/
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\Column]
|
|
|
|
protected bool $enable_requests = false;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
2021-05-30 18:55:26 +00:00
|
|
|
/** @OA\Property(example=5) */
|
|
|
|
#[ORM\Column]
|
|
|
|
protected ?int $request_delay = self::DEFAULT_REQUEST_DELAY;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
2021-05-30 18:55:26 +00:00
|
|
|
/** @OA\Property(example=15) */
|
|
|
|
#[ORM\Column]
|
|
|
|
protected ?int $request_threshold = self::DEFAULT_REQUEST_THRESHOLD;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
2021-05-30 18:55:26 +00:00
|
|
|
/** @OA\Property(example=0) */
|
|
|
|
#[ORM\Column(options: ['default' => 0])]
|
|
|
|
protected ?int $disconnect_deactivate_streamer = self::DEFAULT_DISCONNECT_DEACTIVATE_STREAMER;
|
2018-10-27 00:14:32 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
2021-05-30 18:55:26 +00:00
|
|
|
* @OA\Property(
|
|
|
|
* description="Whether streamers are allowed to broadcast to this station at all.",
|
|
|
|
* example=false
|
|
|
|
* )
|
2017-08-17 18:28:48 +00:00
|
|
|
*/
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\Column]
|
|
|
|
protected bool $enable_streamers = false;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
2018-02-03 21:54:12 +00:00
|
|
|
/**
|
2021-05-30 18:55:26 +00:00
|
|
|
* @OA\Property(
|
|
|
|
* description="Whether a streamer is currently active on the station.",
|
|
|
|
* example=false
|
|
|
|
* )
|
2018-02-03 21:54:12 +00:00
|
|
|
*/
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\Column]
|
|
|
|
#[AuditLog\AuditIgnore]
|
|
|
|
protected bool $is_streamer_live = false;
|
2018-02-03 21:54:12 +00:00
|
|
|
|
2017-09-18 03:27:32 +00:00
|
|
|
/**
|
2021-05-30 18:55:26 +00:00
|
|
|
* @OA\Property(
|
|
|
|
* description="Whether this station is visible as a public page and in a now-playing API response.",
|
|
|
|
* example=true
|
|
|
|
* )
|
2017-09-18 03:27:32 +00:00
|
|
|
*/
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\Column]
|
|
|
|
protected bool $enable_public_page = true;
|
2017-09-18 03:27:32 +00:00
|
|
|
|
2020-05-15 10:13:47 +00:00
|
|
|
/**
|
2021-05-30 18:55:26 +00:00
|
|
|
* @OA\Property(
|
|
|
|
* description="Whether this station has a public 'on-demand' streaming and download page.",
|
|
|
|
* example=true
|
|
|
|
* )
|
2020-05-15 10:13:47 +00:00
|
|
|
*/
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\Column]
|
|
|
|
protected bool $enable_on_demand = false;
|
2020-05-15 10:13:47 +00:00
|
|
|
|
2021-01-05 06:43:01 +00:00
|
|
|
/**
|
2021-05-30 18:55:26 +00:00
|
|
|
* @OA\Property(
|
|
|
|
* description="Whether the 'on-demand' page offers download capability.",
|
|
|
|
* example=true
|
|
|
|
* )
|
2021-01-05 06:43:01 +00:00
|
|
|
*/
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\Column]
|
|
|
|
protected bool $enable_on_demand_download = true;
|
2021-01-05 06:43:01 +00:00
|
|
|
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\Column]
|
|
|
|
#[AuditLog\AuditIgnore]
|
|
|
|
protected bool $needs_restart = false;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\Column]
|
|
|
|
#[AuditLog\AuditIgnore]
|
|
|
|
protected bool $has_started = false;
|
2018-08-18 23:01:03 +00:00
|
|
|
|
|
|
|
/**
|
2021-05-30 18:55:26 +00:00
|
|
|
* @OA\Property(
|
|
|
|
* description="The number of 'last played' history items to show for a station in API responses.",
|
|
|
|
* example=5
|
|
|
|
* )
|
2018-08-18 23:01:03 +00:00
|
|
|
*/
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\Column(type: 'smallint')]
|
|
|
|
protected int $api_history_items = self::DEFAULT_API_HISTORY_ITEMS;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
2019-05-13 21:25:36 +00:00
|
|
|
/**
|
2021-05-30 18:55:26 +00:00
|
|
|
* @OA\Property(
|
|
|
|
* description="The time zone that station operations should take place in.",
|
|
|
|
* example="UTC"
|
|
|
|
* )
|
2019-05-13 21:25:36 +00:00
|
|
|
*/
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\Column(length: 100)]
|
|
|
|
protected ?string $timezone = 'UTC';
|
2019-05-13 21:25:36 +00:00
|
|
|
|
2020-05-03 01:28:08 +00:00
|
|
|
/**
|
2021-05-30 18:55:26 +00:00
|
|
|
* @OA\Property(
|
|
|
|
* description="The station-specific default album artwork URL.",
|
|
|
|
* example="https://example.com/image.jpg"
|
|
|
|
* )
|
2020-05-03 01:28:08 +00:00
|
|
|
*/
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\Column(length: 255)]
|
|
|
|
protected ?string $default_album_art_url = null;
|
2020-05-03 01:28:08 +00:00
|
|
|
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\OneToMany(mappedBy: 'station', targetEntity: SongHistory::class)]
|
|
|
|
#[ORM\OrderBy(['timestamp_start' => 'desc'])]
|
|
|
|
protected Collection $history;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\ManyToOne]
|
|
|
|
#[ORM\JoinColumn(name: 'media_storage_location_id', referencedColumnName: 'id', onDelete: 'SET NULL')]
|
|
|
|
#[DeepNormalize(true)]
|
|
|
|
#[Serializer\MaxDepth(1)]
|
|
|
|
protected ?StorageLocation $media_storage_location = null;
|
2020-11-10 03:06:48 +00:00
|
|
|
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\ManyToOne]
|
|
|
|
#[ORM\JoinColumn(name: 'recordings_storage_location_id', referencedColumnName: 'id', onDelete: 'SET NULL')]
|
|
|
|
#[DeepNormalize(true)]
|
|
|
|
#[Serializer\MaxDepth(1)]
|
|
|
|
protected ?StorageLocation $recordings_storage_location = null;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\ManyToOne]
|
|
|
|
#[ORM\JoinColumn(name: 'podcasts_storage_location_id', referencedColumnName: 'id', onDelete: 'SET NULL')]
|
|
|
|
#[DeepNormalize(true)]
|
|
|
|
#[Serializer\MaxDepth(1)]
|
|
|
|
protected ?StorageLocation $podcasts_storage_location = null;
|
2021-05-25 04:29:07 +00:00
|
|
|
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\OneToMany(mappedBy: 'station', targetEntity: StationStreamer::class)]
|
|
|
|
protected Collection $streamers;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\Column]
|
|
|
|
protected ?int $current_streamer_id = null;
|
2018-02-03 21:54:12 +00:00
|
|
|
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\ManyToOne]
|
|
|
|
#[ORM\JoinColumn(name: 'current_streamer_id', referencedColumnName: 'id', onDelete: 'SET NULL')]
|
|
|
|
protected ?StationStreamer $current_streamer = null;
|
2018-02-03 21:54:12 +00:00
|
|
|
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\OneToMany(mappedBy: 'station', targetEntity: RolePermission::class)]
|
|
|
|
protected Collection $permissions;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\OneToMany(mappedBy: 'station', targetEntity: StationPlaylist::class)]
|
|
|
|
#[ORM\OrderBy(['type' => 'ASC', 'weight' => 'DESC'])]
|
|
|
|
protected Collection $playlists;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\OneToMany(mappedBy: 'station', targetEntity: StationMount::class)]
|
|
|
|
protected Collection $mounts;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\OneToMany(mappedBy: 'station', targetEntity: StationRemote::class)]
|
|
|
|
protected Collection $remotes;
|
2018-09-09 18:23:03 +00:00
|
|
|
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\OneToMany(
|
|
|
|
mappedBy: 'station',
|
|
|
|
targetEntity: StationWebhook::class,
|
|
|
|
cascade: ['persist'],
|
|
|
|
fetch: 'EXTRA_LAZY'
|
|
|
|
)]
|
|
|
|
protected Collection $webhooks;
|
2018-02-12 12:46:03 +00:00
|
|
|
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\OneToMany(mappedBy: 'station', targetEntity: SftpUser::class)]
|
|
|
|
protected Collection $sftp_users;
|
2020-01-05 21:29:56 +00:00
|
|
|
|
2017-01-24 00:17:50 +00:00
|
|
|
public function __construct()
|
|
|
|
{
|
2020-10-14 22:19:31 +00:00
|
|
|
$this->history = new ArrayCollection();
|
|
|
|
$this->playlists = new ArrayCollection();
|
|
|
|
$this->mounts = new ArrayCollection();
|
|
|
|
$this->remotes = new ArrayCollection();
|
|
|
|
$this->webhooks = new ArrayCollection();
|
|
|
|
$this->streamers = new ArrayCollection();
|
|
|
|
$this->sftp_users = new ArrayCollection();
|
2017-01-24 00:17:50 +00:00
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getName(): ?string
|
|
|
|
{
|
|
|
|
return $this->name;
|
|
|
|
}
|
2015-01-02 08:16:54 +00:00
|
|
|
|
2019-01-28 20:47:19 +00:00
|
|
|
public function setName(?string $name = null): void
|
2017-01-24 00:17:50 +00:00
|
|
|
{
|
2021-05-30 18:55:26 +00:00
|
|
|
$this->name = $this->truncateNullableString($name, 100);
|
2017-12-08 09:51:08 +00:00
|
|
|
|
|
|
|
if (empty($this->short_name) && !empty($name)) {
|
2020-12-29 21:27:39 +00:00
|
|
|
$this->setShortName(null);
|
2020-03-05 14:37:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getShortName(): ?string
|
|
|
|
{
|
|
|
|
return (!empty($this->short_name))
|
|
|
|
? $this->short_name
|
|
|
|
: self::getStationShortName($this->name);
|
|
|
|
}
|
|
|
|
|
2020-12-29 21:27:39 +00:00
|
|
|
public function setShortName(?string $shortName): void
|
2020-03-05 14:37:35 +00:00
|
|
|
{
|
2020-12-29 21:27:39 +00:00
|
|
|
$shortName = trim($shortName);
|
|
|
|
if (empty($shortName)) {
|
|
|
|
$shortName = $this->name;
|
2017-12-08 09:51:08 +00:00
|
|
|
}
|
2020-12-29 21:27:39 +00:00
|
|
|
|
|
|
|
$shortName = self::getStationShortName($shortName);
|
|
|
|
$this->short_name = $this->truncateString($shortName, 100);
|
2017-01-24 00:17:50 +00:00
|
|
|
}
|
|
|
|
|
2019-12-02 21:54:09 +00:00
|
|
|
public static function getStationShortName(string $str): string
|
2018-03-24 07:38:27 +00:00
|
|
|
{
|
2019-12-02 21:54:09 +00:00
|
|
|
return File::sanitizeFileName($str);
|
2018-03-24 07:38:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setIsEnabled(bool $is_enabled): void
|
|
|
|
{
|
|
|
|
$this->is_enabled = $is_enabled;
|
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getFrontendType(): ?string
|
|
|
|
{
|
|
|
|
return $this->frontend_type;
|
|
|
|
}
|
|
|
|
|
2020-03-29 07:16:41 +00:00
|
|
|
public function setFrontendType(?string $frontend_type = null): void
|
2017-08-17 18:28:48 +00:00
|
|
|
{
|
|
|
|
$this->frontend_type = $frontend_type;
|
|
|
|
}
|
2016-05-19 14:56:21 +00:00
|
|
|
|
2020-05-02 07:58:59 +00:00
|
|
|
public function getFrontendConfig(): StationFrontendConfiguration
|
2017-08-17 18:28:48 +00:00
|
|
|
{
|
2020-05-02 07:58:59 +00:00
|
|
|
return new StationFrontendConfiguration((array)$this->frontend_config);
|
2017-08-17 18:28:48 +00:00
|
|
|
}
|
|
|
|
|
2020-05-02 07:58:59 +00:00
|
|
|
/**
|
|
|
|
* @param array|StationFrontendConfiguration $frontend_config
|
|
|
|
* @param bool $force_overwrite
|
|
|
|
*/
|
2021-04-23 22:12:47 +00:00
|
|
|
public function setFrontendConfig(
|
|
|
|
StationFrontendConfiguration|array $frontend_config,
|
|
|
|
bool $force_overwrite = false
|
|
|
|
): void {
|
2020-05-02 07:58:59 +00:00
|
|
|
if (!($frontend_config instanceof StationFrontendConfiguration)) {
|
|
|
|
$config = new StationFrontendConfiguration(
|
|
|
|
($force_overwrite) ? [] : (array)$this->frontend_config,
|
|
|
|
);
|
2020-07-11 05:38:20 +00:00
|
|
|
|
|
|
|
foreach ($frontend_config as $key => $val) {
|
|
|
|
$config->set($key, $val);
|
|
|
|
}
|
|
|
|
|
2020-05-02 07:58:59 +00:00
|
|
|
$frontend_config = $config;
|
2017-08-04 11:46:30 +00:00
|
|
|
}
|
2018-05-01 14:37:52 +00:00
|
|
|
|
2021-01-19 21:16:32 +00:00
|
|
|
$config = $frontend_config->toArray();
|
|
|
|
|
|
|
|
if ($this->frontend_config != $config) {
|
|
|
|
$this->setNeedsRestart(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->frontend_config = $config;
|
2018-03-10 15:37:35 +00:00
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getBackendType(): ?string
|
2017-01-24 00:17:50 +00:00
|
|
|
{
|
2017-08-17 18:28:48 +00:00
|
|
|
return $this->backend_type;
|
2017-01-24 00:17:50 +00:00
|
|
|
}
|
|
|
|
|
2019-01-28 20:47:19 +00:00
|
|
|
public function setBackendType(string $backend_type = null): void
|
2017-08-17 18:28:48 +00:00
|
|
|
{
|
|
|
|
$this->backend_type = $backend_type;
|
|
|
|
}
|
2015-02-17 12:23:21 +00:00
|
|
|
|
2019-05-19 15:30:44 +00:00
|
|
|
/**
|
|
|
|
* Clear all port assignments for the station (useful after cloning).
|
|
|
|
*/
|
|
|
|
public function clearPorts(): void
|
|
|
|
{
|
2020-05-02 07:58:59 +00:00
|
|
|
$fe_config = $this->getFrontendConfig();
|
|
|
|
$fe_config->setPort(null);
|
|
|
|
$this->setFrontendConfig($fe_config);
|
|
|
|
|
|
|
|
$be_config = $this->getBackendConfig();
|
|
|
|
$be_config->setDjPort(null);
|
|
|
|
$be_config->setTelnetPort(null);
|
|
|
|
$this->setBackendConfig($be_config);
|
2019-05-19 15:30:44 +00:00
|
|
|
}
|
|
|
|
|
2018-05-01 07:32:31 +00:00
|
|
|
/**
|
|
|
|
* Whether the station uses AzuraCast to directly manage the AutoDJ or lets the backend handle it.
|
|
|
|
*/
|
|
|
|
public function useManualAutoDJ(): bool
|
|
|
|
{
|
2020-05-02 07:58:59 +00:00
|
|
|
$settings = $this->getBackendConfig();
|
|
|
|
return $settings->useManualAutoDj();
|
2018-05-01 07:32:31 +00:00
|
|
|
}
|
|
|
|
|
2020-05-02 07:58:59 +00:00
|
|
|
public function getBackendConfig(): StationBackendConfiguration
|
2019-09-04 18:00:51 +00:00
|
|
|
{
|
2020-05-02 07:58:59 +00:00
|
|
|
return new StationBackendConfiguration((array)$this->backend_config);
|
2019-09-04 18:00:51 +00:00
|
|
|
}
|
|
|
|
|
2020-05-02 07:58:59 +00:00
|
|
|
/**
|
|
|
|
* @param array|StationBackendConfiguration $backend_config
|
|
|
|
* @param bool $force_overwrite
|
|
|
|
*/
|
2021-04-23 22:12:47 +00:00
|
|
|
public function setBackendConfig(
|
|
|
|
StationBackendConfiguration|array $backend_config,
|
|
|
|
bool $force_overwrite = false
|
|
|
|
): void {
|
2020-05-02 07:58:59 +00:00
|
|
|
if (!($backend_config instanceof StationBackendConfiguration)) {
|
|
|
|
$config = new StationBackendConfiguration(
|
|
|
|
($force_overwrite) ? [] : (array)$this->backend_config
|
|
|
|
);
|
2020-07-11 05:38:20 +00:00
|
|
|
|
|
|
|
foreach ($backend_config as $key => $val) {
|
|
|
|
$config->set($key, $val);
|
|
|
|
}
|
2020-05-02 07:58:59 +00:00
|
|
|
|
|
|
|
$backend_config = $config;
|
2019-09-04 18:00:51 +00:00
|
|
|
}
|
|
|
|
|
2021-01-19 21:16:32 +00:00
|
|
|
$config = $backend_config->toArray();
|
|
|
|
|
|
|
|
if ($this->backend_config != $config) {
|
|
|
|
$this->setNeedsRestart(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->backend_config = $config;
|
2019-09-04 18:00:51 +00:00
|
|
|
}
|
|
|
|
|
2017-09-07 03:53:25 +00:00
|
|
|
public function getAdapterApiKey(): ?string
|
|
|
|
{
|
|
|
|
return $this->adapter_api_key;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate a random new adapter API key.
|
|
|
|
*/
|
2019-01-28 20:47:19 +00:00
|
|
|
public function generateAdapterApiKey(): void
|
2017-09-07 03:53:25 +00:00
|
|
|
{
|
|
|
|
$this->adapter_api_key = bin2hex(random_bytes(50));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Authenticate the supplied adapter API key.
|
|
|
|
*
|
2019-01-31 17:54:17 +00:00
|
|
|
* @param string $api_key
|
2017-09-07 03:53:25 +00:00
|
|
|
*/
|
2021-04-23 22:12:47 +00:00
|
|
|
public function validateAdapterApiKey(string $api_key): bool
|
2017-09-07 03:53:25 +00:00
|
|
|
{
|
|
|
|
return hash_equals($api_key, $this->adapter_api_key);
|
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getDescription(): ?string
|
2017-01-24 00:17:50 +00:00
|
|
|
{
|
2017-08-17 18:28:48 +00:00
|
|
|
return $this->description;
|
|
|
|
}
|
2017-01-24 00:35:16 +00:00
|
|
|
|
2019-01-28 20:47:19 +00:00
|
|
|
public function setDescription(string $description = null): void
|
2017-08-17 18:28:48 +00:00
|
|
|
{
|
|
|
|
$this->description = $description;
|
2017-01-24 00:17:50 +00:00
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getUrl(): ?string
|
|
|
|
{
|
|
|
|
return $this->url;
|
|
|
|
}
|
2016-05-06 08:57:34 +00:00
|
|
|
|
2019-01-28 20:47:19 +00:00
|
|
|
public function setUrl(string $url = null): void
|
2017-08-17 18:28:48 +00:00
|
|
|
{
|
2020-03-29 07:16:41 +00:00
|
|
|
$this->url = $this->truncateString($url);
|
2017-08-17 18:28:48 +00:00
|
|
|
}
|
2017-04-23 20:37:10 +00:00
|
|
|
|
2018-11-26 08:16:55 +00:00
|
|
|
public function getGenre(): ?string
|
|
|
|
{
|
|
|
|
return $this->genre;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setGenre(?string $genre): void
|
|
|
|
{
|
2021-05-30 18:55:26 +00:00
|
|
|
$this->genre = $this->truncateNullableString($genre, 150);
|
2018-11-26 08:16:55 +00:00
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getRadioBaseDir(): ?string
|
|
|
|
{
|
|
|
|
return $this->radio_base_dir;
|
|
|
|
}
|
2017-01-24 00:17:50 +00:00
|
|
|
|
2020-03-29 07:29:29 +00:00
|
|
|
public function setRadioBaseDir(?string $newDir = null): void
|
2017-05-10 09:01:38 +00:00
|
|
|
{
|
2021-05-30 18:55:26 +00:00
|
|
|
$newDir = $this->truncateNullableString(trim($newDir));
|
2020-03-29 07:29:29 +00:00
|
|
|
|
|
|
|
if (empty($newDir)) {
|
2020-12-03 04:18:06 +00:00
|
|
|
$stationsBaseDir = Environment::getInstance()->getStationDirectory();
|
2020-03-29 07:29:29 +00:00
|
|
|
$newDir = $stationsBaseDir . '/' . $this->getShortName();
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->radio_base_dir = $newDir;
|
2017-05-10 09:01:38 +00:00
|
|
|
}
|
|
|
|
|
2020-11-10 03:06:48 +00:00
|
|
|
public function ensureDirectoriesExist(): void
|
2018-12-05 07:15:51 +00:00
|
|
|
{
|
2020-11-10 03:06:48 +00:00
|
|
|
if (null === $this->radio_base_dir) {
|
2021-04-23 22:12:47 +00:00
|
|
|
$this->setRadioBaseDir();
|
2020-11-10 03:06:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Flysystem adapters will automatically create the main directory.
|
2021-03-31 16:42:24 +00:00
|
|
|
$this->ensureDirectoryExists($this->getRadioBaseDir());
|
|
|
|
$this->ensureDirectoryExists($this->getRadioPlaylistsDir());
|
|
|
|
$this->ensureDirectoryExists($this->getRadioConfigDir());
|
|
|
|
$this->ensureDirectoryExists($this->getRadioTempDir());
|
2020-11-10 03:06:48 +00:00
|
|
|
|
|
|
|
if (null === $this->media_storage_location) {
|
|
|
|
$storageLocation = new StorageLocation(
|
|
|
|
StorageLocation::TYPE_STATION_MEDIA,
|
|
|
|
StorageLocation::ADAPTER_LOCAL
|
|
|
|
);
|
2021-03-31 16:42:24 +00:00
|
|
|
|
|
|
|
$mediaPath = $this->getRadioBaseDir() . '/media';
|
|
|
|
$this->ensureDirectoryExists($mediaPath);
|
|
|
|
$storageLocation->setPath($mediaPath);
|
2020-11-10 03:06:48 +00:00
|
|
|
|
|
|
|
$this->media_storage_location = $storageLocation;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (null === $this->recordings_storage_location) {
|
|
|
|
$storageLocation = new StorageLocation(
|
|
|
|
StorageLocation::TYPE_STATION_RECORDINGS,
|
|
|
|
StorageLocation::ADAPTER_LOCAL
|
|
|
|
);
|
2021-03-31 16:42:24 +00:00
|
|
|
|
|
|
|
$recordingsPath = $this->getRadioBaseDir() . '/recordings';
|
|
|
|
$this->ensureDirectoryExists($recordingsPath);
|
|
|
|
$storageLocation->setPath($recordingsPath);
|
2020-11-10 03:06:48 +00:00
|
|
|
|
|
|
|
$this->recordings_storage_location = $storageLocation;
|
|
|
|
}
|
2021-05-25 04:29:07 +00:00
|
|
|
|
|
|
|
if (null === $this->podcasts_storage_location) {
|
|
|
|
$storageLocation = new StorageLocation(
|
|
|
|
StorageLocation::TYPE_STATION_PODCASTS,
|
|
|
|
StorageLocation::ADAPTER_LOCAL
|
|
|
|
);
|
|
|
|
|
|
|
|
$podcastsPath = $this->getRadioBaseDir() . '/podcasts';
|
|
|
|
$this->ensureDirectoryExists($podcastsPath);
|
|
|
|
$storageLocation->setPath($podcastsPath);
|
|
|
|
|
|
|
|
$this->podcasts_storage_location = $storageLocation;
|
|
|
|
}
|
2018-12-05 07:15:51 +00:00
|
|
|
}
|
|
|
|
|
2021-03-31 16:42:24 +00:00
|
|
|
protected function ensureDirectoryExists(string $dirname): void
|
2020-05-12 00:32:41 +00:00
|
|
|
{
|
2021-03-31 16:42:24 +00:00
|
|
|
if (is_dir($dirname)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$visibilityConverter = new PortableVisibilityConverter();
|
|
|
|
$visibility = $visibilityConverter->defaultForDirectories();
|
|
|
|
if (!mkdir($dirname, $visibility, true) && !is_dir($dirname)) {
|
2021-04-23 22:12:47 +00:00
|
|
|
throw new RuntimeException(sprintf('Directory "%s" was not created', $dirname));
|
2021-03-31 16:42:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
clearstatcache(false, $dirname);
|
2020-05-12 00:32:41 +00:00
|
|
|
}
|
|
|
|
|
2020-11-10 03:06:48 +00:00
|
|
|
public function getRadioPlaylistsDir(): string
|
2018-12-05 07:15:51 +00:00
|
|
|
{
|
2020-11-10 03:06:48 +00:00
|
|
|
return $this->radio_base_dir . '/playlists';
|
2018-12-05 07:15:51 +00:00
|
|
|
}
|
|
|
|
|
2020-11-10 03:06:48 +00:00
|
|
|
public function getRadioConfigDir(): string
|
2018-11-02 18:44:01 +00:00
|
|
|
{
|
2020-11-10 03:06:48 +00:00
|
|
|
return $this->radio_base_dir . '/config';
|
2018-11-02 18:44:01 +00:00
|
|
|
}
|
|
|
|
|
2020-11-10 03:06:48 +00:00
|
|
|
public function getRadioTempDir(): string
|
2017-01-24 00:17:50 +00:00
|
|
|
{
|
2020-11-10 03:06:48 +00:00
|
|
|
return $this->radio_base_dir . '/temp';
|
2017-01-24 00:17:50 +00:00
|
|
|
}
|
|
|
|
|
2018-02-12 12:46:03 +00:00
|
|
|
public function getNowplaying(): ?Api\NowPlaying
|
2017-05-10 09:27:22 +00:00
|
|
|
{
|
2018-02-12 12:46:03 +00:00
|
|
|
if ($this->nowplaying instanceof Api\NowPlaying) {
|
|
|
|
return $this->nowplaying;
|
|
|
|
}
|
|
|
|
return null;
|
2017-05-10 09:27:22 +00:00
|
|
|
}
|
|
|
|
|
2019-01-28 20:47:19 +00:00
|
|
|
public function setNowplaying(Api\NowPlaying $nowplaying = null): void
|
2017-05-10 09:27:22 +00:00
|
|
|
{
|
2017-08-17 18:28:48 +00:00
|
|
|
$this->nowplaying = $nowplaying;
|
2018-02-12 12:46:03 +00:00
|
|
|
|
|
|
|
if ($nowplaying instanceof Api\NowPlaying) {
|
|
|
|
$this->nowplaying_timestamp = time();
|
|
|
|
}
|
2017-09-07 03:53:25 +00:00
|
|
|
}
|
|
|
|
|
2019-09-04 18:00:51 +00:00
|
|
|
public function getNowplayingTimestamp(): int
|
2019-03-01 00:46:01 +00:00
|
|
|
{
|
2019-09-04 18:00:51 +00:00
|
|
|
return (int)$this->nowplaying_timestamp;
|
2019-03-01 00:46:01 +00:00
|
|
|
}
|
|
|
|
|
2019-09-04 18:00:51 +00:00
|
|
|
public function setNowPlayingTimestamp(int $nowplaying_timestamp): void
|
2017-09-07 03:53:25 +00:00
|
|
|
{
|
2019-09-04 18:00:51 +00:00
|
|
|
$this->nowplaying_timestamp = $nowplaying_timestamp;
|
2017-05-10 09:27:22 +00:00
|
|
|
}
|
|
|
|
|
2020-10-14 22:19:31 +00:00
|
|
|
/**
|
|
|
|
* @return mixed[]|null
|
|
|
|
*/
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getAutomationSettings(): ?array
|
2017-01-24 00:17:50 +00:00
|
|
|
{
|
2017-08-17 18:28:48 +00:00
|
|
|
return $this->automation_settings;
|
2017-01-24 00:17:50 +00:00
|
|
|
}
|
|
|
|
|
2019-01-28 20:47:19 +00:00
|
|
|
public function setAutomationSettings(array $automation_settings = null): void
|
2017-08-17 18:28:48 +00:00
|
|
|
{
|
|
|
|
$this->automation_settings = $automation_settings;
|
|
|
|
}
|
2016-05-19 14:56:21 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getAutomationTimestamp(): ?int
|
|
|
|
{
|
|
|
|
return $this->automation_timestamp;
|
|
|
|
}
|
2016-08-30 06:28:56 +00:00
|
|
|
|
2019-01-28 20:47:19 +00:00
|
|
|
public function setAutomationTimestamp(int $automation_timestamp = null): void
|
2017-08-17 18:28:48 +00:00
|
|
|
{
|
|
|
|
$this->automation_timestamp = $automation_timestamp;
|
|
|
|
}
|
2016-08-30 06:28:56 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getEnableRequests(): bool
|
|
|
|
{
|
|
|
|
return $this->enable_requests;
|
|
|
|
}
|
2016-09-01 18:22:23 +00:00
|
|
|
|
2019-01-28 20:47:19 +00:00
|
|
|
public function setEnableRequests(bool $enable_requests): void
|
2017-08-17 18:28:48 +00:00
|
|
|
{
|
|
|
|
$this->enable_requests = $enable_requests;
|
|
|
|
}
|
2016-09-04 23:24:53 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getRequestDelay(): ?int
|
|
|
|
{
|
|
|
|
return $this->request_delay;
|
|
|
|
}
|
2017-04-14 21:03:59 +00:00
|
|
|
|
2019-01-28 20:47:19 +00:00
|
|
|
public function setRequestDelay(int $request_delay = null): void
|
2017-08-17 18:28:48 +00:00
|
|
|
{
|
|
|
|
$this->request_delay = $request_delay;
|
|
|
|
}
|
2016-09-01 18:22:23 +00:00
|
|
|
|
2019-01-28 20:47:19 +00:00
|
|
|
public function getRequestThreshold(): ?int
|
2017-08-17 18:28:48 +00:00
|
|
|
{
|
|
|
|
return $this->request_threshold;
|
|
|
|
}
|
2016-11-20 04:00:25 +00:00
|
|
|
|
2019-01-28 20:47:19 +00:00
|
|
|
public function setRequestThreshold(int $request_threshold = null): void
|
2017-08-17 18:28:48 +00:00
|
|
|
{
|
|
|
|
$this->request_threshold = $request_threshold;
|
|
|
|
}
|
2017-06-06 18:07:18 +00:00
|
|
|
|
2018-10-27 00:14:32 +00:00
|
|
|
public function getDisconnectDeactivateStreamer(): int
|
|
|
|
{
|
|
|
|
return $this->disconnect_deactivate_streamer;
|
|
|
|
}
|
|
|
|
|
2019-01-28 20:47:19 +00:00
|
|
|
public function setDisconnectDeactivateStreamer(int $disconnect_deactivate_streamer): void
|
2018-10-27 00:14:32 +00:00
|
|
|
{
|
|
|
|
$this->disconnect_deactivate_streamer = $disconnect_deactivate_streamer;
|
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getEnableStreamers(): bool
|
|
|
|
{
|
|
|
|
return $this->enable_streamers;
|
|
|
|
}
|
2015-01-02 08:16:54 +00:00
|
|
|
|
2019-01-28 20:47:19 +00:00
|
|
|
public function setEnableStreamers(bool $enable_streamers): void
|
2017-08-17 18:28:48 +00:00
|
|
|
{
|
2019-03-02 00:34:06 +00:00
|
|
|
if ($this->enable_streamers !== $enable_streamers) {
|
|
|
|
$this->setNeedsRestart(true);
|
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
$this->enable_streamers = $enable_streamers;
|
|
|
|
}
|
2015-01-02 08:16:54 +00:00
|
|
|
|
2018-02-03 21:54:12 +00:00
|
|
|
public function getIsStreamerLive(): bool
|
|
|
|
{
|
|
|
|
return $this->is_streamer_live;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setIsStreamerLive(bool $is_streamer_live): void
|
|
|
|
{
|
|
|
|
$this->is_streamer_live = $is_streamer_live;
|
|
|
|
}
|
|
|
|
|
2018-02-01 11:49:40 +00:00
|
|
|
public function getEnablePublicPage(): bool
|
2017-09-18 03:27:32 +00:00
|
|
|
{
|
2021-04-23 22:12:47 +00:00
|
|
|
return $this->enable_public_page && $this->isEnabled();
|
2017-09-18 03:27:32 +00:00
|
|
|
}
|
|
|
|
|
2019-01-28 20:47:19 +00:00
|
|
|
public function setEnablePublicPage(bool $enable_public_page): void
|
2017-09-18 03:27:32 +00:00
|
|
|
{
|
|
|
|
$this->enable_public_page = $enable_public_page;
|
|
|
|
}
|
|
|
|
|
2020-05-15 10:13:47 +00:00
|
|
|
public function getEnableOnDemand(): bool
|
|
|
|
{
|
|
|
|
return $this->enable_on_demand;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setEnableOnDemand(bool $enable_on_demand): void
|
|
|
|
{
|
|
|
|
$this->enable_on_demand = $enable_on_demand;
|
|
|
|
}
|
|
|
|
|
2021-01-05 06:43:01 +00:00
|
|
|
public function getEnableOnDemandDownload(): bool
|
|
|
|
{
|
|
|
|
return $this->enable_on_demand_download;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setEnableOnDemandDownload(bool $enable_on_demand_download): void
|
|
|
|
{
|
|
|
|
$this->enable_on_demand_download = $enable_on_demand_download;
|
|
|
|
}
|
|
|
|
|
2019-09-04 18:00:51 +00:00
|
|
|
public function isEnabled(): bool
|
|
|
|
{
|
|
|
|
return $this->is_enabled;
|
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getNeedsRestart(): bool
|
|
|
|
{
|
|
|
|
return $this->needs_restart;
|
|
|
|
}
|
2016-09-02 00:34:08 +00:00
|
|
|
|
2019-01-28 20:47:19 +00:00
|
|
|
public function setNeedsRestart(bool $needs_restart): void
|
2017-08-17 18:28:48 +00:00
|
|
|
{
|
|
|
|
$this->needs_restart = $needs_restart;
|
|
|
|
}
|
2017-05-11 05:48:38 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getHasStarted(): bool
|
|
|
|
{
|
|
|
|
return $this->has_started;
|
|
|
|
}
|
2015-01-02 08:16:54 +00:00
|
|
|
|
2019-01-28 20:47:19 +00:00
|
|
|
public function setHasStarted(bool $has_started): void
|
2017-08-17 18:28:48 +00:00
|
|
|
{
|
|
|
|
$this->has_started = $has_started;
|
|
|
|
}
|
|
|
|
|
2018-08-18 23:01:03 +00:00
|
|
|
public function getApiHistoryItems(): int
|
|
|
|
{
|
|
|
|
return $this->api_history_items ?? self::DEFAULT_API_HISTORY_ITEMS;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setApiHistoryItems(?int $api_history_items): void
|
|
|
|
{
|
|
|
|
$this->api_history_items = $api_history_items;
|
|
|
|
}
|
2019-01-28 20:47:19 +00:00
|
|
|
|
2019-05-13 21:25:36 +00:00
|
|
|
public function getTimezone(): string
|
|
|
|
{
|
|
|
|
if (!empty($this->timezone)) {
|
|
|
|
return $this->timezone;
|
|
|
|
}
|
|
|
|
|
2020-10-09 21:31:48 +00:00
|
|
|
return 'UTC';
|
2019-05-13 21:25:36 +00:00
|
|
|
}
|
|
|
|
|
2020-10-05 06:27:12 +00:00
|
|
|
public function getTimezoneObject(): DateTimeZone
|
2020-08-16 14:54:01 +00:00
|
|
|
{
|
2020-10-05 06:27:12 +00:00
|
|
|
return new DateTimeZone($this->getTimezone());
|
2020-08-16 14:54:01 +00:00
|
|
|
}
|
|
|
|
|
2019-05-13 21:25:36 +00:00
|
|
|
public function setTimezone(?string $timezone): void
|
|
|
|
{
|
|
|
|
$this->timezone = $timezone;
|
|
|
|
}
|
|
|
|
|
2020-05-03 01:28:08 +00:00
|
|
|
public function getDefaultAlbumArtUrl(): ?string
|
|
|
|
{
|
|
|
|
return $this->default_album_art_url;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string|null $default_album_art_url
|
|
|
|
*/
|
|
|
|
public function setDefaultAlbumArtUrl(?string $default_album_art_url): void
|
|
|
|
{
|
|
|
|
$this->default_album_art_url = $default_album_art_url;
|
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getHistory(): Collection
|
|
|
|
{
|
|
|
|
return $this->history;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getStreamers(): Collection
|
|
|
|
{
|
|
|
|
return $this->streamers;
|
|
|
|
}
|
|
|
|
|
2018-02-03 21:54:12 +00:00
|
|
|
public function getCurrentStreamer(): ?StationStreamer
|
|
|
|
{
|
|
|
|
return $this->current_streamer;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setCurrentStreamer(?StationStreamer $current_streamer = null): void
|
|
|
|
{
|
2020-02-12 01:18:41 +00:00
|
|
|
if (null !== $this->current_streamer || null !== $current_streamer) {
|
|
|
|
$this->current_streamer = $current_streamer;
|
|
|
|
}
|
2018-02-03 21:54:12 +00:00
|
|
|
}
|
|
|
|
|
2020-11-10 03:06:48 +00:00
|
|
|
public function getMediaStorageLocation(): StorageLocation
|
|
|
|
{
|
|
|
|
return $this->media_storage_location;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setMediaStorageLocation(StorageLocation $storageLocation): void
|
|
|
|
{
|
|
|
|
if (StorageLocation::TYPE_STATION_MEDIA !== $storageLocation->getType()) {
|
2021-04-23 22:12:47 +00:00
|
|
|
throw new InvalidArgumentException('Storage location must be for station media.');
|
2020-11-10 03:06:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$this->media_storage_location = $storageLocation;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getRecordingsStorageLocation(): StorageLocation
|
|
|
|
{
|
|
|
|
return $this->recordings_storage_location;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setRecordingsStorageLocation(StorageLocation $storageLocation): void
|
|
|
|
{
|
|
|
|
if (StorageLocation::TYPE_STATION_RECORDINGS !== $storageLocation->getType()) {
|
2021-04-23 22:12:47 +00:00
|
|
|
throw new InvalidArgumentException('Storage location must be for station live recordings.');
|
2020-11-10 03:06:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$this->recordings_storage_location = $storageLocation;
|
|
|
|
}
|
|
|
|
|
2021-05-25 04:29:07 +00:00
|
|
|
public function getPodcastsStorageLocation(): StorageLocation
|
|
|
|
{
|
|
|
|
return $this->podcasts_storage_location;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setPodcastsStorageLocation(StorageLocation $storageLocation): void
|
|
|
|
{
|
|
|
|
if (StorageLocation::TYPE_STATION_PODCASTS !== $storageLocation->getType()) {
|
|
|
|
throw new InvalidArgumentException('Storage location must be for station podcasts.');
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->podcasts_storage_location = $storageLocation;
|
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getPermissions(): Collection
|
|
|
|
{
|
|
|
|
return $this->permissions;
|
|
|
|
}
|
|
|
|
|
2020-11-10 03:06:48 +00:00
|
|
|
/**
|
|
|
|
* @return StationMedia[]|Collection
|
|
|
|
*/
|
|
|
|
public function getMedia(): Collection
|
|
|
|
{
|
|
|
|
return $this->media_storage_location->getMedia();
|
|
|
|
}
|
|
|
|
|
2020-10-19 10:41:15 +00:00
|
|
|
/**
|
|
|
|
* @return StationPlaylist[]|Collection
|
|
|
|
*/
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getPlaylists(): Collection
|
|
|
|
{
|
|
|
|
return $this->playlists;
|
|
|
|
}
|
|
|
|
|
2020-10-19 10:41:15 +00:00
|
|
|
/**
|
|
|
|
* @return StationMount[]|Collection
|
|
|
|
*/
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getMounts(): Collection
|
|
|
|
{
|
|
|
|
return $this->mounts;
|
|
|
|
}
|
|
|
|
|
2020-10-19 10:41:15 +00:00
|
|
|
/**
|
|
|
|
* @return StationRemote[]|Collection
|
|
|
|
*/
|
2018-09-09 18:23:03 +00:00
|
|
|
public function getRemotes(): Collection
|
|
|
|
{
|
|
|
|
return $this->remotes;
|
|
|
|
}
|
|
|
|
|
2018-02-12 12:46:03 +00:00
|
|
|
public function getWebhooks(): Collection
|
|
|
|
{
|
|
|
|
return $this->webhooks;
|
|
|
|
}
|
|
|
|
|
2020-01-14 03:49:50 +00:00
|
|
|
public function getSftpUsers(): Collection
|
2020-01-05 21:29:56 +00:00
|
|
|
{
|
2020-02-24 16:22:07 +00:00
|
|
|
return $this->sftp_users;
|
2020-01-05 21:29:56 +00:00
|
|
|
}
|
|
|
|
|
2020-08-16 14:54:01 +00:00
|
|
|
public function clearCache(): void
|
|
|
|
{
|
|
|
|
$this->nowplaying = null;
|
|
|
|
$this->nowplaying_timestamp = 0;
|
|
|
|
}
|
2021-05-30 18:55:26 +00:00
|
|
|
|
|
|
|
public function __toString(): string
|
|
|
|
{
|
|
|
|
$name = $this->getName();
|
|
|
|
if (null !== $name) {
|
|
|
|
return $name;
|
|
|
|
}
|
|
|
|
|
|
|
|
$id = $this->getId();
|
|
|
|
return (null !== $id) ? 'Station #' . $id : 'New Station';
|
|
|
|
}
|
2018-08-04 22:05:14 +00:00
|
|
|
}
|