Synology Download Station Automation
I got sick of logging into the NAS every time a new distro ISO came out. Download Station handles HTTP, FTP, BitTorrent, NZB and more, and the useful part is that it can be fed automatically: RSS feeds with filters, a watched folder any device can drop files into, and the DS get phone app. Once it's set up, ISOs and podcast archives show up on the right share without anyone touching the NAS.
Here's what I configured on DSM 6.2, including sorting the results and throttling bandwidth during working hours. I use a dedicated downloads shared folder rather than homes, so permissions and Hyper Backup exclusions stay simple. For BitTorrent, forward the incoming range (6881 to 6890 TCP by default) on the router.
Destinations and general options
Download Station → Settings (the gear icon) → General:
Default destination folder: downloads
Temporary location: downloads/incoming
Auto extract: enabled, delete archive after extraction
Use a temporary location so partially downloaded files do not appear in the finished folder. Under Location, tick "Enable download schedule" and set it to Limited during 08:00 to 18:00 on weekdays; then on the BT tab set the limited speeds:
Max download rate (limited): 2000 KB/s
Max upload rate (limited): 200 KB/s
Max download rate (full): 0 (unlimited)
The schedule makes the NAS behave during the day and open up at night.
RSS feeds with filters
Download Station → RSS Feeds → the plus button. Paste the feed URL and give it a name. Feeds are polled every 30 minutes by default; the interval is adjustable under Settings → RSS.
To download only matching items, open the feed → Filter → Add:
Filter name: ubuntu-server
Match: ubuntu-*-server-amd64.iso
Exclude: beta
Destination: downloads/iso
The Match field accepts plain wildcards, not full regular expressions. An item is downloaded once, and the feed remembers what it has seen; clearing the feed's history from its context menu makes it re-evaluate every item.
The watched folder
Settings → Location → tick "Enable watched folder" and pick a folder such as downloads/watch. Any .torrent, .nzb or plain .txt file with URLs dropped in there is picked up within a minute and removed. This is the simplest integration with anything else: a script on a Linux box can scp a file in, a browser extension can save to the SMB share, or Synology Drive can sync a folder from a laptop into it.
From a Linux machine:
scp ubuntu-18.04.1-server-amd64.iso.torrent user@nas:/volume1/downloads/watch/
API for scripts
Download Station has a simple HTTP API that DS get and third-party tools use. A shell script on another machine can add a task with two calls, one to log in and one to create the task:
NAS=https://nas.example.com:5001
SID=$(curl -s "$NAS/webapi/auth.cgi?api=SYNO.API.Auth&version=2&method=login&account=dl&passwd=secret&session=DownloadStation&format=sid" | sed 's/.*"sid":"\([^"]*\)".*/\1/')
curl -s "$NAS/webapi/DownloadStation/task.cgi" \
--data "api=SYNO.DownloadStation.Task&version=1&method=create&uri=http://releases.ubuntu.com/18.04/ubuntu-18.04.1-server-amd64.iso&_sid=$SID"
I never put an admin password in a cron job. Create a dedicated DSM user (dl above) with permission for Download Station only, under Control Panel → User → Applications. The account can then be used from cron jobs without exposing an administrator password.
Sorting finished files
Download Station does not move completed files by category beyond what the RSS filter destination sets. For everything else I run a scheduled script in Control Panel → Task Scheduler → Create → Scheduled Task → User-defined script, as root, every 15 minutes:
#!/bin/sh
cd /volume1/downloads || exit 1
find . -maxdepth 1 -type f -name '*.iso' -mmin +5 -exec mv {} /volume1/downloads/iso/ \;
find . -maxdepth 1 -type f -name '*.mp3' -mmin +5 -exec mv {} /volume1/music/incoming/ \;
The -mmin +5 guard avoids moving a file Download Station is still writing to, in case the temporary folder is not used.
DS get on the phone
Install DS get, log in with the same limited user, and you can paste a link or share a URL from the browser straight into Download Station. It shows progress and lets you pause tasks, which covers the "start it now, it will be there when I get home" use case without a VPN.
Testing each input
- Add an item to the watched folder and watch it appear in the Download Station task list within a minute.
- Add a test RSS feed (a podcast feed works well) with a filter, wait for the next poll or click Update on the feed, and confirm only matching items were queued.
- Check the schedule: during limited hours the task list header shows the current rate limit.
- Run the API script and check the task appears with the
dluser as owner.
Gotchas
- The task sits at "Waiting" forever. Download Station caps the number of simultaneous tasks in Settings → General → Max concurrent download tasks (default 20 with BitTorrent counted separately). Either raise it or the queue is simply full.
- RSS feed shows "Failed to fetch feed" while the URL works in a browser. Most often the feed requires HTTPS with a certificate DSM does not trust, or the URL is HTTP with a redirect the fetcher does not follow. Use the final HTTPS URL.
- Files downloaded through the RSS filter land in the default folder, not the filter's destination. The destination is set per filter, not per feed; check you edited the filter, not the feed properties.
- API call returns
{"error":{"code":105},"success":false}. Code 105 is "insufficient privilege": the user lacks Download Station application permission or the session was created withoutsession=DownloadStation.
The one thing I check monthly is the size of downloads. A generous RSS filter fills a volume faster than you'd think.