Sign up here and you can log into the forum!

Rtorrent basic control (working!)

Discussion, features, plugins--everything about zoster's UMSP UPnP Media Server software

Rtorrent basic control (working!)   

Postby Martin_L » Mon Mar 28, 2011 10:18 am

Hello everyone!

First thanks for the great work!

I have been thinking of a basic control for rtorrent and I tested a mini-control to change upload throttle.
The basic sh file works, but i run into problems because of lack of permissions of php processes. (thanks recliq)
Surely this will spark ideas into someone to take over or give help.
Right now it works from umsp-test.php, but not from the screen. Any ideas why?

I wrote this because my conection is sometimes choked and I wanted to lower the upload to be able to do things in another computer (or VoIP) without needing to log in or use the wdlxtv webpage.

I will be adding commands if I have time to, but any ideas are very welcome!

File "rtorrent_control.sh"
Code: Select all
#!/usr/bin/env bash
screen -S rtorrent -X register a "$1"
screen -S rtorrent -X paste a
sleep 1
screen -S rtorrent -X hardcopy /tmp/tmprtorrentstatus.txt
grep Throttle /tmp/tmprtorrentstatus.txt


File "rtorrent_control.php"
Code: Select all
<?php
    function _pluginMain($prmQuery) {

    $grtcom = substr($prmQuery,6);
    $output = shell_exec("sudo /tmp/umsp-plugins/rtorrent_control.sh $grtcom");

    $Items[] = array(
            'id'              => 'SubItem01',
            'parentID'        => 'umsp://plugins/rtorrentcontrol',
            'dc:title'        => $output,
            'upnp:class'      => 'object.item.videoItem',
            'res'             => '',
            'protocolInfo'    => '*:*:*:*',
    );


    return $Items;
    }
?>


Chunck to paste in "usmp-items.xml"
Code: Select all
   <item type="directory" id="rtorrent_control_menu" dc.title="rtorrent control" order="7">
      <item id="rtorrent_control" dc.title="Current state" param.rtcom="" order="1"/>
      <item id="rtorrent_control" dc.title="Increase upload throttle: 50 KB" param.rtcom="d" order="2"/>
      <item id="rtorrent_control" dc.title="Increase upload throttle: 5 KB" param.rtcom="s" order="3"/>
      <item id="rtorrent_control" dc.title="Decrease upload throttle: 5 KB" param.rtcom="x" order="4"/>
      <item id="rtorrent_control" dc.title="Decrease upload throttle: 50 KB" param.rtcom="c" order="5"/>
   </item>


Thanks!

Martin
Last edited by Martin_L on Tue Mar 29, 2011 11:19 am, edited 3 times in total.
Martin_L
DLX'er
 
Posts: 67
Joined: Mon Mar 28, 2011 3:11 am

Re: Rtorrent basic control   

Postby recliq » Tue Mar 29, 2011 7:36 am

simply add a sudo to get root rights on command execution:
Code: Select all
$output = shell_exec("sudo /tmp/umsp-plugins/controlrtorrent.sh $rtorrentcommand");
­WDLXTV Project Maintainer
-:] If you like my contributions feel free to donate for a beer or a new flash drive. ...and always remember: RTFM! (README, FAQ, WIKI) [:-
User avatar
recliq
WDLXTV Team
 
Posts: 5513
Joined: Thu Apr 15, 2010 8:09 am
Location: Kiel, Germany

Re: Rtorrent basic control   

Postby Martin_L » Tue Mar 29, 2011 8:58 am

Thanks recliq!

I went on testing and it is working now. I am editing the originial post with the working code.
Unfortunalety, right now it works only from umsp-test.php, but not from the screen. Any ideas why?

Martin
Martin_L
DLX'er
 
Posts: 67
Joined: Mon Mar 28, 2011 3:11 am

Re: Rtorrent basic control (working!)   

Postby Martin_L » Tue Mar 29, 2011 11:23 am

I solved the problem and the plugin is working now!

The global variable of parameters "$_GET" works in UMSP Test, but not in UMSP itself.
I parse the command caracter of interest with substr() and it works.

Enjoy the plugin!

Martin
Martin_L
DLX'er
 
Posts: 67
Joined: Mon Mar 28, 2011 3:11 am


Return to UMSP Media Server

Who is online

Users browsing this forum: No registered users and 1 guest