ohnotnow/laravel-transmission
Composer 安装命令:
composer require ohnotnow/laravel-transmission
包简介
Laravel wrapper for the Transmission torrent server API
README 文档
README
WIP
Laravel API wrapper for Transmission
This is a (for now) very basic wrapper around the Transmission bittorrent client's API.
For now it only supports getting a list of all current torrents, fetching a specific torrent and adding a new torrent in 'paused' mode. This was all I needed for my purposes in transcopy.
If you want a plain PHP version without the Laravel stuff have a look at the underlying library.
Installing
Assuming you have composer available :
composer require ohnotnow/laravel-transmission
Assuming you are on Laravel 5.5+ the package should be auto-discovered. If not you'll have to manually add it to the Providers/Aliases to add to your config/app.php :
'providers' => [ ... Ohffs\LaravelTransmission\TransmissionServiceProvider::class, ... ], 'aliases' => [ ... 'Transmission' => Ohffs\LaravelTransmission\Transmission::class, ... ]
Usage
You need to set some environment variables first :
TRANSMISSION_HOST=127.0.0.1
TRANSMISSION_PORT=9091
TRANSMISSION_USERNAME=
TRANSMISSION_PASSWORD=
Then in a somewhere in your project :
use Ohffs\LaravelTransmission\Client; class Whatever { protected $transmission; public function __construct(Client $transmission) { $this->transmission = $transmission; } public function index() { return $this->transmission->all(); } public function show($id) { return $this->transmission->find($id); } }
You can also use the Transmission facade if you wish :
use Ohffs\LaravelTransmission\Transmission; // ... $allTorrents = Transmission::all(); $singleTorrent = Transmission::find(1);
The find() method returns a single TorrentEntry class, the all() method returns a collection of them. The data is in the format provided by Tranmissions API - so for example the 'percentDone' is given as a float from 0.0 to 1.0 so you'd have to multiply it by 100 to get a 'realistic' percentage. You can get the data from them :
$torrent = $this->transmission->find(1); echo $torrent->toArray(); /* 'name' => 'Some Exciting File', 'id' => 1, 'doneDate' => 0, 'eta' => 1000, 'haveValid' => 0, 'rateDownload' => 0, 'rateUpload' => 0, 'status' => 2, 'totalSize' => 364514248, 'downloadDir' => '/tmp/torrents', 'percentDone' => 0.3, */ // And you can also get those as attributes on the object, eg : echo $torrent->name; // 'Some Exciting File'
Using the collection from all() you can use all of Laravel's collection methods of course. For example, to get a list of torrents which are still downloading :
$stillDownloading = $this->transmission->all()->filter(function ($torrent, $key) { return $torrent->percentDone < 1; });
ohnotnow/laravel-transmission 适用场景与选型建议
ohnotnow/laravel-transmission 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 162 次下载、GitHub Stars 达 4, 最近一次更新时间为 2018 年 03 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 ohnotnow/laravel-transmission 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ohnotnow/laravel-transmission 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 162
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-03-03