Non Removed Torrents Plugin

jith45

Member
May 25, 2018
960
0
16
On my seedbox I have installed the remove and delete addon but some times people sharing the box just delete the torrent leaving random files just eating up hard drive space.

This Addon will create a new tab showing what files are in the Complete directory but no longer on the seedbox torrents list

First Create a folder in addons called nonremoved

now in that folder add these files

Init.js

Code:
var frame = null;

plugin.addNewTabWithURL = function( tabName, tabURL )
{
frame = document.createElement("IFRAME");
frame.name = "NonRemoved";

frame.src = tabURL;
frame.id = "NonRemoved";
frame.style.width = "100%";
frame.style.height = "100%";
frame.style.border = "0";
this.attachPageToTabs(frame,tabName);
}

theTabs.onShow = function(id)
{
if(id=="NonRemoved")
{
frame.src = "plugins/nonremoved/nonremoved.php";
}
}

plugin.addNewTabWithURL( "NonRemoved", "plugins/nonremoved/nonremoved.php" );


nonremoved.php

Code:
<?
require_once( '../../php/xmlrpc.php' );
require_once( '../../php/util.php' );
function getTorrentsname()
{

$req = new rXMLRPCRequest(new rXMLRPCCommand( "d.multicall", array( "", getCmd("d.get_name=")))
);
if($req->success())
{
$ret = array();
for($i=0; $i<count($req->val); $i+=1)
{
$ret[] =$req->val[$i];
}
return($ret);
}
return(false);
}

$directory="../../../Files"; // put your path to your complete download directory here or creat a smy link if path is out side your paths

$dirhandler = opendir($directory);
$nofiles=0;
while ($file = readdir($dirhandler)) {
if ($file != '.' && $file != '..' && $file != ".profile" && $file != ".bashrc" && $file != ".bash_logout")
{
$nofiles++;
$files[$nofiles]=$file;
}
}
closedir($dirhandler);
$result=getTorrentsname();
$available = array_diff($files, $result);
echo '' . implode('</br> ', $available);
?>

plugin.info

Code:
description: UnRemoved
author: Sponge
runlevel: 6
version: 1.0
remote: error
Now edit
Code:
$directory="../../../Files"; // put your path to your complete download directory here or creat a smy link if path is out side your pathsin the nonremoved.php

Now if all done right and you have the path to where your complete torrents are you should be a ok
(Note this may still show up torrents downloading to your server as well as they will not be in the complete directory)

Hope this helps someone else out certainly saves me lots of times manually searching

Sponge

Edited to fix relative paths :)
 

jith45

Member
May 25, 2018
960
0
16
awesome idea.

It would be nicer if it showed the dir where the file was found.

Also, the style of text doesn't quite match, and it is the first tab shown instead of logger, which i don't like...but:

I went ahead and made a tarball of it.

I will add it to this post

also, in the next version, could you add a conf.php
 

shwetha17

Member
May 24, 2018
785
0
16
this is really strange...it's showing 3 torrents i dont' even have or know where they could be....i dont' even reemember downloading 2 of them.


hrm, yes, something is wrong:


Malwarebytes.Anti-Malware.v1.46.Multilingual.WinAll.Incl.Keygen-CRD
30.Rock.S04E19.Argus.PROPER.HDTV.XviD-FQM
britains.got.talent.s04e01.ws.pdtv.xvid-c4tv.avi



These are 3 things i never downloaded

i can't find them anywhere on my system....so something strange is going on here
 

dsouvik215

Member
May 25, 2018
896
0
16
looking at it, it's because you have your url in the link.


basically, you have the "add a tab" code from elsewhere in the forums, and you need to change the url accordingly.


even after i fixed that, it doesnt' work for me.

I end up with this:


success()) { $ret = array(); for($i=0; $ival); $i+=1) { $ret[] =$req->val[$i]; } return($ret); } return(false); } $directory="/home/rtuser1/rtorrent/download"; // put your path to your complete download directory here or creat a smy link if path is out side your paths $dirhandler = opendir($directory); $nofiles=0; while ($file = readdir($dirhandler)) { if ($file != '.' && $file != '..' && $file != ".profile" && $file != ".bashrc" && $file != ".bash_logout") { $nofiles++; $files[$nofiles]=$file; } } closedir($dirhandler); $result=getTorrentsname(); $available = array_diff($files, $result); echo '' . implode('
', $available);


looking at the code you provide...it looks incomplete...
 

