jalle19 / php-tvheadend
与 tvheadend 通信的库
0.3.0
2021-05-25 12:41 UTC
Requires
- ext-curl: *
- ext-json: *
- laminas/laminas-http: ^2.14
- monolog/monolog: ^1.12
- nategood/commando: 0.2.*
README
这是一个用于与 tvheadend 实例通信和控制的 PHP 库。到目前为止,它相当有限,它只支持我迄今为止需要的功能。它基于一个通用框架,其中每个类代表 tvheadend 中的一个模型,例如网络、复用器、频道等。该库使用 HTTP 客户端与 tvheadend 通信。如果需要,客户端可以被覆盖。
该库还包括一个基类,用于创建执行针对 tvheadend 的特定任务的 CLI 命令。要使用它,只需将此库包含到您的项目中,并扩展 Jalle19\tvheadend\cli\TvheadendCommand
类。基本命令提供了一种从用户请求开关和标志以及请求输入的方式。
安装
composer require jalle19/php-tvheadend
示例用法(库)
require_once('/path/to/vendor/autoload.php'); use Jalle19\tvheadend; // Create a new instance $tvheadend = new tvheadend\Tvheadend('localhost', 9981); // Create an IPTV network $network = new tvheadend\model\network\IptvNetwork(); $network->networkname = 'Test network'; $network->max_streams = 5; try { $tvheadend->createNetwork($network); } catch (tvheadend\exception\RequestFailedException $e) { die('Failed to create network'); } // Loop through all networks and print their respective names foreach ($tvheadend->getNetworks as $network) echo $network->networkname.PHP_EOL;
示例用法(命令)
// let's call this file command.php require_once(__DIR__.'/vendor/autoload.php'); new Jalle19\tvheadend\cli\TvheadendCommand();
使用 php command.php
运行时的输出
command.php
--help
Show the help page for this command.
--tvheadend-hostname <argument>
Required. The hostname where tvheadend is running
--tvheadend-http-port <argument>
The tvheadend HTTP port
--tvheadend-password <argument>
The tvheadend password
--tvheadend-username <argument>
The tvheadend username
许可证
该库根据 GNU GPL 版本 2 许可