History

{osc,select}.lua: show playlist entries with trailing /

If a playlist entry ends with a slash these scripts only show the basename which is empty. Fix this by stripping trailing slashes so that the last directory component becomes the basename.

Guido Cella committed 2 years ago

Commit ee058041 parent 67bd00f2 files · +8 −2Browse files

Showing the changes to player/lua/select.lua (1 of 2 files). Show all

Unified · Split

player/lua/select.lua+4−1
@@ -29,13 +29,16 @@ mp.add_forced_key_binding(nil, "select-playlist", function () · 28 unmodified lines
29 local playlist = {}29 local playlist = {}
30 local default_item30 local default_item
31 local show = mp.get_property_native("osd-playlist-entry")31 local show = mp.get_property_native("osd-playlist-entry")
32 local trailing_slash_pattern = mp.get_property("platform") == "windows"
33 and "[/\\]+$" or "/+$"
32 34
33 for i, entry in ipairs(mp.get_property_native("playlist")) do35 for i, entry in ipairs(mp.get_property_native("playlist")) do
34 playlist[i] = entry.title36 playlist[i] = entry.title
35 if not playlist[i] or show ~= "title" then37 if not playlist[i] or show ~= "title" then
36 playlist[i] = entry.filename38 playlist[i] = entry.filename
37 if not playlist[i]:find("://") then39 if not playlist[i]:find("://") then
38 playlist[i] = select(2, utils.split_path(playlist[i]))40 playlist[i] = select(2, utils.split_path(
41 playlist[i]:gsub(trailing_slash_pattern, "")))
39 end42 end
40 end43 end
41 if entry.title and show == "both" then44 if entry.title and show == "both" then

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t