das329717

Member
May 25, 2018
928
0
16
Some points:
1) Don't forget to change this
Quote
author: dmrom​

to your nick or name.
2) Replace this fragment
Code:
$req = new rXMLRPCRequest(new rXMLRPCCommand( "d.multicall", array( "", "d.get_name="))
to
Code:
$req = new rXMLRPCRequest(new rXMLRPCCommand( "d.multicall", array( "", getCmd("d.get_name=")))
for correct command substitution for rTorrent > 0.8.6 (it use method "d.name" instead "d.get_name").
3) This
Code:
http://www.tasleech.com/rutorrent/plugins/nonremoved/nonremoved.phpis not correct at all. Try to use realtive path.
BTW, don't forget to defend your installation of ruTorrent with auth.
 

shwetha17

Member
May 24, 2018
785
0
16
Paths are now fixed to be realtive path

Changed the call to $req = new rXMLRPCRequest(new rXMLRPCCommand( "d.multicall", array( "", getCmd("d.get_name=")))

Quote
first tab shown instead of logger, which i don't like..​

Now fixed so not the deafult Tab

Have made all the changes to the orginal post sorry for any issues caused.

Wonslung when you changed the code to fix my orginal issues up only thing I can think of that would cause your error is that you missed a php tag <? and all the php script is being outputed as html
 

dsouvik215

Member
May 25, 2018
896
0
16
i didn't touch your original post


and for the record, it still looks like it's missing code.


look at your original post, it starts with a php code tag but doesn't have a closing tag. It's obviously missing something.
 

das329717

Member
May 25, 2018
928
0
16
I did not mean you edited my post you edited the code on your site to try and fix the relative path problem

I have updated my orginal post and have fixed a few issues so try the code from my orginal post again please

and inform me of any problems
 

shwetha17

Member
May 24, 2018
785
0
16
nope, still no good for me.

i get this:



success()) { $ret = array(); for($i=0; $ival); $i+=1) { $ret[] =$req->val[$i]; } return($ret); } return(false); } $directory="/home/rtuser1/Complete/"; // put your path to your complete download directory here or creat a smy link if path is out side your paths $dirhandler = opendir($directory); $nofiles=0; while ($file = readdir($dirhandler)) { if ($file != '.' && $file != '..' && $file != ".profile" && $file != ".bashrc" && $file != ".bash_logout") { $nofiles++; $files[$nofiles]=$file; } } closedir($dirhandler); $result=getTorrentsname(); $available = array_diff($files, $result); echo '' . implode('
', $available); ?>



and before you tell me there is something wrong with my php, if that were really true, i wouldn't be able to use rutorrent at all.
 

dsouvik215

Member
May 25, 2018
896
0
16
When is it supposed to update ?
As I have a blank tab with no info

Also , how does this work for multiple users ?
And does this work when you have all in categorie folders ?
 

das329717

Member
May 25, 2018
928
0
16
When is it supposed to update ?

Updates eveytime you click on the tab

Also , how does this work for multiple users ?

should work ok with multiuser as long as you have the correct path of where the completed downloads are found in the script

And does this work when you have all in categorie folders ?

Not as of yet sorry working on trying to get this to work. looking at reading the custom data and browsing those directories

As a test for the code replace nonremoved.php with this code this will show you whats read into each array to compare just good for testing also includes a test to see if the directory path exists

Code: [Select]
<?
require_once( '../../php/xmlrpc.php' );
require_once( '../../php/util.php' );

function getTorrentsname()
{
$req = new rXMLRPCRequest(new rXMLRPCCommand( "d.multicall", array( "", getCmd("d.get_name=")))
);
if($req->success())
{
$ret = array();
for($i=0; $i<count($req->val); $i+=1)
{
$ret[] =$req->val[$i];
}
return($ret);
}
return(false);
}

function print_r2($val){
echo '<pre>';
print_r($val);
echo '</pre>';
}

$directory="../../../path to where you complete files are"; // put your path to your complete download directory here or create a smy link if path if out side your paths this path on my server is jumping back to main html folder my dir structure is public_html/rutorrent/plugins/nonremoved/

