* UPDATED to subliminal 0.8.0-dev (22-06-2014) *
* UPDATED to subliminal 2.0.5 (28-09-2018) *
A short write-up on how to automate the download of subtitles for every new episode that Sickbeard is queueing with SABNZBD.
First of all, for this to work, I assume you already have:
- Obviously a QNAP
- qpkg installed for Sickbeard and SABNZBD
As Subliminal is not part of the qpkg tree we need to first get, compile and install it. This is done by using the ipkg tree and installing additional tools.
1. Install the OPTWARE qpkg. In the QNAP adminstration interface -> Applications -> QPKG Center
2. Connect to the QNAP via SSH and update and upgrade the ipkg tree by using the following commands:ipkg update
3. Make sure you have the most recent versions of git, python tools and textutils installed, if not, run the following commands:ipkg install python27
ipkg install py27-setuptools
ipkg install git
ipkg install textutils
4. Fetch and install the Subliminal package:git clone -b master https://github.com/Diaoul/subliminal.git /tmp/subliminal
/opt/bin/python2.7 setup.py install
5. Now, using your favo editor (I use vim), you have to create the following file “subtitles.sh”. This will fetch the Dutch subtitle and if this is not available the secondary language is English.
UPDATE: When you update from version 0.6 to 0.8 like I just did the original script doesn’t work anymore due to a syntax change, make sure you remove/add the bits in red below.vim subtitles.sh
#!/bin/sh echo Filename to process. $1 echo Original filename... $2 echo Show TVDB id........ $3 echo Season number....... $4 echo Episode number...... $5 echo Episode air date.... $6 echo ... pass the episode info to Subliminal and fetch the subtitle /opt/local/bin/subliminal
--cache-dir /share/MD1_DATA/subliminal-l nl -l en -- "$1" As you can see my cache dir is placed on the MD1_DATA volume. If you only have one set of disks in a volume this will probably be MD0_DATA.
Subliminal uses a cache file out-of-the-box, instead of a defined cache directory, which is located at /root/.cache/subliminal/cli.dbm
6. Integration with Sickbeard is done by editing the config.ini and adding this script to the post processing part.
First copy the script to the Sickbeard scripts location (again, in my case this is on MD1_DATA)cp subtitles.sh /share/MD1_DATA/.qpkg/SickBeard/AutoProcessTV/
Now SHUTDOWN Sickbeard otherwise the changes to the running config will NOT be applied!vim /share/MD1_DATA/.qpkg/SickBeard/config.ini
Find the line that says:
extra_scripts = ""
and change it into:
extra_scripts = "/share/MD1_DATA/.qpkg/SickBeard/AutoProcessTV/subtitles.sh"
Save the file and start Sickbeard. Well that’s it, if you queue an episode Sickbeard will automagically find and download the correct subtitle, rename it according to the episode and move it to the correct folder as well.
The following bit shows the entire process in the logging for an episode of Modern Family, down the bottom you see subtitles.sh script in action:
Loading config from /share/MD1_DATA/.qpkg/SickBeard/autoProcessTV/autoProcessTV.cfg Opening URL: http://localhost:7071/home/postprocess/processEpisode?nzbName=Modern.Family.S04E09.720p.WEB-DL.DD5.1.H.264-HWD.nzb&quiet=1&dir=%2Fshare%2FMD1_DATA%2FDownload%2Fsabnzbd%2Fcomplete%2FTV%2FModern.Family.S04E09.720p.WEB-DL.DD5.1.H.264-HWD Processing folder /share/MD1_DATA/Download/sabnzbd/complete/TV/Modern.Family.S04E09.720p.WEB-DL.DD5.1.H.264-HWD Processing /share/MD1_DATA/Download/sabnzbd/complete/TV/Modern.Family.S04E09.720p.WEB-DL.DD5.1.H.264-HWD/Modern.Family.S04E09.720p.WEB-DL.DD5.1.H.264-HWD.mkv (Modern.Family.S04E09.720p.WEB-DL.DD5.1.H.264-HWD.nzb) Found result in history: (95011, 4, ) Parsed Modern.Family.S04E09.720p.WEB-DL.DD5.1.H.264-HWD.nzb into Modern Family - S4E9 - 720p.WEB-DL.DD5.1.H.264 (HWD) [ABD: False] Checking scene exceptions for a match on Modern Family Looking up Modern Family in the DB Lookup successful, using tvdb id 95011 Loading show object for tvdb_id 95011 Retrieving episode object for 4x9 The old status had a quality in it, using that: 720p WEB-DL SB snatched this episode so I'm marking it as priority Is ep a priority download: True File /share/MD1_DATA/Multimedia/Seriezz/Modern Family/Season 04/Modern Family - 4x09 - When a Tree Falls.mkv doesn't exist so there's no worries about replacing it This download is marked a priority download so I'm going to replace an existing file if I find one Deleting file /share/MD1_DATA/Multimedia/Seriezz/Modern Family/Season 04/Modern Family - 4x09 - When a Tree Falls.mkv Found release name Modern.Family.S04E09.720p.WEB-DL.DD5.1.H.264-HWD Destination folder for this episode: /share/MD1_DATA/Multimedia/Seriezz/Modern Family/Season 04 Moving file from /share/MD1_DATA/Download/sabnzbd/complete/TV/Modern.Family.S04E09.720p.WEB-DL.DD5.1.H.264-HWD/Modern.Family.S04E09.720p.WEB-DL.DD5.1.H.264-HWD.mkv to /share/MD1_DATA/Multimedia/Seriezz/Modern Family/Season 04/Modern Family - 4x09 - When a Tree Falls.mkv Executing command ['/share/MD1_DATA/.qpkg/SickBeard/autoProcessTV/findsubs.sh', u'/share/MD1_DATA/Multimedia/Seriezz/Modern Family/Season 04/Modern Family - 4x09 - When a Tree Falls.mkv', u'/share/MD1_DATA/Download/sabnzbd/complete/TV/Modern.Family.S04E09.720p.WEB-DL.DD5.1.H.264-HWD/Modern.Family.S04E09.720p.WEB-DL.DD5.1.H.264-HWD.mkv', '95011', '4', '9', '2012-11-28'] Absolute path to script: /share/MD1_DATA/.qpkg/SickBeard/autoProcessTV/subtitles.sh Script result: Filename to process. /share/MD1_DATA/Multimedia/Seriezz/Modern Family/Season 04/Modern Family - 4x09 - When a Tree Falls.mkv Original filename... /share/MD1_DATA/Download/sabnzbd/complete/TV/Modern.Family.S04E09.720p.WEB-DL.DD5.1.H.264-HWD/Modern.Family.S04E09.720p.WEB-DL.DD5.1.H.264-HWD.mkv Show TVDB id........ 95011 Season number....... 4 Episode number...... 9 Episode air date.... 2012-11-28 ... pass the episode info to Subliminal and fetch the subtitle WARNING: root Some characters could not be decoded, and were replaced with REPLACEMENT CHARACTER. WARNING: root Some characters could not be decoded, and were replaced with REPLACEMENT CHARACTER. ************************************************** Downloaded 1 subtitle(s) for 1 video(s) /share/MD1_DATA/Multimedia/Seriezz/Modern Family/Season 04/Modern Family - 4x09 - When a Tree Falls.srt from bierdopje ************************************************** Deleting folder /share/MD1_DATA/Download/sabnzbd/complete/TV/Modern.Family.S04E09.720p.WEB-DL.DD5.1.H.264-HWD Processing succeeded for /share/MD1_DATA/Download/sabnzbd/complete/TV/Modern.Family.S04E09.720p.WEB-DL.DD5.1.H.264-HWD/Modern.Family.S04E09.720p.WEB-DL.DD5.1.H.264-HWD.mkv
Of course, just like me, you already downloaded series. Well you can manually run the subtitles.sh script as well. I recommend doing this for each series separately and not all at once!
UPDATE: check the syntax change in red (double minus!).
Go into the directory where you keep your episodes:
subliminal –opensubtitles <your_opensubtitles_user> <your_opensubtitles_password> download * -l nl -l en
One more thing to make this work! Appearently the subtitles need to be set executable for players as VLC to work otherwise you get all sorts of errors. So in the directory that contains the series run the following command:chmod +rx *.srt