Giter VIP home page Giter VIP logo

php-deluge-console's Introduction

PHP-Deluge-Console

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

php-deluge-console's People

Contributors

jeankassio avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.