torrent auto-import

Support forum for the built-in BitTorrent client. What is BitTorrent?

Similar topics


torrent auto-import

Postby frejac » Wed Jun 18, 2008 4:09 pm

Hi!

I just started using the new built-in torrent client.
(previously I used a self-compiled rtorrent/libtorrent on my readynas)

Very neat, with the firefox addon!

Performance seems fine too.

Hmm just miss a drop-folder that it monitors for new torrents.
I need to look into if I could do a wget thingy to submit a file on local filesystem :)
frejac
ReadyNAS Expert
 
Posts: 265
Joined: Tue Nov 28, 2006 5:59 am

Re: torrent auto-import

Postby chirpa » Wed Jun 18, 2008 4:14 pm

I am currently doing that, hacked it up one night, only bug I have noticed, that I haven't accounted for yet is torrents with spaces (" ") in the filenames. Here is what I have been using for a few months now:

$ cat /etc/cron.d/import_torrents
Code: Select all
# Run import script every so often
3,12,21,29,38,47,55 * * * *     root   /root/import_torrents.sh &>/dev/null

$ cat /root/import_torrents.sh
Code: Select all
#!/bin/sh
#     What: Import .torrents into the NETGEAR ReadyNAS BitTorrent Download Manager
#      Who: Quickly slapped together by chirpa (readynas.com/forum), crontab it and walk away.
# Requires: Curl (maybe I'll make it work with Wget at some point)
#  Version: 0.1a
#     Todo: Check for returned status: apiTorrentAddFinishedOk / apiTorrentAddFailed
#     Todo: Handle filenames with spaces in it (damn mininova!)

INCOMING_DIR=/tmp/torrents
DONE_DIR=/tmp/torrents/done
BTURL="http://localhost:8080/api/torrent-add?start=yes"

cd $INCOMING_DIR
for f in `ls -1 *.torrent 2>/dev/null`
do
  echo Loading file: $f
  curl -s -F fileEl=@$f $BTURL >/dev/null
  mv $f $DONE_DIR
done

I'm sure it can be done a lot cleaner, but I've just been using what has worked for me.
User avatar
chirpa
Jedi Council
 
Posts: 11174
Joined: Mon Sep 24, 2007 11:52 am
Location: T.A.R.D.I.S.
ReadyNAS: Repertoire

Re: torrent auto-import

Postby frejac » Wed Jun 18, 2008 4:32 pm

wow. thanks. no idea to reinvent the wheel :)

great!
frejac
ReadyNAS Expert
 
Posts: 265
Joined: Tue Nov 28, 2006 5:59 am

Re: torrent auto-import

Postby frejac » Thu Jun 19, 2008 2:46 pm

So...I googled some and found what seems to be a nice way to handle spaces.

Just add

Code: Select all
IFS=$'\0'


somewhere before the for-loop.

edit: not sure exactly what it does, so it may break something else :)
frejac
ReadyNAS Expert
 
Posts: 265
Joined: Tue Nov 28, 2006 5:59 am

Re: torrent auto-import

Postby chirpa » Thu Jun 19, 2008 2:56 pm

Thanks, I'll try it out tonight.
User avatar
chirpa
Jedi Council
 
Posts: 11174
Joined: Mon Sep 24, 2007 11:52 am
Location: T.A.R.D.I.S.
ReadyNAS: Repertoire

Re: torrent auto-import

Postby jaysin436 » Thu Jul 10, 2008 10:58 am

Can you guys clarify what this does?

Does this look for .torrent files that you've saved somewhere and then automatically add those the built in BitTorrent client?

If so, can you explain how I install this and make this work?

Thanks,
Jason.
jaysin436
ReadyNAS Newbie
 
Posts: 8
Joined: Tue Jul 08, 2008 9:10 pm

Re: torrent auto-import

Postby chirpa » Thu Jul 10, 2008 12:07 pm

jaysin436 wrote:Can you guys clarify what this does?
Does this look for .torrent files that you've saved somewhere and then automatically add those the built in BitTorrent client?
If so, can you explain how I install this and make this work?

Yes, will check a directory on the NAS (shared from a PC) where .torrents are stored. Will then pass them to the ReadyNAS BitTorrent Manager to download. It requires root SSH to be enabled on the NAS, which should only be done if you have experience with linux consoles.
User avatar
chirpa
Jedi Council
 
Posts: 11174
Joined: Mon Sep 24, 2007 11:52 am
Location: T.A.R.D.I.S.
ReadyNAS: Repertoire

