What's new

[How-To] Download torrents using Dropbox

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

ryzhov_al

Very Senior Member
Just imagine: you'll drop *.torrent-files to Dropbox folder and router download it and report you when finished with a text file placed back to Dropbox folder.

This solution uses Dropbox-Uploader which is already in Entware repo.

1. Prerequisites
asuswrt-merlin firmware on board and a USB drive with Entware installation.

2. Installation
Install necessary packages and fix root account for the cron service:
Code:
opkg install cron curl dropbox-uploader transmission-web
sed -i 's/root/admin/g' /opt/etc/crontab
Place this content to /opt/etc/cron.5mins/torrent-watch.sh
Code:
#!/opt/bin/bash

if [ -z "$TR_TORRENT_NAME" ]
then
    dropbox_uploader list | grep -iE "^ \[F\] .+\.torrent$" | \
    sed "s|^ \[F\] ||g" | \
    while read item
    do
        dropbox_uploader download "$item" "/opt/etc/transmission/watchdir/$item"
        dropbox_uploader delete "$item"
    done
else
    echo "Donwload job done at `date`" > "/tmp/$TR_TORRENT_NAME.txt"
    dropbox_uploader upload "/tmp/$TR_TORRENT_NAME.txt"
    rm -f "/tmp/$TR_TORRENT_NAME.txt"
fi
and make it executable:
Code:
chmod +x /opt/etc/cron.5mins/torrent-watch.sh

3. Configure transmission
I'll show only those strings in /opt/etc/transmission/settings.json which need to be changed:
Code:
...
"download-dir": "/tmp/mnt/MYUSBDRIVE/Torrents",
...
"script-torrent-done-enabled": true,
"script-torrent-done-filename": "/opt/etc/cron.5mins/torrent-watch.sh",
...
where "download-dir" is a folder on USB drive where torrent content will be placed.

4. Configure Dropbox-Uploader
This part is a tricky one. Proceed here and create new Dropbox application by filling:
  • App type: Core,
  • App name: <You name it as you wish>,
  • Permission type: App folder,
  • Push "Create app",
  • Name of app folder: Torrents (or any other you like),
  • Press "Update".
Dropbox site will give you "App key" and "App secret" values which will be used on the next step. Now return to router console and type dropbox_uploader. Answer a few questions:
  • App key: value from previous step,
  • App secret: from previous step too,
  • Access level [a/f]: a,
  • …it's ok? [y/n]: y,
  • Token request. Please, copy URL from console to web browser and press "Allow" on the web page appeared. Only then return to router and press "Enter".

Installation is finished. Reboot router and try to place some *.torrent files to the "Applications/Torrents" folder in Dropbox account. They will disappear within five minutes. It means router is "took" them and start downloads. When downloading will be finished, a text file will be appeared in Dropbox folder, named as a finished torrent job. You may take a look inside (a job finish time will be there) and erase it.

You don't need a real IP or open ports to add new torrents. As always, you may point a web browser to <ip of router>:9091 from LAN to see current a torrents activity.
 
Last edited:
Hi

Thanks for you guide :)

Can you please explain 4., I think dropbox has changed since you tutorial.

4. Configure Dropbox-Uploader
This part is a tricky one. Proceed here and create new Dropbox application by filling:
App type: Core,
App name: <You name it as you wish>,
Permission type: App folder,
Push "Create app",
Name of app folder: Torrents (or any other you like),
Press "Update".
Dropbox site will give you "App key" and "App secret" values which will be used on the next step. Now return to router console and type dropbox_uploader. Answer a few questions:
App key: value from previous step,
App secret: from previous step too,
Access level [a/f]: a,
…it's ok? [y/n]: y,
Token request. Please, copy URL from console to web browser and press "Allow" on the web page appeared. Only then return to router and press "Enter".

Thanks
 
Go to https://www.dropbox.com/developers/apps/create
Dropbox API app
Files and datastores
Yes My app only needs access to files it creates.
App name = Dropbox-Torrents (or choose another name if name already taken)
Create App
-------------------------
Now continue from....
Code:
Dropbox site will give you "App key" and "App secret".......


Hi

Thanks for you guide :)

Can you please explain 4., I think dropbox has changed since you tutorial.

4. Configure Dropbox-Uploader
This part is a tricky one. Proceed here and create new Dropbox application by filling:
App type: Core,
App name: <You name it as you wish>,
Permission type: App folder,
Push "Create app",
Name of app folder: Torrents (or any other you like),
Press "Update".
Dropbox site will give you "App key" and "App secret" values which will be used on the next step. Now return to router console and type dropbox_uploader. Answer a few questions:
App key: value from previous step,
App secret: from previous step too,
Access level [a/f]: a,
…it's ok? [y/n]: y,
Token request. Please, copy URL from console to web browser and press "Allow" on the web page appeared. Only then return to router and press "Enter".

Thanks
 
Hi Thanks

For your input, I managed to follow the guide.

But I can't get it to work.

3. Configure transmission
I'll show only those strings in /opt/etc/transmission/settings.json which need to be changed:
Code:
...
"download-dir": "/tmp/mnt/MYUSBDRIVE/Torrents",
...
"script-torrent-done-enabled": true,
"script-torrent-done-filename": "/opt/etc/cron.5mins/torrent-watch.sh",

