Non Removed Torrents Plugin

somus1735

Member
May 25, 2018
833
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 looks like it could be a useful plugin, but for this problem you could just add something like the following to your .rtorrent.rc:
Code
on_erase = rm_files,"execute={rm,-rf,--,$d.get_base_path=}"This will delete the data for all erased torrents, so users can't make mistakes.

Of course, if you need to be able to erase torrents without removing data the erasedata plugin coupled with Sponge's plugin would be a better solution.
 

shwetha17

Member
May 24, 2018
785
0
16
This looks like it could be a useful plugin, but for this problem you could just add something like the following to your .rtorrent.rc:
Code
on_erase = rm_files,"execute={rm,-rf,--,$d.get_base_path=}"This will delete the data for all erased torrents, so users can't make mistakes.
This will not work for torrents, which was closed since rtorrent start. In rtorrent 0.8.6 $d.get_base_path return empty string for such torrents.
 

das329717

Member
May 25, 2018
928
0
16
Is there a way to put the listings in alphabetical order?

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 :)
 

somus1735

Member
May 25, 2018
833
0
16
I have never used this plugin but to simply get the list sorted alphabetically you should be able to just change this at the end of nonremoved.php

Code:
closedir($dirhandler);
$result=getTorrentsname();
$available = array_diff($files, $result);
sort($available);
echo '' . implode('</br> ', $available);
?>
 

shwetha17

Member
May 24, 2018
785
0
16
Thanks for this plugin!
It does the job!
Request:
1. Option to exclude files and directories inside $dirpath using config

Anyways, if someone wants to exclude a directory do this:
change
Code:
if ($file != "." && $file != "..")to
Code:
if ($file != "." && $file != ".." && $file !="dirname_here")
EDIT: I messed around a bit with nonremoved.php (see screenshot in attachment)
I don't code php so my additions are simple: Output closer to my liking and a dir I did not want excluded.
If you like here is the whole nonremoved.php a bit altered (to change/add an exclusion for a dir/file and change the color of the letters, see commented lines)
Code:
<?php
require_once( '../../php/xmlrpc.php' );
require_once( '../../php/util.php' );
require_once( 'config.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();
if (is_dir($dir)) {
if ($handle = opendir($dir)) {
chdir($dir);
while (false !== ($file = readdir($handle))) {
//Do not show dir1 --->change dir1 to a dir you wish to hide
//original line was the following
// if ($file != "." && $file != ".." ) {
if ($file != "." && $file != ".." && $file != "dir1" ) {
$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 '<pre>';
print_r($val);
echo '</pre>';
}

$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);
//Header color is 336699, text color is FFFFFF --> change this (I use a dark theme and wanted white text)
print "<table width='90%'; border='1' align='center'>";
print "<tr>";
print "<th style='font-size: 13px; font-family: Tahoma, Arial, Helvetica, sans-serif; color:#336699'>Filename</th>";
print "<th style='font-size: 13px; font-family: Tahoma, Arial, Helvetica, sans-serif; color:#336699'>Path</th>";
print "</tr>";
print "<tr>";
while (list ($key, $val) = each ($compare)) {
print "<td style='font-size: 11px; font-family: Tahoma, Arial, Helvetica, sans-serif; color:#FFFFFF'> ".$filename[$val]."</td>";
$trimmed = ltrim($pathdir[$val],$dirpath);
if ($trimmed == "") $trimmed = "Root folder";
print "<td style='font-size: 11px; font-family: Tahoma, Arial, Helvetica, sans-serif; color:#FFFFFF'> ".$trimmed."</td></tr>";
}
print "</table>";

if ($debug == "true") print_r2($compare);
?>
This plugin would be perfect if someone could take over it. It needs, to be perfect:
1. Multilingual setup (this I might look into how it can be done)
2. Fonts and colors to not be hardcoded
3. A config to exclude dirs/files
4. Posibility to delete the orphan files from within rutorrent