Downloading Subtitles for all media files on a Server

This guide is based on using CentOS 6 and running Python 2.7.

Firstly, install Python 2.7 onto your server:

yum install -y centos-release-SCL
yum install -y python27

Now enable python27 via scl enable (This will launch a new bash session using the more recent Python version) – You will need to do this again if you want to re-run this at a later date.

scl enable python27 bash

Now we will need to update pip setup tools and install the Subliminal Python package which will be doing the Subtitle downloads

pip install --upgrade setuptools

pip install subliminal

I will likely revisit this at some stage, but the best way I found to do this was to find all media files on your server (You can add extensions as required) and save these to a text file for use in your download script:

find /your-media/location/ -type f -name "*.mkv" -or -name "*.mp4" > /root/allmedia.txt

We can now tell your server to use new lines as the only break for the for loop and start the download of Subtitles (NOTE: Depending on the amount of files on your server, it may be worth running this command within screen so you can disconnect and leave it running. If you do this – You must run the scl command once more before proceeding):

IFS=$'\n'

for i in $(cat /root/allmedia.txt); do subliminal download -l en $i; done

Any comments or questions? Get in touch here or Email me at [email protected]