Skip to content

Commit cef46ac

Browse files
committed
select.lua: display commented titles in watch_later files
If --write-filename-in-watch-later-config is set and a title is written in the watch later file, display it in the Watch later menu.
1 parent 56cc83b commit cef46ac

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

player/lua/select.lua

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -517,9 +517,17 @@ mp.add_key_binding(nil, "select-watch-later", function ()
517517
for _, watch_later_file in pairs(watch_later_files) do
518518
local file_handle = io.open(watch_later_file)
519519
if file_handle then
520-
local line = file_handle:read()
521-
if line and line ~= "# redirect entry" and line:find("^#") then
522-
files[#files + 1] = {line:sub(3), utils.file_info(watch_later_file).mtime}
520+
local line1 = file_handle:read()
521+
local line2 = file_handle:read()
522+
if line1 and line1 ~= "# redirect entry" and line1:find("^#") then
523+
local entry = {
524+
path = line1:sub(3),
525+
time = utils.file_info(watch_later_file).mtime
526+
}
527+
if line2 and line2:find("^#") then
528+
entry.title = line2:sub(3)
529+
end
530+
files[#files + 1] = entry
523531
end
524532
file_handle:close()
525533
end
@@ -533,19 +541,19 @@ mp.add_key_binding(nil, "select-watch-later", function ()
533541
end
534542

535543
table.sort(files, function (i, j)
536-
return i[2] > j[2]
544+
return i.time > j.time
537545
end)
538546

539547
local items = {}
540-
for i, file in ipairs(files) do
541-
items[i] = os.date("(%Y-%m-%d) ", file[2]) .. file[1]
548+
for i, entry in ipairs(files) do
549+
items[i] = format_history_entry(entry)
542550
end
543551

544552
input.select({
545553
prompt = "Select a file:",
546554
items = items,
547555
submit = function (i)
548-
mp.commandv("loadfile", files[i][1])
556+
mp.commandv("loadfile", files[i].path)
549557
end,
550558
})
551559
end)

0 commit comments

Comments
 (0)