if (file_exists($directory)) {
echo "The dir $directory exists";


$dirhandler = opendir($directory);
$nofiles=0;
while ($file = readdir($dirhandler)) {
if ($file != '.' && $file != '..' && $file != ".profile" && $file != ".bashrc" && $file != ".bash_logout")
{
$nofiles++;
$files[$nofiles]=$file;
}
}
closedir($dirhandler);
$result=getTorrentsname();

print "<h2>Files</h2>";
print_r2($files);

print "<h2>Torrents</h2>";
print_r2($result);

$available = array_diff($files, $result);
echo '' . implode('</br> ', $available);
} else {
echo "The dir $directory does not exist";
}
?>

Hope this helps out please post me back if not I have this plus quite a few other personal mods working on my seedbox and was hopping to share this idea to help others

Sponge
 

jith45

Member
May 25, 2018
960
0
16
Thanks ...

It seems to be working , as I see the msg that the DIR exists.

But as I have everything in the main dir in folders : APPS / Movies / Music and so on ... it does not work yet
But it is a nice add-on ... tx for sharing ..

if you have any more nice ones, I am always interested ;-)
 

shwetha17

Member
May 24, 2018
785
0
16
Ok Have the array of al the files in the directories even all the nested folders just need to work out the call to read the file names from the torrent

example tv show might have 20 rars I can get rtorrent to tell me the name of the show but i want rtorrent to tell me the name of the files in the torrent

Can Novik65 or someone in the know please give me the rXMLRPCCommand to call up all the file names in a torrent

Thanks sponge
 

dsouvik215

Member
May 25, 2018
896
0
16
$req = new rXMLRPCRequest(new rXMLRPCCommand( "f.multicall", array( $hash, "", getCmd("f.get_path=")));
 

das329717

Member
May 25, 2018
928
0
16
Thankyou Novik65

ok here is the new nonremoved.php file just replace in your plugin nonremoved folder

Code:
<?
require_once( '../../php/xmlrpc.php' );
require_once( '../../php/util.php' );

function getTorrentshash()
{
$req = new rXMLRPCRequest(new rXMLRPCCommand( "d.multicall", array( "", getCmd("d.get_hash=")))
);
if($req->success())
{
$ret = array();
for($i=0; $i<count($req->val); $i+=1)
{
$ret[] =$req->val[$i];
}
return($ret);
}
return(false);
}

function getTorrentsfiles($hash)
{
$req = new rXMLRPCRequest(new rXMLRPCCommand( "f.multicall", array( $hash, "", getCmd("f.get_path="))));

if($req->success())
{
$ret = array();
for($i=0; $i<count($req->val); $i+=1)
{
$arr = explode("/", $req->val[$i]);
$ret[] = $arr[0];
if ($arr[1] != "") $ret[] = $arr[1];
if ($arr[2] != "") $ret[] = $arr[2];
if ($arr[3] != "") $ret[] = $arr[3];
if ($arr[4] != "") $ret[] = $arr[4];
if ($arr[5] != "") $ret[] = $arr[5];
if ($arr[6] != "") $ret[] = $arr[6];
if ($arr[7] != "") $ret[] = $arr[7];
if ($arr[8] != "") $ret[] = $arr[8];
}

return($ret);
}
return(false);
}

function scan_Dir($dir) {
$arrfiles = array();
$test7 = array();
if (is_dir($dir)) {
if ($handle = opendir($dir)) {
chdir($dir);
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file != "*.r*") {
if (is_dir($file)) {
$arr = scan_Dir($file);
foreach ($arr as $value) {
$arrfiles[] = $value;
}
} else {
$arrfiles[] = $file;
}
}
}
chdir("../");
}
closedir($handle);
}
return $arrfiles;
}

function print_r2($val){
echo '<pre>';
print_r($val);
echo '</pre>';
}


$files2=scan_Dir('../../../Files'); // put your path to your complete download directory here or create a smy link if path is out side your paths

$hash=getTorrentshash();

foreach($hash as $hashs)
{
$files = getTorrentsfiles($hashs);
$result = array_merge((array)$result, (array)$files);
}

$available = array_diff($files2, $result);
echo '' . implode('</br> ', $available);

?>


Please change the path $files2=scan_Dir('../../../Files'); // put your path to your complete download directory here or create a smy link if path is out side your paths

This code will read all directories under the folder you supply and now reads all file names from torrents and compares these 2 to show you a more very accurate list of files you have not deleted

At this stage I do not have the path to these files listed this will be a feature ill try and addon soon

If some one can try this out and supply feedback would be appreciated
 

somus1735

Member
May 25, 2018
833
0
16
I have the blank tab again.

My torrents are in : /Home/rascalli/torrents/
Under here are all the folders

