Skip to content

Commit 9103443

Browse files
committed
fix loadfile error due to mpv changing it's syntax
fixes #3
1 parent ac14621 commit 9103443

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

selectformat.lua

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ local numshorten
6363
local sigcmp
6464
local is_network_stream
6565
local reload_resume
66+
local reload
6667
local update_ytdl_path
6768
local find_executable_path
6869
local get_ytdl_hook_opt_paths
@@ -980,7 +981,7 @@ function is_network_stream(path)
980981
end
981982

982983
-- this function is a modified version of mpv-reload's reload_resume()
983-
-- https://github.com/4e6/mpv-reload, commit c1219b6
984+
-- https://github.com/4e6/mpv-reload, commit 1a6a938
984985
function reload_resume()
985986
local pos = mp.get_property("time-pos")
986987
local duration = mp.get_property_native("duration")
@@ -993,9 +994,9 @@ function reload_resume()
993994
end
994995

995996
if pos and isnum(duration) and duration >= 0 then
996-
mp.commandv("loadfile", url, "replace", "start=+" .. pos)
997+
reload(url, pos)
997998
else
998-
mp.commandv("loadfile", url, "replace")
999+
reload(url, nil)
9991000
end
10001001

10011002
for i = 0, plpos - 1 do
@@ -1009,6 +1010,19 @@ function reload_resume()
10091010
end
10101011
end
10111012

1013+
function reload(path, timepos)
1014+
if timepos == nil then
1015+
mp.commandv("loadfile", path, "replace")
1016+
return
1017+
end
1018+
local success =
1019+
mp.commandv("loadfile", path, "replace", 0, "start=+" .. timepos) -- mpv >= v0.38.0
1020+
if not success then
1021+
mp.msg.warn("falling back to old loadfile syntax (mpv <= v0.37.0)")
1022+
mp.commandv("loadfile", path, "replace", "start=+" .. timepos) -- mpv <= v0.37.0
1023+
end
1024+
end
1025+
10121026
-- find the executable path of yt-dlp or youtube-dl and update the ytdl_path variable
10131027
function update_ytdl_path()
10141028
if ytdl_not_found then

0 commit comments

Comments
 (0)