Subtitles are important

I’m a such a TV series fanboy.

dot SRT files are like icing/cherry (whichever’s available) and I love them. The problem with subtitles are, YOU HAVE TO DOWNLOAD THEM. It is like a seven steps procedure.

Open browser

Go to a subtitles portal

Search

Refine search

Download the zip

Unzip

Drag and drop

Okay, that’s exactly seven steps. Cool.

So back to the problem. I’m too lazy for even two steps, seven’s godforsaken. That’s why during my rewatch of Charlie Sheen’s Anger Management, I sat my ass at 5AM to write a Python script to fetch me subtitles for all the rest of the episodes I haven’t watched.

This works on the basic FETCH request for SRT files and downloading them in the same folder as the video file.

Now, not all subtitles portal have their own simple API. Luckily, there’s SubDB. There have this awesome tree library and a really simple API method called “download”, which as anyone can presume, downloads the subtitle for requested hash function.

Hash function? Hehe. Yes, its calculated by taking the first and last 64Kb of a video file, putting them together and generating a MD5 of the resultant.

 readsize = 64 * 1024

Then we simply request for a related subtitle file and use a function, here “download” to, well, download the file.

Now, it order to make it available for all other video files like movies, TED etc, I used Automator in Mac OS X to create a Service “Fetch Subs”. So whenever I need subtitles for a new movie I downloaded, all I have to do is Right Click >> Services >> Fetch Subs.

The Fetch Subs option is actually a simple shell script, defined just to fetch English language subtitles of the relevant catch.

 IFS_BAK=$IFS
 IFS=" "
 for line in $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS; do
    full_path="/home/Rishiraj/Documents/subtitle/"subsfetch.py
    python $full_path $line 
    notify-send $line
 done
 IFS=$IFS_BAK

What’s left of the work is to give it a bar. A roadblock. For example, it will return error functions if used on a non-video file. So barring the shell function to only .MP4 or .MOV files will be beneficiary.

Another option can be a choice for Language. This will be kinky, as user might have to select language for the subtitles every time he runs the script. Maybe we can do a two step Automation for this. Like a default choice (English) and an another choice (?).

 
7
Kudos
 
7
Kudos

Now read this

Recruitment is a joke

I always wanted to start up. But when I joined college, I was introduced to a new, hostile concept where a menial job, paying quarter a million rupees per year was everything to a student. Placements, they called it. It is a ceremonial... Continue →