Finding subtitles for ripped or downloaded videos isn't terribly complicated. Most of the time it involves a quick search at sites like OpenSubtitles or Subscene for a particular TV show or movie, and filtering through language options. It's not a lot of work but it isn't the most efficient either when dealing with a large video library.
Subtitles by Rainy Cape can shave a few seconds off the whole process by making it as simple as dragging and dropping a video file. It's not the only program of its kind but earns a few points in my book for being cross-platform and for its no frills UI. Basically, you just need to drag a video onto it, and Subtitles will query the OpenSubtitles database for a match to download onto the same directory as the video file.
Since we're already optimizing why not take it to the next level and make subtitle fetching 100% hands off? With the help of a couple handy tools – AHK in Windows and Automator or Hazel in OS X – we certainly can.
Windows
Many of you are probably already familiar with AutoHotKey. This small and free utility lets you automate tasks and streamline your workflow. The program is driven by a custom scripting language that's easy to understand – even for someone with little or no coding experience. But don't let this perceived simplicity fool you. AHK can handle some complex stuff too and a vibrant community behind it has made sure to unleash its potential.
A few days ago I set out to create a script that would monitor a folder within Windows so whenever a movie file was dropped into it, AHK would automatically open said file with the Subtitles app. That's zero interaction on your side, and most of the time subtitles will already be there whenever you're ready to start playing a video.
Luckily a lot of the underlying functionality was already taken care of – you'll need to save the WatchDirectory, Struct and sizeof scripts onto the Lib folder under your AHK installation. Once that's ready this will get the job done:
#persistent
WatchDirectory("C:\Users\YourUser\YourWatchedFolder*|.mkv|.avi|.mp4","OpenFileWith")
return
#g::
WatchDirectory("")
ExitApp
Return
OpenFileWith(from, to){
static obj:=[]
if (from=""||(from&&to&&from!=to)){
obj.Insert(to)
SetTimer,launch,-1000
}
return
launch:
If f:=FileOpen(obj[obj.MaxIndex()],"w"){
f:=""
Run % """C:\Program Files (x86)\Subtitles\Contents\Windows\Subtitles.exe"" """ obj.Remove() """"
}
if obj.MaxIndex()
SetTimer,launch,-1000
return
}
Download: FetchSubtitles.ahk (Kudos to HotKeyIt for helping out with the script)
For the purpose of settings things up all you'll need to understand and configure is that second line. The first half is the directory to watch so be sure to configure your own and include a * at the end to watch subfolders.
Right after that you can specify file extensions separated by pipe '|' and a back slash at the end to mark the end of a file name. In this case, "|.mkv|.avi|.mp4". Leave the rest untouched (except maybe the Subtitles.exe directory if you installed the application someplace else). Save the script as a .ahk file and run it.
Now anytime you finish downloading a video into your watched folder, Subtitles will fetch the appropriate .srt file for it and download it into the same directory. There's still room for improvement – i.e. making Subtitles app launch in the background and quit when it's idle / done downloading subtitles – but as a first approach, it works.
OS X Method 1: Automator
Things are a little easier on OS X and you don't need to install third-party software. Instead, you can create a folder action with Automator and assign it to whichever directory you'll be monitoring for movies.
Create a new Automator document, for type choose Folder Action, and assign a folder to it from the pull down over at the top of the right side panel. Then, drag the following actions into your workflow, in the same order:
- Get Folder Contents. Tick the box that says 'Repeat for each subfolder found'.
- Wait for files to copy. This action isn't included by default in Automator, unfortunately, but you can download it for free here. As the name suggests, what this'll do is keep the rest of the workflow from running until all files have been copied – useful when transferring large files between disks or over the network. Enter all file types you want to look out for in the 'Name Extensions' field (i.e. mkv, avi, mp4).
- Open Finder Items. Select 'Open with Subtitles' from the pull down.
That alone will do the trick but you can take it a step further adding a fourth action, Run AppleScript, to make sure Subtitles runs in the background and quits after a set amount of time. The code to do that is as follows:
tell application "Finder"
set visible of process "Subtitles" to false
end tell
delay 30 – (set this to whatever you like, in seconds)
tell application "Subtitles"
quit
end tell
OS X Method 2: Hazel
Hazel is a super useful system preference pane that lets you monitor specific folders and trigger actions whenever files are added to it or modified. Its main duty is to keep your Mac clean by moving files around or tagging them according to your organization strategy – i.e. archiving old files, flagging unused applications for removal based on last open date, automatically moving downloads to a folder based on file type, and so on.
It costs $28 but there's people that swear by it. A free 14-day trial might help you decide if it's for you. If you're already a Hazel user here are two simple rules you can assign to a folder for automatic subtitle downloads.
- Check subfolders. Makes sure it looks for files within sub directories, not just the root.
- Fetch Subtitles. Watch for movie files to open with Subtitles.