Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Get external subtitle filename #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions sub-search.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Credits:
--]]

local auto_hide_console = true
local srt_file_extensions = {".srt", ".en.srt", ".eng.srt"}

------------- repl.lua -------------
-- repl.lua -- A graphical REPL for mpv input commands
Expand Down Expand Up @@ -703,15 +702,12 @@ function srt_time_to_seconds(time)
end

function open_subtitles_file()
local video_path = mp.get_property("path")
local srt_filename = video_path:gsub('\\','/'):match("^(.+)/.+$") .. "/" .. mp.get_property("filename/no-ext")
local srt_filename = mp.get_property("current-tracks/sub/external-filename")

for i, ext in ipairs(srt_file_extensions) do
local f, err = io.open(srt_filename .. ext, "r")
local f, err = io.open(srt_filename, "r")

if f then
return f
end
if f then
return f
end

return false
Expand Down