autosub.lua - dotfiles - leot's dotfiles
 (HTM) hg clone https://bitbucket.org/iamleot/dotfiles
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
       autosub.lua
       ---
            1 -- requires subliminal, version 1.0 or newer
            2 -- default keybinding: b
            3 -- add the following to your input.conf to change the default keybinding:
            4 -- keyname script_binding auto_load_subs
            5 local utils = require 'mp.utils'
            6 function load_sub_fn()
            7     subl = "/usr/pkg/bin/subliminal-2.7" -- use 'which subliminal' to find the path
            8     mp.msg.info("Searching subtitle")
            9     mp.osd_message("Searching subtitle")
           10     t = {}
           11     t.args = {subl, "download", "-s", "-l", "en", mp.get_property("path")}
           12     res = utils.subprocess(t)
           13     if res.status == 0 then
           14         mp.commandv("rescan_external_files", "reselect") 
           15         mp.msg.info("Subtitle download succeeded")
           16         mp.osd_message("Subtitle download succeeded")
           17     else
           18         mp.msg.warn("Subtitle download failed")
           19         mp.osd_message("Subtitle download failed")
           20     end
           21 end
           22 
           23 mp.add_key_binding("b", "auto_load_subs", load_sub_fn)