mirror of
https://github.com/AzuraCast/AzuraCast.git
synced 2024-06-15 05:36:37 +00:00
Add ability to specify admin pw and load clients for remote relays.
This commit is contained in:
parent
027590dc54
commit
dbba8e3c00
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
use App\Entity\StationRemote;
|
||||
|
||||
return [
|
||||
|
@ -16,7 +17,7 @@ return [
|
|||
'deselected_text' => __('No'),
|
||||
'default' => true,
|
||||
'form_group_class' => 'col-sm-12',
|
||||
]
|
||||
],
|
||||
],
|
||||
|
||||
'type' => [
|
||||
|
@ -30,7 +31,7 @@ return [
|
|||
\App\Radio\Adapters::REMOTE_ICECAST => 'Icecast v2.4+',
|
||||
],
|
||||
'form_group_class' => 'col-sm-12',
|
||||
]
|
||||
],
|
||||
],
|
||||
|
||||
'display_name' => [
|
||||
|
@ -39,7 +40,7 @@ return [
|
|||
'label' => __('Display Name'),
|
||||
'description' => __('The display name assigned to this relay when viewing it on administrative or public pages. Leave blank to automatically generate one.'),
|
||||
'form_group_class' => 'col-md-6',
|
||||
]
|
||||
],
|
||||
],
|
||||
|
||||
'url' => [
|
||||
|
@ -53,7 +54,7 @@ return [
|
|||
),
|
||||
'required' => true,
|
||||
'form_group_class' => 'col-md-6',
|
||||
]
|
||||
],
|
||||
],
|
||||
|
||||
'mount' => [
|
||||
|
@ -66,7 +67,16 @@ return [
|
|||
'2'
|
||||
),
|
||||
'form_group_class' => 'col-md-6',
|
||||
]
|
||||
],
|
||||
],
|
||||
|
||||
'admin_password' => [
|
||||
'text',
|
||||
[
|
||||
'label' => __('Remote Station Administrator Password'),
|
||||
'description' => __('To retrieve detailed unique listeners and client details, an administrator password is often required.'),
|
||||
'form_group_class' => 'col-md-6',
|
||||
],
|
||||
],
|
||||
|
||||
'enable_autodj' => [
|
||||
|
@ -78,7 +88,7 @@ return [
|
|||
'deselected_text' => __('No'),
|
||||
'default' => 0,
|
||||
'form_group_class' => 'col-sm-12',
|
||||
]
|
||||
],
|
||||
],
|
||||
|
||||
],
|
||||
|
@ -101,7 +111,7 @@ return [
|
|||
],
|
||||
'default' => StationRemote::FORMAT_MP3,
|
||||
'form_group_class' => 'col-md-6',
|
||||
]
|
||||
],
|
||||
],
|
||||
|
||||
'autodj_bitrate' => [
|
||||
|
@ -120,7 +130,7 @@ return [
|
|||
],
|
||||
'default' => 128,
|
||||
'form_group_class' => 'col-md-6',
|
||||
]
|
||||
],
|
||||
],
|
||||
|
||||
'source_port' => [
|
||||
|
@ -129,7 +139,7 @@ return [
|
|||
'label' => __('Remote Station Source Port'),
|
||||
'description' => __('If the port you broadcast to is different from the one you listed in the URL above, specify the source port here.'),
|
||||
'form_group_class' => 'col-md-6',
|
||||
]
|
||||
],
|
||||
],
|
||||
|
||||
'source_mount' => [
|
||||
|
@ -138,7 +148,7 @@ return [
|
|||
'label' => __('Remote Station Source Mountpoint/SID'),
|
||||
'description' => __('If the mountpoint (i.e. <code>/radio.mp3</code>) or Shoutcast SID (i.e. <code>2</code>) you broadcast to is different from the one listed above, specify the source mount point here.'),
|
||||
'form_group_class' => 'col-md-6',
|
||||
]
|
||||
],
|
||||
],
|
||||
|
||||
'source_username' => [
|
||||
|
@ -147,7 +157,7 @@ return [
|
|||
'label' => __('Remote Station Source Username'),
|
||||
'description' => __('If you are broadcasting using AutoDJ, enter the source username here. This may be blank.'),
|
||||
'form_group_class' => 'col-md-6',
|
||||
]
|
||||
],
|
||||
],
|
||||
|
||||
'source_password' => [
|
||||
|
@ -156,7 +166,7 @@ return [
|
|||
'label' => __('Remote Station Source Password'),
|
||||
'description' => __('If you are broadcasting using AutoDJ, enter the source password here.'),
|
||||
'form_group_class' => 'col-md-6',
|
||||
]
|
||||
],
|
||||
],
|
||||
|
||||
'is_public' => [
|
||||
|
@ -168,7 +178,7 @@ return [
|
|||
'deselected_text' => __('No'),
|
||||
'default' => false,
|
||||
'form_group_class' => 'col-md-6',
|
||||
]
|
||||
],
|
||||
],
|
||||
|
||||
],
|
||||
|
@ -183,7 +193,7 @@ return [
|
|||
'type' => 'submit',
|
||||
'label' => __('Save Changes'),
|
||||
'class' => 'ui-button btn-lg btn-primary',
|
||||
]
|
||||
],
|
||||
],
|
||||
|
||||
],
|
||||
|
|
35
src/Entity/Migration/Version20200213052842.php
Normal file
35
src/Entity/Migration/Version20200213052842.php
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity\Migration;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20200213052842 extends AbstractMigration
|
||||
{
|
||||
public function getDescription() : string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema) : void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
$this->addSql('ALTER TABLE station_remotes ADD admin_password VARCHAR(100) DEFAULT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema) : void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
$this->addSql('ALTER TABLE station_remotes DROP admin_password');
|
||||
}
|
||||
}
|
|
@ -146,6 +146,15 @@ class StationRemote implements StationMountInterface
|
|||
*/
|
||||
protected $mount;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="admin_password", type="string", length=100, nullable=true)
|
||||
*
|
||||
* @OA\Property(example="password")
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $admin_password;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="source_port", type="smallint", nullable=true, options={"unsigned"=true})
|
||||
*
|
||||
|
@ -214,113 +223,71 @@ class StationRemote implements StationMountInterface
|
|||
$this->station = $station;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Station
|
||||
*/
|
||||
public function getStation(): Station
|
||||
{
|
||||
return $this->station;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Relay|null
|
||||
*/
|
||||
public function getRelay(): ?Relay
|
||||
{
|
||||
return $this->relay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Relay|null $relay
|
||||
*/
|
||||
public function setRelay(?Relay $relay): void
|
||||
{
|
||||
$this->relay = $relay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isVisibleOnPublicPages(): bool
|
||||
{
|
||||
return $this->is_visible_on_public_pages;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $is_visible_on_public_pages
|
||||
*/
|
||||
public function setIsVisibleOnPublicPages(bool $is_visible_on_public_pages): void
|
||||
{
|
||||
$this->is_visible_on_public_pages = $is_visible_on_public_pages;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getEnableAutodj(): bool
|
||||
{
|
||||
return $this->enable_autodj;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $enable_autodj
|
||||
*/
|
||||
public function setEnableAutodj(bool $enable_autodj): void
|
||||
{
|
||||
$this->enable_autodj = $enable_autodj;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|string
|
||||
*/
|
||||
public function getAutodjFormat(): ?string
|
||||
{
|
||||
return $this->autodj_format;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null|string $autodj_format
|
||||
*/
|
||||
public function setAutodjFormat(string $autodj_format = null): void
|
||||
{
|
||||
$this->autodj_format = $autodj_format;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getAutodjBitrate(): ?int
|
||||
{
|
||||
return $this->autodj_bitrate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $autodj_bitrate
|
||||
*/
|
||||
public function setAutodjBitrate(int $autodj_bitrate = null): void
|
||||
{
|
||||
$this->autodj_bitrate = $autodj_bitrate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCustomListenUrl(): ?string
|
||||
{
|
||||
return $this->custom_listen_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null|string $custom_listen_url
|
||||
*/
|
||||
public function setCustomListenUrl(string $custom_listen_url = null): void
|
||||
{
|
||||
$this->custom_listen_url = $this->_truncateString($custom_listen_url, 255);
|
||||
|
@ -332,17 +299,11 @@ class StationRemote implements StationMountInterface
|
|||
return $this->getSourceUsername();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|string
|
||||
*/
|
||||
public function getSourceUsername(): ?string
|
||||
{
|
||||
return $this->source_username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null|string $source_username
|
||||
*/
|
||||
public function setSourceUsername(?string $source_username): void
|
||||
{
|
||||
$this->source_username = $this->_truncateString($source_username, 100);
|
||||
|
@ -367,70 +328,56 @@ class StationRemote implements StationMountInterface
|
|||
return $password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|string
|
||||
*/
|
||||
public function getSourcePassword(): ?string
|
||||
{
|
||||
return $this->source_password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null|string $source_password
|
||||
*/
|
||||
public function setSourcePassword(?string $source_password): void
|
||||
{
|
||||
$this->source_password = $this->_truncateString($source_password, 100);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
*/
|
||||
public function setType(string $type): void
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|string
|
||||
*/
|
||||
public function getSourceMount(): ?string
|
||||
{
|
||||
return $this->source_mount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null|string $source_mount
|
||||
*/
|
||||
public function setSourceMount(?string $source_mount): void
|
||||
{
|
||||
$this->source_mount = $this->_truncateString($source_mount, 150);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|string
|
||||
*/
|
||||
public function getMount(): ?string
|
||||
{
|
||||
return $this->mount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null|string $mount
|
||||
*/
|
||||
public function setMount(?string $mount): void
|
||||
{
|
||||
$this->mount = $this->_truncateString($mount, 150);
|
||||
}
|
||||
|
||||
public function getAdminPassword(): ?string
|
||||
{
|
||||
return $this->admin_password;
|
||||
}
|
||||
|
||||
public function setAdminPassword(?string $admin_password): void
|
||||
{
|
||||
$this->admin_password = $admin_password;
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
public function getAutodjMount(): ?string
|
||||
{
|
||||
|
@ -452,17 +399,11 @@ class StationRemote implements StationMountInterface
|
|||
return parse_url($this->getUrl(), PHP_URL_HOST);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|string
|
||||
*/
|
||||
public function getUrl(): ?string
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null|string $url
|
||||
*/
|
||||
public function setUrl(?string $url): void
|
||||
{
|
||||
if (!empty($url) && substr($url, 0, 4) !== 'http') {
|
||||
|
@ -486,17 +427,11 @@ class StationRemote implements StationMountInterface
|
|||
return parse_url($this->getUrl(), PHP_URL_PORT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getSourcePort(): ?int
|
||||
{
|
||||
return $this->source_port;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $source_port
|
||||
*/
|
||||
public function setSourcePort(?int $source_port): void
|
||||
{
|
||||
if ((int)$source_port === 0) {
|
||||
|
@ -512,49 +447,31 @@ class StationRemote implements StationMountInterface
|
|||
return (Adapters::REMOTE_ICECAST !== $this->getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getIsPublic(): bool
|
||||
{
|
||||
return $this->is_public;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $is_public
|
||||
*/
|
||||
public function setIsPublic(bool $is_public)
|
||||
{
|
||||
$this->is_public = $is_public;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getListenersUnique(): int
|
||||
{
|
||||
return $this->listeners_unique;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $listeners_unique
|
||||
*/
|
||||
public function setListenersUnique(int $listeners_unique): void
|
||||
{
|
||||
$this->listeners_unique = $listeners_unique;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getListenersTotal(): int
|
||||
{
|
||||
return $this->listeners_total;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $listeners_total
|
||||
*/
|
||||
public function setListenersTotal(int $listeners_total): void
|
||||
{
|
||||
$this->listeners_total = $listeners_total;
|
||||
|
|
|
@ -96,7 +96,20 @@ abstract class AbstractRemote
|
|||
$np_adapter = new $adapter_class($remote->getUrl(), $this->http_client);
|
||||
|
||||
try {
|
||||
$adminPassword = $remote->getAdminPassword();
|
||||
if (!empty($adminPassword)) {
|
||||
$np_adapter->setAdminPassword($adminPassword);
|
||||
}
|
||||
|
||||
$np = $np_adapter->getNowPlaying($remote->getMount());
|
||||
if (empty($np)) {
|
||||
return $np_aggregate;
|
||||
}
|
||||
|
||||
$np['listeners']['clients'] = ($include_clients && !empty($adminPassword))
|
||||
? $np_adapter->getClients($remote->getMount(), true)
|
||||
: null;
|
||||
|
||||
$this->logger->debug('NowPlaying adapter response', ['response' => $np]);
|
||||
|
||||
return $this->_mergeNowPlaying(
|
||||
|
|
Loading…
Reference in New Issue
Block a user