当前位置: 首页 > news >正文

AzuraCast:自托管一体化网络电台管理套件

AzuraCast:自托管一体化网络电台管理套件

项目描述

AzuraCast是一个自托管、一体化的网络电台管理套件。通过其简单的安装程序和强大直观的Web界面,您可以在几分钟内启动一个完全可用的网络电台。AzuraCast适用于各种类型和规模的网络电台,旨在运行在最经济的VPS虚拟主机上。

功能特性

  • 完整的电台管理:提供从流媒体广播到节目编排的完整解决方案
  • 多格式支持:支持Icecast、HLS等多种流媒体协议和格式
  • 智能自动DJ:支持播放列表调度、歌曲请求和实时流媒体
  • 共享编码器:可选功能,可在具有相同比特率和格式的多个流之间共享编码器,显著降低CPU消耗
  • Liquidsoap 2.4.0集成:更新的流媒体后端,包含关键错误修复和改进
  • 用户权限管理:细粒度的权限控制系统,支持全局和电台级别权限
  • API接口:完整的RESTful API,支持第三方集成
  • 多语言支持:支持多种语言界面
  • 主题定制:可定制的用户界面主题
  • 备份恢复:完整的数据库和媒体备份恢复功能

安装指南

系统要求

  • PHP 8.1或更高版本
  • MariaDB/MySQL数据库
  • Redis缓存(可选但推荐)
  • 足够的磁盘空间用于媒体存储

安装步骤

  1. 下载项目

    git clone https://github.com/AzuraCast/AzuraCast.git
    cd AzuraCast
    
  2. 运行安装程序

    ./docker.sh setup
    
  3. 或使用传统安装方式

    php bin/console azuracast:setup
    
  4. 访问管理界面
    安装完成后,通过浏览器访问您的服务器IP地址即可开始配置。

Docker安装(推荐)

AzuraCast提供完整的Docker支持,包含所有必要的依赖项:

curl -fsSL https://raw.githubusercontent.com/AzuraCast/AzuraCast/main/docker.sh > docker.sh
chmod a+x docker.sh
./docker.sh setup

使用说明

基本配置

  1. 创建第一个电台

    • 登录管理后台
    • 点击"添加电台"
    • 配置基本信息、流媒体设置和自动DJ
  2. 上传媒体文件

    • 通过Web界面上传音乐文件
    • 或使用SFTP直接上传到媒体目录
  3. 配置播放列表

    • 创建定时播放列表
    • 设置播放规则和顺序
    • 配置交叉淡入淡出效果

API使用示例

获取当前播放信息:

curl https://your-azuracast-instance.com/api/nowplaying

获取电台列表:

curl https://your-azuracast-instance.com/api/stations

命令行工具

AzuraCast提供丰富的命令行工具:

# 同步当前播放信息
php bin/console azuracast:sync:nowplaying# 备份系统
php bin/console azuracast:backup /path/to/backup.zip# 恢复备份
php bin/console azuracast:restore /path/to/backup.zip# 清除缓存
php bin/console azuracast:cache:clear

核心代码

权限控制系统

