├── README.md ├── autosub.lua └── LICENSE /README.md: -------------------------------------------------------------------------------- 1 | # autosub-mpv 2 | -------------- 3 | 4 | ### Also checkout https://github.com/davidde/mpv-autosub wich seems better :smile: 5 | 6 | 7 | Automatically download subtitles in mpv using subliminal. 8 | 9 | 1. Install [subliminal](https://github.com/Diaoul/subliminal) 10 | 2. Put `autosub.lua` in `~/.config/mpv/scripts` 11 | 3. Start a video and press `b` to download a subtitle 12 | 13 | Fork from : https://gist.github.com/selsta/ce3fb37e775dbd15c698 14 | -------------------------------------------------------------------------------- /autosub.lua: -------------------------------------------------------------------------------- 1 | -- default keybinding: b 2 | -- add the following to your input.conf to change the default keybinding: 3 | -- keyname script_binding auto_load_subs 4 | local utils = require 'mp.utils' 5 | 6 | function display_error() 7 | mp.msg.warn("Subtitle download failed: ") 8 | mp.osd_message("Subtitle download failed") 9 | end 10 | 11 | function load_sub_fn() 12 | path = mp.get_property("path") 13 | srt_path = string.gsub(path, "%.%w+$", ".srt") 14 | t = { args = { "subliminal", "download", "-s", "-f", "-l", "en", path } } 15 | 16 | mp.osd_message("Searching subtitle") 17 | res = utils.subprocess(t) 18 | if res.error == nil then 19 | if mp.commandv("sub_add", srt_path) then 20 | mp.msg.warn("Subtitle download succeeded") 21 | mp.osd_message("Subtitle '" .. srt_path .. "' download succeeded") 22 | else 23 | display_error() 24 | end 25 | else 26 | display_error() 27 | end 28 | end 29 | 30 | mp.add_key_binding("b", "auto_load_subs", load_sub_fn) 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Yann Vaillant 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | --------------------------------------------------------------------------------