Jump to content

[HOW-TO] Handle magnet links from a remote pc


cajainas

Recommended Posts

In windows it's too easy (download utorrent adder, configure, and ready), but I find the way to send magnet links to utserver from a remote pc in GNU/Linux (Mint 14 in my case)

I think that dependencies are: python (>2.6.6) and python-libtorrent

- Download utwhisper from https://github.com/tranqil/utwhisper and extract in a folder ("~/magnet" in my case)

- Configure settings.py (user,pass and server url).

Optional: If you write in the console "python ~/magnet/utwhisper --addurl magneturl", you will add the magnet to your utserver. But forget this, we want to automate this (you can see the funcionalities of this program writing "python utwhisper --help")

Now, the way to handle magnets, using chrome is:

Open a console and write:

$ gconftool-2 -t string -s /desktop/gnome/url-handlers/magnet/command "python /home/YOURUSER/FOLDER/utwhisper.py --addurl %s"

$ gconftool-2 -s /desktop/gnome/url-handlers/magnet/needs_terminal false -t bool

$ gconftool-2 -t bool -s /desktop/gnome/url-handlers/magnet/enabled true

Now, if you click in a magnet, chrome will ask you if do you want a external application to handle the magnet protocol, press ok (and check on the remember option) and the torrent will download in your remote utserver.

Apologies for my bad english :)

Link to comment
Share on other sites

  • 1 year later...
  • 2 weeks later...

This also works well, have been using my script for a while now.

Just change myCRED="admin:" and

 

#!/bin/bash
##
 
do_GetToken() {
echo "Getting token."
curl -s \
--connect-timeout 20 --max-time 60 \
--trace $logNAME".trace" \
--insecure \
--user $myCRED \
--cookie-jar $logNAME".cj" \
--output $logNAME".of" \
$myURL"token.html"
 
if [ -e $logNAME".of" ]
then
myTOKEN=`cat $logNAME".of" |sed 's/<[^<>]*>//g'`
if [ -z "$myTOKEN" ]
then
echo "Problem with Token, exiting"
exit 1
else
echo "Good token."
echo "Token obtained: "$myTOKEN >> $myLOGS
fi
else
clear
echo "Error connecting!"
exit
fi
}
 
do_PostTo() {
echo "Posting magnetic link."
curl -G -s \
--user-agent "blah blah" \
--user $myCRED \
--insecure \
--trace $logNAME".trace" \
--connect-timeout 20 --max-time 60 \
--cookie $logNAME".cj" \
--dump-header $logNAME".dh" \
--output $logNAME".of" \
--data token=$myTOKEN \
--data action=add-url \
--data-urlencode s=$magnetLink \
$myURL
 
checkRes=`cat $logNAME".of" |grep "build"`
if [ -z "$checkRes" ]
then
echo "Problem ???"
else
echo "Finished." 
fi
 
}
 
clear
me=`basename $0`
logNAME="/tmp/$me.log"
rm -f "$logNAME""*"
myLOGS="$logNAME"".mylogs"
myCRED="admin:"
rm -f $logNAME".of"
magnetList="/tmp/magnetList"
cat <<EOF> $magnetList
magnet:?xt=urn:btih:757b25d9681d493167b8d3759dbfddc983e80646&dn=ubuntu-14.04-server-amd64.iso
EOF
 
do_GetToken
 
while read magnetLink
do
do_PostTo
done < $magnetList
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...