<?php
declare(strict_types=1);namespace App;final class Acl
{public function __construct(private readonly ReloadableEntityManagerInterface $em,private readonly EventDispatcherInterface $dispatcher) {$this->reload();}/*** 检查用户是否具有特定权限*/public function userAllowed(User $user, string $permission, ?Station $station = null): bool{$userRoles = $user->roles;foreach ($userRoles as $role) {if ($this->roleHasPermission($role, $permission, $station)) {return true;}}return false;}/*** 重新加载ACL缓存*/public function reload(): void{// 从数据库加载权限配置$sql = $this->em->createQuery(<<<'DQL'SELECT IDENTITY(rp.station) AS station_id, IDENTITY(rp.role) AS role_id, rp.action_name FROM App\Entity\RolePermission rpDQL);$this->actions = [];foreach ($sql->toIterable() as $row) {if ($row['station_id']) {$this->actions[$row['role_id']]['stations'][$row['station_id']][] = $row['action_name'];} else {$this->actions[$row['role_id']]['global'][] = $row['action_name'];}}}
}

当前播放缓存系统

<?php
declare(strict_types=1);namespace App\Cache;final class NowPlayingCache
{private const int NOWPLAYING_CACHE_TTL = 180;/*** 设置电台的当前播放信息*/public function setForStation(Station $station,?NowPlaying $nowPlaying): void {$this->populateLookupCache($station);$stationCacheItem = $this->getStationCache($station->short_name);$stationCacheItem->set($nowPlaying);$stationCacheItem->expiresAfter(self::NOWPLAYING_CACHE_TTL);$this->cache->saveDeferred($stationCacheItem);$this->cache->commit();}/*** 获取所有电台的当前播放信息*/public function getForAllStations(bool $publicOnly = false): array{$lookupCacheItem = $this->getLookupCache();if (!$lookupCacheItem->isHit()) {return [];}$np = [];$lookupCache = (array)$lookupCacheItem->get();foreach ($lookupCache as $stationInfo) {if ($publicOnly && !$stationInfo['is_public']) {continue;}$npRowItem = $this->getStationCache($stationInfo['short_name']);$npRow = $npRowItem->isHit() ? $npRowItem->get() : null;if ($npRow instanceof NowPlaying) {$np[] = $npRow;}}return $np;}
}

自定义资源管理系统

<?php
declare(strict_types=1);namespace App\Assets;abstract class AbstractCustomAsset implements CustomAssetInterface
{/*** 获取资源路径*/public function getPath(): string{$pattern = sprintf($this->getPattern(), '');return $this->getBasePath() . '/' . $pattern;}/*** 获取资源URL*/public function getUrl(): string{$path = $this->getPath();if (is_file($path)) {$pattern = $this->getPattern();$mtime = filemtime($path);return $this->getBaseUrl() . '/' . sprintf($pattern,'.' . $mtime);}return $this->getDefaultUrl();}/*** 上传资源*/public function upload(ImageInterface $image, string $mimeType): void{$newImage = clone $image;$newImage->resizeDown(1500, 1500);$this->delete();$patterns = $this->getPatterns();[$pattern, $encoder] = $patterns[$mimeType] ?? $patterns['default'];$destPath = $this->getPathForPattern($pattern);$this->ensureDirectoryExists(dirname($destPath));$newImage->encode($encoder)->save($destPath);}
}

消息队列处理系统

<?php
declare(strict_types=1);namespace App\Console\Command\MessageQueue;final class ProcessCommand extends AbstractSyncCommand
{protected function execute(InputInterface $input, OutputInterface $output): int{$this->logToExtraFile('app_worker.log');$runtime = Types::int($input->getArgument('runtime'));$workerName = Types::stringOrNull($input->getOption('worker-name'), true);$this->logger->notice('Starting new Message Queue worker process.', ['runtime' => $runtime,'workerName' => $workerName,]);// 配置消息队列接收器$receivers = $this->queueManager->getTransports();// 添加事件订阅者$this->eventDispatcher->addServiceSubscriber(ClearEntityManagerSubscriber::class);$this->eventDispatcher->addServiceSubscriber(LogWorkerExceptionSubscriber::class);// 设置工作器超时$this->eventDispatcher->addSubscriber(new StopWorkerOnTimeLimitListener($runtime, $busLogger));try {$worker = new Worker($receivers, $this->messageBus, $this->eventDispatcher, $busLogger);$worker->run();} catch (Throwable $e) {$this->logger->error('Message queue error: ' . $e->getMessage(), ['workerName' => $workerName,'exception' => $e,]);return 1;}return 0;}
}

更多精彩内容 请关注我的个人公众号 公众号(办公AI智能小助手)
对网络安全、黑客技术感兴趣的朋友可以关注我的安全公众号(网络安全技术点滴分享)

公众号二维码

公众号二维码

http://www.zskr.cn/news/50558.html

相关文章:

  • 019数据结构之栈——算法备赛 - 实践
  • GESP考试报名附考试报名流程
  • 字节序浅析
  • 2025 最新无缝钢管厂家推荐榜:国际测评认证 + 技术创新 + 全场景适配权威指南大口径无缝钢管/16Mn 无缝钢管/定制无缝钢管/厚壁无缝钢管公司推荐
  • 2025年硫酸钠流化床干燥机源头厂家权威推荐榜单:调味品振动流化床干燥机/大豆纤维流化床干燥机/味精振动流化床干燥机源头厂家精选
  • MX Round 24 解题报告
  • 2025年目字扣订制厂家权威推荐榜单:塑料扣具/箱包插扣/五金插扣源头厂家精选
  • # 第10章 指针和结构体
  • 2025年全自动无屑切割倒角一体机实力厂家权威推荐榜单:自动化切割倒角一体机/切割倒角一体机/自动切割倒角一体机源头厂家精选
  • 2025 年 11 月喷漆废水处理工艺,喷漆废水处理技术改造,喷漆废水处理运维服务公司最新推荐,聚焦资质、案例、售后的五家机构深度解读
  • 2025 年 11 月喷漆废水处理设备,喷漆废水处理药剂,喷漆废水处理系统厂家最新推荐,聚焦资质、案例、售后的五家机构深度解读!
  • 2025 最新喷漆废水处理公司推荐!喷漆废水处理设备 / 药剂 / 工艺 / 循环回用系统优质品牌榜单,含技术改造与运维服务厂家优选
  • 完整教程:VScode 入门(设置篇)
  • 微服务架构中的 Token 工作机制详解
  • [KaibaMath]1023 柯西不等式的简洁证明
  • 2025 最新网架厂家权威排行榜:焊接球 / 螺栓球 / 大跨度等多类型网架实力企业最新推荐
  • WEB集群-HTTP概述与Nginx部署
  • BBS伪随机数生成器
  • 11.15模拟赛
  • 2025年RS485红外线测温仪源头厂家权威推荐榜单:在线红外测温仪/20mA红外线测温仪/红外线测温仪变送器源头厂家精选
  • P14508 猜数游戏 guess
  • 用HBuilder建立查询天气的网页
  • fanuc 双安检实验指导书
  • 1115noip模拟赛
  • 2025年毕业论文救星:6款免费AI写论文工具实测推荐
  • 2025 最新推荐!护栏厂家实力榜单,国际协会认证优质品牌,市政 / 铁路 / 桥梁专用护栏制造厂精选
  • 序列密码算法RC4的实现与攻击
  • arch配置swap分区并做休眠设置
  • 2025 年结晶装备厂家最新推荐榜:连续结晶器、煤化工蒸发设备、盐硝分离器等工业核心装备权威品牌指南多效蒸发/硫酸钠蒸发结晶器/煤化工盐硝分离器公司推荐
  • 2025 最新新能源装备厂家企业品牌权威推荐榜,含芒硝结晶器/碳化热解设备/碳酸锂碳化提纯设备优质厂商