Re: torrent auto-import

Postby jaysin436 » Fri Jul 11, 2008 7:53 am

Chirpa,

Thanks, after reading up on Cron and Curl I think I understand now. I didn't realize that this is two scripts, one for Cron and the other the actual import itself.



Thanks,
Jason.
jaysin436
ReadyNAS Newbie
 
Posts: 8
Joined: Tue Jul 08, 2008 9:10 pm

Re: torrent auto-import

Postby chirpa » Fri Jul 11, 2008 1:35 pm

jaysin436 wrote:I didn't realize that this is two scripts, one for Cron and the other the actual import itself.
My bad, I was lazy when I posted it all together. I have edited that post and split the files up to be more clear.
User avatar
chirpa
Jedi Council
 
Posts: 11174
Joined: Mon Sep 24, 2007 11:52 am
Location: T.A.R.D.I.S.
ReadyNAS: Repertoire

Re: torrent auto-import

Postby jaysin436 » Fri Jul 11, 2008 11:44 pm

Chirpa,

Where is Curl? I can't find it on the ReadyNas. Do I need an add on for this exe?

Thanks,
Jason.
jaysin436
ReadyNAS Newbie
 
Posts: 8
Joined: Tue Jul 08, 2008 9:10 pm

Re: torrent auto-import

Postby chirpa » Sat Jul 12, 2008 12:07 am

1. Install the APT addon.
2.
Code: Select all
apt-get update;apt-get install curl
User avatar
chirpa
Jedi Council
 
Posts: 11174
Joined: Mon Sep 24, 2007 11:52 am
Location: T.A.R.D.I.S.
ReadyNAS: Repertoire

Re: torrent auto-import

Postby jaysin436 » Sat Jul 12, 2008 12:19 am

Chirpa,

I'm sure glad you're up late :)

Many thanks, I've got the script working by with a simple test executing it manually, now I just need to add it to cron.

Jason.
jaysin436
ReadyNAS Newbie
 
Posts: 8
Joined: Tue Jul 08, 2008 9:10 pm

Re: torrent auto-import

Postby Peakation » Wed Aug 13, 2008 3:02 am

frejac wrote:So...I googled some and found what seems to be a nice way to handle spaces.

Just add

Code: Select all
IFS=$'\0'


somewhere before the for-loop.

edit: not sure exactly what it does, so it may break something else :)


IFS means Input Field Separator and is default a space. The IFS is an internal variable used in several bash functions, eg. "for i in" where the line is read word for word separated by a space, ie. the IFS.
You may set the IFS to anything you prefer to make it function to your needs but a good practice is to set it back to original before you end your script:
Code: Select all
TMP_IFS=$IFS
IFS=";"
..do your thing
IFS=$TMP_IFS


I'm not sure what the code IFS=$'\0' actually means but $0 is always the script itself. $1 is input one, etc. Try echo $0 inside your script to see.

A very good source for more on bash functions is: http://www.faqs.org/docs/abs/HTML/index.html

First post, waiting for my ReadyNAS Duo to arrive! Can't wait to start "hacking"... :D
Peakation
ReadyNAS Newbie
 
Posts: 6
Joined: Wed Aug 13, 2008 2:45 am

Re: torrent auto-import

Postby chirpa » Wed Aug 13, 2008 5:15 am

I'll give that a try in the next few days, thanks.
User avatar
chirpa
Jedi Council
 
Posts: 11174
Joined: Mon Sep 24, 2007 11:52 am
Location: T.A.R.D.I.S.
ReadyNAS: Repertoire

Re: torrent auto-import

Postby Baxalasse » Thu Aug 28, 2008 11:59 am

Jedi Council

Yes, will check a directory on the NAS (shared from a PC) where .torrents are stored. Will then pass them to the ReadyNAS BitTorrent Manager to download. It requires root SSH to be enabled on the NAS, which should only be done if you have experience with linux consoles.



Is it to much to ask of you to write a step by step instructions how to install this addon from scratch. I have absolutely no experience with Linux console? But very interested in your addon.

Thanks in advance
Baxalasse
ReadyNAS DUO 500, user with no linux experience...
- 1GB Upgrade
- RAIDiator 4.1.6

Status: Slow backup speed, ~3MB/s
Baxalasse
ReadyNAS Newbie
 
Posts: 33
Joined: Thu Aug 28, 2008 11:53 am
ReadyNAS: Duo

Next

Return to BitTorrent

Similar topics


Who is online

Users browsing this forum: No registered users and 0 guests