So I put down in the nonremoved.php : $files2=scan_Dir('/Home/rascalli/torrents/');
please confirm this is correct



EDIT ... I did a total update of rutorrent & now it seems to be working .. I see a lot of files now ;-) .. it's working now
 

shwetha17

Member
May 24, 2018
785
0
16
Ok did Some Updates on the plugin added paths to the files and created a config.php file to make it easier for people to debug and configure

Here are the two new scripts

nonremoved.php
Code:
<?php
require_once( &#39;../../php/xmlrpc.php&#39; );
require_once( &#39;../../php/util.php&#39; );
require_once( &#39;config.php&#39; );

function getTorrentshash()
{
$req = new rXMLRPCRequest(new rXMLRPCCommand( "d.multicall", array( "", getCmd("d.get_hash=")))
);
if($req->success())
{
$ret = array();
for($i=0; $i<count($req->val); $i+=1)
{
$ret[] =$req->val[$i];
}
return($ret);
}
return(false);
}

function getTorrentsfiles($hash)
{
$req = new rXMLRPCRequest(new rXMLRPCCommand( "f.multicall", array( $hash, "", getCmd("f.get_path="))));

if($req->success())
{
$ret = array();
for($i=0; $i<count($req->val); $i+=1)
{
$arr = explode("/", $req->val[$i]);
$ret[] = $arr[0];
if ($arr[1] != "") $ret[] = $arr[1];
if ($arr[2] != "") $ret[] = $arr[2];
if ($arr[3] != "") $ret[] = $arr[3];
if ($arr[4] != "") $ret[] = $arr[4];
if ($arr[5] != "") $ret[] = $arr[5];
if ($arr[6] != "") $ret[] = $arr[6];
if ($arr[7] != "") $ret[] = $arr[7];
if ($arr[8] != "") $ret[] = $arr[8];
}

return($ret);
}
return(false);
}

function scan_Dir($dir) {
$arrfiles = array();
if (is_dir($dir)) {
if ($handle = opendir($dir)) {
chdir($dir);
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$t++;
if (is_dir($file)) {
$arr = scan_Dir($file);
foreach ($arr as $value) {
$arrfiles[] = $dir."/".$value;
}
} else {
$arrfiles[] = $dir."/".$file;
}
}
}
chdir("../");
}
closedir($handle);
}
return $arrfiles;
}

function print_r2($val){
echo &#39;<pre>&#39;;
print_r($val);
echo &#39;</pre>&#39;;
}

$path=scan_Dir($dirpath);
$filename = array();
while (list ($key, $val) = each ($path)) {
$filename[$key] = basename($val);
$pathdir[$key] = dirname($val);
}
if ($debug == "true") print_r2($filename);
if ($debug == "true") print_r2($pathdir);
$hash=getTorrentshash();
foreach($hash as $hashs)
{
$files = getTorrentsfiles($hashs);
$result = array_merge((array)$result, (array)$files);
}
$available = array_diff($filename, $result);
if ($debug == "true") print_r2($available);
$compare=array_keys($available);
print "<table width=&#39;95%&#39; border=&#39;1&#39; align=&#39;center&#39;>";
while (list ($key, $val) = each ($compare)) {
print "<tr><td>Filename: ".$filename[$val]."</td>";
$trimmed = ltrim($pathdir[$val],$dirpath);
if ($trimmed == "") $trimmed = "Root Folder";
print "<td>path: ".$trimmed."</td></tr>";
}
print "</table>";

if ($debug == "true") print_r2($compare);

?>


And now craete a config.php in the same plugin folder as nonremoved.php

config.php
Code:
<?php
$dirpath = "../../../???????"; // replace the question marks with the path to your folder where your complete torrents are stored or create a sym link.
$debug ="false";
?>
Again any feedback or code enhancements people can think of would be appreciated.
 

dsouvik215

Member
May 25, 2018
896
0
16
O this looks nice
I now see the file and also the path
Maybe the clums need a bit of polishing, but it does what it needs to do







It only does not work for multiple users, as you see them the files from all users , I guess that is maybe something that needs a bit of work

I already tried to make a folder caled non_remoed , and put in there a link to users folder, but that did not help
 

das329717

Member
May 25, 2018
928
0
16
Quote
It only does not work for multiple users, as you see them the files from all users​


Probally the best thing to do is just have this addon installed for just the people that manage the box

Its hard to test multi user setup as I dont have my server set up this way. (but will look at setting up a home linux box in the next week for more development)