Skip to content

Commit

Permalink
select.lua: strip filename from the display of external track titles
Browse files Browse the repository at this point in the history
It doesn't make much sense to display them, streamline the display
as much as possible and avoid excessively long external titles
  • Loading branch information
dyphire committed Feb 23, 2025
1 parent deb27c0 commit 2b033f1
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion player/lua/select.lua
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,23 @@ local function format_flags(track)
end

local function format_track(track)
local title = track.title or ""
local filename = mp.get_property_native("filename/no-ext", "")
:gsub("[%(%)%.%%%+%-%*%?%[%]%^%$]", "%%%0")
local bitrate = track["demux-bitrate"] or track["hls-bitrate"]

if track.external and title ~= "" then
local extension = title:match("%.([^%.]+)$")
if filename ~= "" and extension then
title = title:gsub(filename .. "%.?", "")
end
if track.lang and title:lower() == track.lang:lower() .. "." .. extension:lower() then
title = extension:lower()
end
end

return (track.selected and "" or "") ..
(track.title and " " .. track.title or "") ..
(title ~= "" and " " .. title or "") ..
" (" .. (
(track.lang and track.lang .. " " or "") ..
(track.codec and track.codec .. " " or "") ..
Expand Down

0 comments on commit 2b033f1

Please sign in to comment.