Let’s work together

Feel free to send me an email at [email protected]

Research Campus 18
3500 Hasselt

Subliminal on QNAP

Subliminal on QNAP

Installing Subliminal

So installing Subliminal on QNAP (in my case, a QNAP 412 Turbo Nas) isn’t out of the box with qpkg’s like for example SickBeard, CouchPotato or SABnzbd. For all who’s wondering, these tools are the ultimate combination for managing and updating your media library.

Subliminal is the successor of Periscope, also written in Python. It allows your to download subtitles for movies/tv shows fairly easy. Here’s a quick install guide.

First, connect to your NAS via SSH with the ‘admin’ user.
Next, make sure you update your IPKG’s + add some new ones:

ipkg update                             
ipkg upgrade                            
ipkg install git                         
ipkg install textutils	                
ipkg install python27	                
ipkg install py27-setuptools	    
ipkg install mlocate

So now you’ve got all the utlities you need so let’s download the latest version of Subliminal:

git clone -b master https://github.com/Diaoul/subliminal.git /tmp/subliminal

Now let’s install Subliminal.

cd /tmp/subliminal
/opt/bin/python2.7 setup.py install

You now should have a working copy of Subliminal on your NAS. Now how do you use this wonderful piece of software?

You can manually retrieve subs using this command:

# subliminal -l LANG DIR
subliminal -l en /Qmultimedia/Movies/

But here’s a better way. We’re lazy right?

Automating Subliminal with Sickbeard and Couchpotato

1) using cronjobs
Cronjobs is a command/script which runs regularly. Normally you’d use crontab for this, but QNAP automatically cleans this each reboot..
So according to their docs, we’ll have to do some other way. We’ll pick method 1.

echo "1 22,0 * * * /share/MD0_DATA/.qpkg/Optware/local/bin/subliminal -l en /Qmultimedia/Movies/" >> /etc/config/crontab
echo "#1 22,0 * * * /share/MD0_DATA/.qpkg/Optware/local/bin/subliminal -l en /Qmultimedia/Series/" >> /etc/config/crontab
crontab /etc/config/crontab

You now have a cronjob which checks for new subtitles for new movies at 22 and 24 hour each day. Don’t overdo do this, since you’re basicly scraping all the subtitle sites. Once or twice a day should do.

2) using extrascripts
Currently only sickbeard has this well documented.
Using the ‘locate’ command I found out where my SickBeard install is located.

cd /share/MD0_DATA/.qpkg/SickBeard/
vim config.ini

And find the extrascript and replace it with:

extra_scripts = "findSubs.sh"

Now create this script:

vim findSubs.sh

Insert script

# http://code.google.com/p/sickbeard/wiki/AdvancedSettings
subliminal -l en $1

Now quit vim and chmod this bash script.

chmod +x findSubs.sh

Congrats! Sickbeard will now automaticlly call this script as soon as an episode is downloaded meaning you will have subtitles almost directly after downloading them.

I noticed these cronjobs aren’t always running.. after quite some debugging I found a workaround. The reason the cronjobs aren’t working is because Subliminal is having problems scanning directories with lots of media. Here’s how I fixed it:

1 22,0 * * * /share/MD0_DATA/Multimedia/_crons/subs_series.sh
10 22,0 * * * /share/MD0_DATA/Multimedia/_crons/subs_movies.sh


find /Qmultimedia/Series/ -type d | while read dir;
        /share/MD0_DATA/.qpkg/Optware/local/bin/subliminal -l en "$dir" --cache-dir /Qmultimedia/_crons/cache/
        echo "$dir"
touch /Qmultimedia/_crons/logs/series_`date +%Y-%m-%d-%H-%M-%S`-cron.log


find /Qmultimedia/Movies/ -type d | while read dir;
        /share/MD0_DATA/.qpkg/Optware/local/bin/subliminal -l en "$dir" --cache-dir /Qmultimedia/_crons/cache/
        echo "$dir"
touch /Qmultimedia/_crons/logs/movies_`date +%Y-%m-%d-%H-%M-%S`-cron.log