Thu, 03/31/2016 - 16:37
[SMPlayer](http://www.smplayer.eu/) is powerful GUI for mplayer and for some time form mpv too. It already has UI for downloading subtitles from opensubtiles.org, but that's all you can do with online subtitles. Fortunately [mpv](https://mpv.io) comes to rescue with it's support for .lua scripts. On from pantheon of user scripts is [find_subtitles.lua](https://github.com/directorscut82/find_subtitles), which add option to download subtitles automatically after pressing one key. But not so fast, first you'll need python tool **subliminal**. ### Subliminal I've had some trouble installing this tool when I followed guide and used `pip install`, in case anyone has same problem, here is how I installed it from repository. Which brings one plus, I can use latest version from devel branch (I love having latest tools): ```bash git clone https://github.com/Diaoul/subliminal.git cd subliminal git checkout develop sudo python setup.py install ``` Now try if everything works fine by running `subliminal` you should see help. I case you want to use python3 version, just install it by `sudo python3 setup.py install`. Well, that's a good start, now how to use this with SMPlayer. ### SMPlayer + MPV lua scripts You can find quick guide on how to use find_subtitles in [repository](https://github.com/ra100/find_subtitles/). Download the [find_subtitles.lua](https://github.com/ra100/find_subtitles/blob/master/find_subtitles.lua) script to folder `~/.config/mpv/scripts`. Now just open mpv and download subtitles to currently playing video by pressing _s_. With SMPlayer it's a bit more complicated. I wasn't able to use keyboard shortcuts to control mpv script, so I decided to execute script on every file open. Then I just open video file, wait few seconds and voila, subtitles are there. I added to script just one line: ```lua mp.register_event("start-file", find_subtitles) ``` then I commented line 38 and uncommented line with addic7ed (I want to use this provided too), where I added my credentials ```lua local ss = os.capture("subliminal --addic7ed USER PASSWORD download --provider addic7ed --provider opensubtitles --provider podnapisi --provider thesubdb --provider tvsubtitles -l en -v '" .. mp.get_property("path") .. "'") ``` Lua script is ready, now we need to configure SMPlayer. MPV under SMPlayer is by default started without scripts, so we need to change one setting. In _Preferences_ (_CTRL+P_) -> _Advanced_ -> _Options for MPlayer/mpv_ add to _Options_ parameter which starts mpv with our script: ```bash --script ~/.config/mpv/scripts/find_subtitles.lua ``` That's it, now just open video and subtitles are downloaded automatically.