Skip to content

Instantly share code, notes, and snippets.

@gileri
Forked from selsta/autosub.lua
Created September 24, 2015 07:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gileri/c46d096f7f452eb4c556 to your computer and use it in GitHub Desktop.
Save gileri/c46d096f7f452eb4c556 to your computer and use it in GitHub Desktop.
Automatically download subtitles in mpv using subliminal.
-- requires subliminal, version 1.0 or newer
-- default keybinding: b
-- add the following to your input.conf to change the default keybinding:
-- keyname script_binding auto_load_subs
-- Forked from https://gist.github.com/selsta/ce3fb37e775dbd15c698
local utils = require 'mp.utils'
function load_sub_fn()
mp.msg.info("Searching subtitle")
mp.osd_message("Searching subtitle")
t = {}
t.args = {"subliminal", "-s", "-l", "en", "--", mp.get_property("path")}
res = utils.subprocess(t)
if res.status == 0 then
mp.commandv("rescan_external_files", "reselect")
mp.msg.info("Subtitle download succeeded")
mp.osd_message("Subtitle download succeeded")
else
mp.msg.warn("Subtitle download failed")
mp.osd_message("Subtitle download failed")
end
end
mp.add_key_binding("b", "auto_load_subs", load_sub_fn)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment