-
Notifications
You must be signed in to change notification settings - Fork 174
Download Station
If you are using Download Station on your Synology, perform the following steps to configure postprocessing for "TorrentToMedia.py".
Copy new config file from sample (skip this step if you already have autoProcessMedia.cfg)
Copy the autoProcessMedia.cfg.sample to a new file called autoProcessMedia.cfg
and edit the parameters:
i. First step is to set the torrent client you are using. This tells the script which variables to expect when the script is called.
clientAgent = synods
ii. useLink - Set to hard for physical links, sym for symbolic links, move to move, and no to not use links (copy). For example:
useLink = move
iii. Default output directory. Categories will be appended as subdirectory to outputDirectory e.g. tv,movie
outputDirectory = /abs/path/to/complete/
iv. Other categories/labels defined for your downloader. Does not include CouchPotato, SickBeard, HeadPhones, Mylar categories. (make sure Download Station downloads to categories (Like TV) otherwise nzbToMedia does not know the category & how to process)
categories = music,music_videos,pictures,software
v. Synology Download Station
- synoHost = localhost
- synoPort = 5000
- synoUSR =
- synoPWD =
i. This next setting tells the script which file extensions you want to identify and extract. The usual settings are pretty safe.
compressedExtentions: .zip,.rar,.7z,.gz,.bz,.tar,.arj
ii. This setting lists all the media files you want to be processed. The default settings are usually pretty safe.
mediaExtentions: .mkv,.avi,.divx,.xvid,.mov,.mp4,.mpg,.mpeg,.vob,.iso #(.wmv removed due to spam)
iii. This setting lists all the other file extensions you want to be processed. Any other extensions will be ignored and cleaned up.
metaExtensions: .nfo,.sub,.srt,.jpg,.gif
ls -l /usr/syno/etc/packages/DownloadStation/download
here you should see settings.json
. If you don't see this file you should start a torrent download with Download Station and then the file will be created.
3. Stop Download Station from removing the settings.json file each time the service is stopped / NAS is rebooted
i. Edit the start-stop-status script that is used for Download Station:
nano /var/packages/DownloadStation/scripts/start-stop-status
ii. Find the line where the settings.json file is removed and comment it out (with a # hash) so that it looks like this:
# rm ${PACKAGE_DIR}/etc/download/settings.json
Edit settings.json: nano /usr/syno/etc/packages/DownloadStation/download/settings.json
"script-torrent-done-enabled": true,
"script-torrent-done-filename": "/path/to/TorrentToMedia.py",
7. This adjustment is not required for DSM 7.0. For DSM 5.1 to 6.2.4-xxxx, Enable Download Station AppArmor profile to execute script when a torrent completes
i. Edit the Download Station AppArmor profile.
nano /var/packages/DownloadStation/target/apparmor/pkg_DownloadStation
ii. Add TorrentToMedia.py to the AppArmor profile using rwux permissions so logs can be created and further dependencies can be executed.
#transmissiond
/volume*/@appstore/nzbToMedia{,**} rwux,
iii. Restart AppArmor to ensure new profile settings have been applied. You may need to do this each time DSM is re-started as this change to the above-mentioned profile is ignored at start-up. Only DSM defaults are loaded. To overcome this, go to Task Scheduler, create a Triggered Task as a 'User Defined Script' with Event: Boot-up, paste the following into the user-defined script section, and run the task.
sleep 30
/usr/syno/etc.defaults/rc.sysv/apparmor.sh stop
/usr/syno/etc.defaults/rc.sysv/apparmor.sh start
Note: sleep 30
will delay the 'User Defined Script' from running by 30 seconds, this may or may not be required on your NAS. You may need to extend this to 60 seconds depending on when this script is triggered in the boot order.
Note: although there is a restart option in DSM for this service, /usr/syno/etc.defaults/rc.sysv/apparmor.sh restart
will fail and eventually disable your web GUI login. You should stop & start the service separately as per the above.
Output from TorrentToMedia will be logged here /nzbToMedia/logs/nzbtomedia.log
/bin/python
can be symlinked to /volume1/@appstore/python3/bin/python3.5
which can be downloaded from the Synology Community Package Centre (Allan Clark).
Important note: Some functions of DSM still require python 2.7 i.e. deleting shared folders from the GUI, so you may need to change this back occasionally when deleting shares
To link to the latest version of python 3:
cd /bin
rm python
ln -s /volume1/@appstore/python3/bin/python3 python
To link back to the original DSM version of python 2.7
cd /bin
rm python
ln -s python2 python
AppArmor will prevent Download Station from executing scripts unless all executable paths and dependencies are listed in
/var/packages/DownloadStation/target/apparmor/pkg_DownloadStation
and the profile has been applied.
Depending on your environment, it may be difficult to determine exactly where the script may fail and exit should a path not be listed in this profile. To troubleshoot the issue, you can view the apparmor log...
nano /var/log/apparmor.log
and search for DENIED logs.
e.g. An apparmor="DENIED"
log that shows name="/volume1/@apstore/nzbToMedia/TorrentToMedia.py"
can be resolved by adding the following to /var/packages/DownloadStation/target/apparmor/pkg_DownloadStation
#transmissiond
/volume*/@appstore/nzbToMedia/{,**} rwux,
File permission access modes consists of combinations of the following modes:
r - read
w - write -- conflicts with append
a - append -- conflicts with write
ux - unconfined execute
Ux - unconfined execute -- scrub the environment
px - discrete profile execute
Px - discrete profile execute -- scrub the environment
cx - transition to subprofile on execute
Cx - transition to subprofile on execute -- scrub the environment
ix - inherit execute
m - allow PROT_EXEC with mmap(2) calls
l - link
k - lock