systemart / rtgui

Automatically exported from code.google.com/p/rtgui
0 stars 0 forks source link

Allow upload to watch_directory #14

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The feature to add a torrent from a URL is nice, but some sites forwards
the URL to another URL and it seems that rtGui isn't too fond of that.

It would be nice to have an upload box that allows you to send a .torrent
to the watch_directory as specified in the .rtorrent.rc file. That way
rtorrent will load the torrent as expected. 

I've looked into the system.listMethods but haven't found the
watch_directory listed in the obvious places...

Original issue reported on code.google.com by clkr...@gmail.com on 7 Feb 2008 at 5:54

GoogleCodeExporter commented 9 years ago
Why not save the .torrent files directly to the watch_directory?

You can export the watch_directory via samba so you can save .torrents from 
your 
Windoze machines and have rTorrent load them directly.  I can't see the 
advantage of 
doing it via rtGui...

Original comment by lemonbe...@gmail.com on 7 Feb 2008 at 7:30

GoogleCodeExporter commented 9 years ago
This is what I currently do. But I could be somewhere else where I do not want 
to vpn
to the server and just upload a torrent anyway.

Perhaps you do not see an advantage, but for some, there actually is an 
advantage.

Original comment by clkr...@gmail.com on 8 Feb 2008 at 2:39

GoogleCodeExporter commented 9 years ago
I actually implemented it myself, you can see the screenshot at
http://www.aijaa.com/img/b/00012/1530510.jpg

I also added "Seed torrent", which applies rtorrent_fast_resume data to the 
.torrent
file, so it doesn't need to be hash checked.

Send me an email to karri(at)wippies.fi, I can tell you how to add that 
yourself.

Original comment by Mim...@gmail.com on 12 Feb 2008 at 11:14

GoogleCodeExporter commented 9 years ago
I have tried Mimmus's patch and it does work great! His implementation only 
requires
a minor addition of code and should probably be included in future release, if 
only
to please people like me.

And hey, it's one more feature!

Cheers!

Original comment by clkr...@gmail.com on 14 Feb 2008 at 6:17

GoogleCodeExporter commented 9 years ago
Hi Mimmus,
Can you post the code here?  I'll incorporate it into next release.
Cheers
Simon

Original comment by lemonbe...@gmail.com on 14 Feb 2008 at 8:09

GoogleCodeExporter commented 9 years ago
This goes to index.php:

echo "<td align=right width=26% class='mediumtext'>";
echo "<form enctype=multipart/form-data action=up.php method=POST>";
echo "Get torrent: ";
echo "<input name=userfile type=file size=25>";
echo "<input type=submit value=Add>";
echo "</form><br>";
echo "</td>";

And this is a file up.php, which I refer to in index.php:

<?php

$uploaddir = '/var/www/filut/tor/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);

if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
header("Location: index.php");
} else {
echo "Error.\n";
}

?>

$uploaddir -variable needs to be edited to match rTorrent watch directory. As 
you can
see, my script is very basic, it doesn't check that the uploaded file is a 
.torrent.
You can edit it if you want, I actually even don't know how to do it.

Original comment by Mim...@gmail.com on 15 Feb 2008 at 7:18

GoogleCodeExporter commented 9 years ago
Fixed in 0.2.3

Original comment by lemonbe...@gmail.com on 3 Mar 2008 at 8:18

GoogleCodeExporter commented 9 years ago
This is better to realize without using "watch_directory". Sample code:

<?php
...
function uploadTorrent($fileU, $dir)
{
    $uploadfile = DIR_EXEC . DIR_TORRENTS . basename($fileU['name']);
    if (!is_writable(DIR_EXEC . DIR_TORRENTS)) {
        $this->addMessage($this->_str['err_add_dir']);
        return false;
    }
    if (file_exists($uploadfile)) {
        $this->addMessage($this->_str['err_add_file']);
        return false;
    }

    $res[] = move_uploaded_file($fileU['tmp_name'], $uploadfile);
    chmod($uploadfile, PERM_TORRENTS);

    $message = new xmlrpcmsg("set_directory", array(new xmlrpcval($dir, 'string')));
    $result1 = $this->client->send($message);
    $message = new xmlrpcmsg("load_start", array(new xmlrpcval($uploadfile, 
'string')));
    $result2 = $this->client->send($message);

    if (($result1->errno == 0) && ($result2->errno == 0) && ($res[0] !== false))
        $this->addMessage($this->_str['info_add_torrent']);
    else {
        $this->addMessage($this->_str['err_add_torrent']);
        @unlink($uploadfile);
    }
}
?>

Original comment by ru.dmi...@gmail.com on 26 Mar 2008 at 8:48