Since I know quite some people are looking for something like this, I decided to write a quick HOW-TO.
Please NOTE: Since Periscope does its searches based on the exact filename of the series (e.g House.S07E08.720p.HDTV.X264-DIMENSION.mkv) this solution will not work if you are using the post-processing/renaming features of SabNZBd or Sickbeard. So if you want this to work, you will have to disable renaming for now (until this tool is fully integrated into Sickbeard).
The steps:
In order to download Periscope onto Synology it's easiest to do so via SVN. In order to be able to install SVN, you first have to install ipkg if not already done so.
- Log on to your synology box (as root)
If you don't know how to do this, see here
- Install ipkg
See here
- Install svn
Once ipkg is installed, you can easily install SVN by running :
- Code: Select all
ipkg install svn
- Download periscope
cd to the directory you want to install periscope in. This can be anywhere, but for now I will assume /volume1/@appstore (The SVN checkout command will create a subdirectory below this directory)
- Code: Select all
cd /volume1/@appstore
now download periscope by running :
- Code: Select all
svn checkout http://periscope.googlecode.com/svn/trunk/ periscope
- Install python 2.6
- Code: Select all
ipkg install python26
- Install BeautifulSoup
BeautifulSoup is an HTML/XML parser that is used by periscope. To download it :
- Code: Select all
cd /volume1/@appstore/periscope
wget http://launchpad.net/beautifulsoup/3.2/3.2.0/+download/BeautifulSoup-3.2.0.tar.gz
unzip/untar it :
- Code: Select all
gunzip BeautifulSoup-3.2.0.tar.gz
tar -xvf BeautifulSoup-3.2.0.tar
remove the tar file as not needed anymore:
- Code: Select all
rm BeautifulSoup-3.2.0.tar
Now copy BeautifulSoup.py to the plugins directory of periscope
- Code: Select all
cp BeautifulSoup-3.2.0/BeautifulSoup.py periscope/plugins/
- Create simple python download command file
in /volume1/@appstore/periscope/periscope, create a file called downloadSub.py with following contents :
- Code: Select all
#!/opt/bin/python2.6
# -*- coding: utf-8 -*-
import periscope
import sys
import logging
logging.basicConfig(level=logging.DEBUG)
subdl = periscope.Periscope()
filepath = sys.argv[1]
subtitle = subdl.downloadSubtitle(filepath, ['nl','en']) # Dutch, and if not available try English
if subtitle :
print "Found a sub from %s in language %s, downloaded to %s" % ( subtitle['plugin'], subtitle['lang'], subtitle['subtitlepath'])
Either do this using vi if you're familiar with it, or use notepad, place it on a share and then copy it to the right location:
- Code: Select all
cp /volume1/public/downloadSub.py /volume1/@appstore/periscope/periscope/
also make sure downloadSub.py is executable :
- Code: Select all
chmod +x downloadSub.py
Note : the ['nl','en'] can be changed to the language(s) you want. In this case it will first try to obtain a Dutch subtitle. If not available it will try to download english subtitle.
- Test the download command by providing one of your existing series :
- Code: Select all
./downloadSub.py /volume1/video/Series/House/House.S07E08.720p.HDTV.X264-DIMENSION.mkv
As debugging is on, you should see all actions that are being performed to get the (dutch or english) subs. If succesfull, last line should be something like:
Found a sub from <plugins.BierDopje.BierDopje object at 0xf6f912ac> in language nl, downloaded to /volume1/video/Series/House/House.S07E08.720p.HDTV.X264-DIMENSION.srt
- Scan for subs for all videofiles
Obviously you don't want to manually run the downloadSub.py for every new download. You can probably add python code to scan all directories, but since I didn't want to spend too much time on it I just used something I'm familiar with.
- Code: Select all
cd /volume1/@appstore/periscope/periscope
find /volume1/video/Series/ \( -name *.avi -o -name *.mkv \) -mtime -7 -type f -exec ./downloadSub.py {} \;
(change /video/Series to the path you have stored your series)
This will scan the Series folder for all MKV and AVI files that were added in the last 7 days. You could also run the command only for series that do not have a SRT downloaded yet, but since I want the Dutch subs if they are available this method wouldn't work for me (i.e. when English sub already downloaded it would not try to get the Dutch one anymore).
Note: for 1st time run, you can just leave out the '-mtime -7', so it will scan all files instead of just the ones added in last 7 days.
Now to finish things off you can put these 2 lines in a scriptfile, say /volume1/@appstore/periscope/periscope/scanSeries.sh and put it in cron to run it every day.
To add the script to the cron scheduler, just add this line to /etc/crontab :
- Code: Select all
#minute hour mday month wday who command
0 19 * * * root /volume1/@appstore/periscope/periscope/scanSeries.sh >>/volume1/@appstore/periscope/periscope/scanSeries.log 2>&1
(command goes on 1 line)
make sure scanSeries.sh is executable :
- Code: Select all
chmod +x scanSeries.sh
now restart cron daemon:
- Code: Select all
/usr/syno/etc.defaults/rc.d/S04crond.sh stop
/usr/syno/etc.defaults/rc.d/S04crond.sh start
Every day at 19:00 the subs will now be downloaded.
Have fun:)
[Edit]
If you want to exclude some of the subtitle sources (i.e. because you know it will never find anything, or quality is always bad), you can do so by editing periscope/plugins/__init__.py and comment out the ones you don't want :
i.e. I only want to check Bierdopje and Addic7ed :
- Code: Select all
#from OpenSubtitles import OpenSubtitles
#from SubtitleSource import SubtitleSource
#from SubScene import SubScene
#from Subtitulos import Subtitulos
from Addic7ed import Addic7ed
#from Podnapisi import Podnapisi
#from TheSubDB import TheSubDB
from BierDopje import BierDopje
#from TvSubtitles import TvSubtitles
#from Podnapisi2 import Podnapisi
[edit 14-01-2011]
If you are using SickBeard and you want to include periscope into the sabToSickBeard.py post-processing, you can do the following :
(Note: this will probably not be so usefull when downloading the most recent episodes of a series since subs will not be available yet for most of them until 1-2 days after airdate)
- Create a file called 'sabToPeriscopeToSickBeard.py' in the same directory as sabToSickBeard.py with following contents :
- Code: Select all
#!/opt/bin/python2.6
import sys
sys.path.append("/volume1/@appstore/periscope/periscope")
import autoProcessTV
import periscope
import os
import glob
import logging
logging.basicConfig(level=logging.ERROR)
if len(sys.argv) < 2:
print "No folder supplied - is this being called from SABnzbd?"
sys.exit()
DOWNLOADPATH=sys.argv[1]
filelist=glob.glob(DOWNLOADPATH+"/*.avi")+glob.glob(DOWNLOADPATH+"/*.mkv")
for file in filelist:
print "Trying to find subs for %s" % (file)
subdl = periscope.Periscope()
subtitle = subdl.downloadSubtitle(file, ['nl','en']) # Dutch, and if not available try English
if subtitle :
print "----------------------------------------------------------------------------------------------------------------"
print "Found a sub in language %s, downloaded to %s" % ( subtitle['lang'], subtitle['subtitlepath'])
print "----------------------------------------------------------------------------------------------------------------"
print "Now handing over postprocessing to SickBeard.."
if len(sys.argv) >= 3:
autoProcessTV.processEpisode(sys.argv[1], sys.argv[2])
else:
autoProcessTV.processEpisode(sys.argv[1])
Note: update the path to periscope in this script to the location you have installed it to.
- Make script executable :
- Code: Select all
chmod +x sabToPeriscopeToSickBeard.py
- Make sure you have enabled 'Move Associated Files' in SickBeard (Config -> Episode Downloads)
- in SAB, change the script of the user defined category that is used by SickBeard (usually 'TV') from 'sabToSickBeard.py' to 'SabToPeriscopeToSickBeard.py' via the dropdown menu
That's it, from now on for any new download periscope will try to get the NL/EN sub.




