MODS: Queuing with Transmission BitTorrent Client

If you followed our previous article in adding a telnet utility to your Popcorn Hour C-200 and installed LTU 0.76, you also upgraded the Transmission torrent client in the process. The latest bittorrent client, Transmission 2.33, is packaged with the LTU 0.76. This is one of the strengths of having a custom package installed on the C-200. One thing to note though is that if you installed BusyBox 1.4.1 on the C-200, it conflicts with LTU 0.76. So better to uninstall BusyBox and retain LTU instead.

Having a telnet shell to the Popcorn Hour C-200 is very powerful. Here is a demonstration of how powerful and flexible having a shell access to the C-200 really is -- queuing with the transmission torrent client. The transmission bittorrent client doesn't have this feature by default, but that doesn't mean we can't do anything about it. Here's a script you can put on your C-200 that controls queuing of Transmission torrents.

#!/bin/sh

# *************
# Configuration
REMOTE="/nmt/apps/bin/transmission-remote"
USERNAME="nmt"
PASSWORD="1234"
MAXDOWN=2
MAXACTIVE=5
CONFIG="/share/.transmission/settings.json"

# *************
# Set-up variables
CMD="$REMOTE --auth $USERNAME:$PASSWORD"
MAXRATIO=$(cat $CONFIG | grep \"ratio-limit\":)
MAXRATIO=${MAXRATIO#*\"ratio-limit\": }
MAXRATIO=${MAXRATIO%*, }

# *************
# deal with downloads
DOWNACTIVE="$($CMD -l | tail -n +2 | grep -v 100% | grep -v Sum | grep -v Stopped | grep -v Verifying | grep -v Will\ Verify | wc -l)"
if [ $MAXDOWN -lt $DOWNACTIVE ]; then
    DOWNTOSTOP="$($CMD -l | tail -n +2 | grep -v 100% | grep -v Sum | grep -v Stopped | grep -v Verifying | grep -v Will\ Verify | tail -n $(expr $DOWNACTIVE - $MAXDOWN) | awk '{ print $1; }')"
    for ID in $DOWNTOSTOP; do
        NAME="$($CMD --torrent $ID --info | grep Name:)"
        $CMD --torrent $ID --stop >> /dev/null 2>&1
    done
else
    [ $(expr $MAXDOWN - $DOWNACTIVE) -gt 0 ] && (
    DOWNINACTIVE="$($CMD -l | tail -n +2 | grep -v 100% | grep Stopped | wc -l)"
    [ $DOWNINACTIVE -gt 0 ] && (
        DOWNTOSTART="$($CMD -l | tail -n +2 | grep -v 100% | grep Stopped | head -n $(expr $MAXDOWN - $DOWNACTIVE) | awk '{ print $1; }')"
        for ID in $DOWNTOSTART; do
            NAME="$($CMD --torrent $ID --info | grep Name:)"
            $CMD --torrent $ID --start >> /dev/null 2>&1
        done
        )
    )
fi
# Then deal with total active
ACTIVE="$($CMD -l | tail -n +2 | grep -v Sum | grep -v Stopped | grep -v Verifying | grep -v Will\ Verify | wc -l)"
if [ $MAXACTIVE -lt $ACTIVE ]; then
    TOSTOP="$($CMD -l | tail -n +2 | grep 100% | grep -v Stopped | grep -v Verifying | grep -v Will\ Verify | tail -n $(expr $ACTIVE - $MAXACTIVE) | awk '{ print $1; }')"
    for ID in $TOSTOP; do
        NAME="$($CMD --torrent $ID --info | grep Name:)"
        $CMD --torrent $ID --stop >> /dev/null 2>&1
    done
else
    [ $(expr $MAXACTIVE - $ACTIVE) -gt 0 ] && (
    SEEDINACTIVE="$($CMD -l | tail -n +2 | grep 100% | grep Stopped | awk -v ratio=$MAXRATIO '{ if (substr($0,52,4) < ratio) print $0 ;}' | wc -l)"
    [ $SEEDINACTIVE -gt 0 ] && (
        TOSTART="$($CMD -l | tail -n +2 | grep 100% | grep Stopped | awk -v ratio=$MAXRATIO '{ if (substr($0,52,4) < ratio) print $0 ;}' | head -n $(expr $MAXACTIVE - $ACTIVE) | awk '{ print $1; }')"
        for ID in $TOSTART; do
            NAME="$($CMD --torrent $ID --info | grep Name:)"
            $CMD --torrent $ID --start >> /dev/null 2>&1
        done
        )
    )

On the above script, change the values for USERNAME, PASSWORD, MAXDOWN and MAXACTIVE. The script above contains the default values for the C-200. I tested the above script to work on my C-200. It will work on another 200 series Popcorn Hour too. A friend has tested it on his A-210 as well, and his feedback is good.

The script is working but how do you automate this? Linux just has the answer in cron. The script can be manually put in cron but the issue is, when the C-200 is rebooted, the entries get wiped out.

This is how to automate the queuing on the Transmission torrent client on the C-200. Edit the file /share/Apps/LTU/appinfo.json. Add the line:
crontab="*/5 * * * * /PATH/TO/torrent-queue.sh"

Verify that your crontab has entries above by rebooting the C-200 and check with "crontab -l". That's it folks, queuing working with the Transmission BT client. Now, imagine trying to do the same without shell access to your Popcorn Hour.

Credits: The original script was taken from http://pastie.org/632212. It was then adapted to work with the Popcorn Hour C-200.

Share:

Subscribe for Latest Update

Popular Posts

Post Labels

100gb (1) acceleration (1) acrobat (1) adblock (1) advanced (1) ahci (1) airdrop (2) aix (14) angry birds (1) article (21) aster (1) audiodg.exe (1) automatic (2) autorun.inf (1) bartpe (1) battery (2) bigboss (1) binance (1) biometrics (1) bitcoin (3) blackberry (1) book (1) boot-repair (2) calendar (1) ccleaner (3) chrome (5) cloud (1) cluster (1) compatibility (3) CPAN (1) crypto (3) cydia (1) data (3) ddos (1) disable (1) discount (1) DLNA (1) dmidecode (1) dns (7) dracut (1) driver (1) error (10) esxi5 (2) excel (1) facebook (1) faq (36) faucet (1) firefox (17) firewall (2) flash (5) free (3) fun (1) gadgets (4) games (1) garmin (5) gmail (3) google (4) google+ (2) gps (5) grub (2) guide (1) hardware (6) how (1) how-to (45) huawei (1) icloud (1) info (4) iphone (7) IPMP (2) IPV6 (1) iscsi (1) jailbreak (1) java (3) kodi (1) linux (28) locate (1) lshw (1) luci (1) mafia wars (1) malware (1) mapsource (1) memory (2) mikrotik (5) missing (1) mods (10) mouse (1) multipath (1) multitasking (1) NAT (1) netapp (1) nouveau (1) nvidia (1) osmc (1) outlook (2) p2v (2) patch (1) performance (19) perl (1) philippines (1) php (1) pimp-my-rig (9) pldthomedsl (1) plugin (1) popcorn hour (10) power shell (1) process (1) proxy (2) pyspark (1) python (13) qos (1) raspberry pi (7) readyboost (2) reboot (2) recall (1) recovery mode (1) registry (2) rename (1) repository (1) rescue mode (1) review (15) right-click (1) RSS (2) s3cmd (1) salary (1) sanity check (1) security (15) sendmail (1) sickgear (3) software (10) solaris (17) squid (3) SSD (3) SSH (9) swap (1) tip (4) tips (42) top list (3) torrent (5) transmission (1) treewalk (2) tunnel (1) tweak (4) tweaks (41) ubuntu (4) udemy (6) unknown device (1) updates (12) upgrade (1) usb (12) utf8 (1) utility (2) V2V (1) virtual machine (4) VirtualBox (1) vmware (14) vsphere (1) wannacry (1) wifi (4) windows (54) winpe (2) xymon (1) yum (1) zombie (1)

Blog Archives

RANDOM POSTS