When I change this, it is reset back to default af reboot.
"script-torrent-done-enabled": false,
"script-torrent-done-filename": "",

When I try and execute the from terminal, with a torrent in my app folder I get this output, and no active torrent downloading:
admin@AsusWRT:/tmp/home/root# /opt/etc/cron.5mins/torrent-watch.sh
> Downloading "/" to "/opt/etc/transmission/watchdir///"...
> Creating local directory "/opt/etc/transmission/watchdir///"... DONE
> Downloading "//TEST.torrent" to "/opt/etc/transmission/watchdir////TEST.torrent"... DONE
> Deleting "/"... FAILED

Hope you can help.

Thanks
 
Stop transmission
Modify settings.json
Start transmission again


Hi

Thanks that worked, I know have the right settings in the settings.son file.

But my torrents are still not picked up from my dropbox:
admin@AsusWRT:/tmp/home/root# /opt/etc/cron.5mins/torrent-watch.sh
> Downloading "/" to "/opt/etc/transmission/watchdir///"...
> Creating local directory "/opt/etc/transmission/watchdir///"... DONE
> Downloading "//Test.torrent" to "/opt/etc/transmission/watchdir////Test.torrent"... DONE
> Deleting "/"... FAILED
admin@AsusWRT:/tmp/home/root#

Any input?
- Are you writting a tutorial for this one on www.asuswrt.eu
 
Hi

Thanks that worked, I know have the right settings in the settings.son file.

But my torrents are still not picked up from my dropbox:
admin@AsusWRT:/tmp/home/root# /opt/etc/cron.5mins/torrent-watch.sh
> Downloading "/" to "/opt/etc/transmission/watchdir///"...
> Creating local directory "/opt/etc/transmission/watchdir///"... DONE
> Downloading "//Test.torrent" to "/opt/etc/transmission/watchdir////Test.torrent"... DONE
> Deleting "/"... FAILED
admin@AsusWRT:/tmp/home/root#

Any input?
- Are you writting a tutorial for this one on www.asuswrt.eu
Actually, I didn't tried this but I can post it on my site is user request. I have about 500 visitors per day but almost zero feedback.
 
Actually, I didn't tried this but I can post it on my site is user request. I have about 500 visitors per day but almost zero feedback.

Hi

I would like this :)

I am going to do a fresh install of firmware Merlin fork 374.43_2-05j9527 with reset.

Im will try the following from your site:
1. HOW TO INSTALL ENTWARE
2. LIGHTTPD WEB SERVER WITH PHP SUPPORT THROUGH ENTWARE
3. WORDPRESS BLOG SERVER THROUGH ENTWARE
4. TRANSMISSION ON ASUSWRT ROUTERS THROUGH ENTWARE
5. This one, Download torrents using Dropbox
 
Tried to da a fresh install af firmware and jffs, still no dice:
admin@AsusWRTport:/tmp/home/root# /opt/etc/cron.5mins/torrent-watch.sh
> Downloading "/" to ".//"...
> Creating local directory ".//"... DONE
> Downloading "//TEST.torrent" to ".///TEST.torrent"... DONE
/opt/etc/cron.5mins/torrent-watch.sh: line 10: /opt/etc/transmission/watchdir/: Is a directory
> Deleting "/"... FAILED
admin@AsusWRT:/tmp/home/root#
 
I managed to make it work (somehow), will copy torrents files to /opt/etc/transmission/watchdir/ and start downloading but will not delete *.torrent files from dropbox folder and will take again forever.
Maybe dropbox-uploader script is not 100% ok, even if I try to delete a file from terminal with command
Code:
dropbox_uploader delete "$item"
will fail, I have to input exactly file name and will delete file but is not a solution.
Code:
dropbox_uploader delete torrent-name.torrent
What do you say @ryzhov_al?
 
Found the issue, working on it now :)
I see you've updated dropbox_uploader package. I should do the same. Why you've changed this string?
Code:
admin@RT-N66U:/tmp/mnt/OPT/tmp# diff -u ./dropbox_uploader.sh ./dropbox_uploader_th
--- ./dropbox_uploader.sh
+++ ./dropbox_uploader_th
...
@@ -953,7 +954,7 @@

                 local FILE=$(echo "$line" | sed -n 's/.*"path": *"\([^"]*\)".*/\1/p')
                 local IS_DIR=$(echo "$line" | sed -n 's/.*"is_dir": *\([^,]*\).*/\1/p')
-                local SIZE=$(echo "$line" | sed -n 's/.*"bytes": *\([0-9]*\).*/\1/p')
+

                 echo -e "$FILE:$IS_DIR;$SIZE" >> "$RESPONSE_FILE"
 
Was the easiest way to make it work, I'm sure you can do better :)
That line will show file size from remote and your script will not work because needs only file names
Put some files in dropbox folder and run list command
Code:
dropbox_uploader list
Dropbox_uploader script was updated and you should modify /opt/etc/cron.5mins/torrent-watch.sh, right now will fetch all files on remote, even directories not only .torrents but it's ok, we should leave it empty.
 
Hi all.

Cron is not working for me.
I can see cron service running using top with pid 530. But if I check the service by the instruction "cron status" the system response is... "cron: can't lock /opt/var/run/cron.pid, otherpid may be 530: Resource temporarily unavailable"

If I execute /opt/etc/cron.5mins/torrent-watch.sh works flawless but not automatically under cron.
 

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top