jeankassio/php-deluge-console 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jeankassio/php-deluge-console

Composer 安装命令:

composer require jeankassio/php-deluge-console

包简介

Connection to Deluge client/server console via PHP, with pre-established functions and open console to send commands.

README 文档

README

Connection to Deluge-Torrent client/server console via PHP, with pre-established functions and open console to send commands.

Total Downloads License: MIT

Php package from deluge console

Installation:

 composer require jeankassio/php-deluge-console

How to use:

require dirname(__FILE__) . '/vendor/autoload.php';

use JeanKassio\Deluge\Console;
use JeanKassio\Deluge\DelugeFunctions\BasicFunctions;
 
 /*
 Here you configure the connection settings.
 */
 
 $config = array(
	'console_command' => 'deluge-console', 	//optional, default is 'deluge-console'
	'host' => 'localhost',  		//optional, default is 'localhost'
	'port' => '58846',  			//optional, default is '58846'
	'user' => 'username',
	'pass' => 'password',
);

/*
Instancing a new Console
*/

$console = new Console($config);

/*
Here you call the method you want.
Let's in this example add a new torrent.
*/

/*
The first parameter is the Path where the file we are going to download will be saved.
The second parameter is the Magnet Link or the location where the .torrent file is stored.
*/
  
$id = 0; //Get id value from something
$id++;
$name = "file.torrent";
$c_torrent = dirname(__FILE__, 2) . "/content/torrent/$name";
$path = dirname(__FILE__, 2) . "/content/download/$id/";
		
if (!file_exists($path)) {
  mkdir($path, 0777, true); //Here I am creating a directory to save my file
  chmod($path, 0777);       //Here I am setting the permissions to 777, this is the permission level that Deluge needs so that the download can start normally.
}
  
/*
Here I am finally submitting the information and adding the torrent to Deluge
*/

$response = (new BasicFunctions($console))->addtorrent($path, $c_torrent);
 

Other existing methods

Get torrent list

require dirname(__FILE__) . '/vendor/autoload.php';

use JeanKassio\Deluge\Console;
use JeanKassio\Deluge\DelugeFunctions\BasicFunctions;

$config = array(
	'console_command' => 'deluge-console', 	//optional, default is 'deluge-console'
	'host' => 'localhost',  		//optional, default is 'localhost'
	'port' => '58846',  			//optional, default is '58846'
	'user' => 'username',
	'pass' => 'password',
);

$console = new Console($config);

$torrents = (new BasicFunctions($console))->torrentList();

foreach($torrents as $torrent){

	var_dump($torrent);			

}

Get a single Torrent

require dirname(__FILE__) . '/vendor/autoload.php';

use JeanKassio\Deluge\Console;
use JeanKassio\Deluge\DelugeFunctions\BasicFunctions;

$config = array(
	'console_command' => 'deluge-console', 	//optional, default is 'deluge-console'
	'host' => 'localhost',  		//optional, default is 'localhost'
	'port' => '58846',  			//optional, default is '58846'
	'user' => 'username',
	'pass' => 'password',
);

$console = new Console($config);

$torrent_id = "9c62d55c744642ef3f6f6daa3448055fb490a12e";

$torrent = (new BasicFunctions($console))->torrent($torrent_id);

var_dump($torrent);

Console, to make your own calls

require dirname(__FILE__) . '/vendor/autoload.php';

use JeanKassio\Deluge\Console;
use JeanKassio\Deluge\DelugeFunctions\BasicFunctions;

$config = array(
	'console_command' => 'deluge-console', 	//optional, default is 'deluge-console'
	'host' => 'localhost',  		//optional, default is 'localhost'
	'port' => '58846',  			//optional, default is '58846'
	'user' => 'username',
	'pass' => 'password',
);

$console = new Console($config);

$command = "status";

$response = (new BasicFunctions($console))->console($command);

var_dump($response);

New Methods

All these functions always return null

require dirname(__FILE__) . '/vendor/autoload.php';

use JeanKassio\Deluge\Console;
use JeanKassio\Deluge\DelugeFunctions\BasicFunctions;

$config = array(
	'console_command' => 'deluge-console', 	//optional, default is 'deluge-console'
	'host' => 'localhost',  		//optional, default is 'localhost'
	'port' => '58846',  			//optional, default is '58846'
	'user' => 'username',
	'pass' => 'password',
);

$console = new Console($config);

$bFunction = new BasicFunctions($console);


$bFunction->pause(true); //Pause all torrents

$bFunction->pause(false, array("9c62d55c744642ef3f6f6daa3448055fb490a12e","57a30a85b4a8375fc7a05a05c5f47e28b34da087")); //Pause only torrents listed with your ID



$bFunction->recheck(true); //Recheck on all torrents

$bFunction->recheck(false, array("9c62d55c744642ef3f6f6daa3448055fb490a12e","57a30a85b4a8375fc7a05a05c5f47e28b34da087")); //Recheck only on torrents listed with your ID



$bFunction->resume(true); //Resume all torrents

$bFunction->resume(false, array("9c62d55c744642ef3f6f6daa3448055fb490a12e","57a30a85b4a8375fc7a05a05c5f47e28b34da087")); //Resume only torrents listed with your ID



$bFunction->remove(array("9c62d55c744642ef3f6f6daa3448055fb490a12e","57a30a85b4a8375fc7a05a05c5f47e28b34da087")); //Delete the torrent without deleting the files

$bFunction->remove(array("9c62d55c744642ef3f6f6daa3448055fb490a12e","57a30a85b4a8375fc7a05a05c5f47e28b34da087"), true); //Delete the torrent and the files



Package modification of deluge-php

jeankassio/php-deluge-console 适用场景与选型建议

jeankassio/php-deluge-console 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 25 次下载、GitHub Stars 达 2, 最近一次更新时间为 2022 年 08 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 jeankassio/php-deluge-console 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 jeankassio/php-deluge-console 我们能提供哪些服务?
定制开发 / 二次开发

基于 jeankassio/php-deluge-console 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 25
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 8
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-08-19