Skip to content

Commit

Permalink
脚本: playlist_osd 修复m3u列表显示的特例
Browse files Browse the repository at this point in the history
  • Loading branch information
hooke007 committed May 18, 2024
1 parent 3bc3728 commit 2027fb8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion portable_config/script-opts.conf
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@
##播放列表的字体样式,下方为示例。留空则使用 mpv.conf 中的OSD设置
## {\fnUbuntu\fs10\b0\bord1} 相当于 font=Ubuntu, size=10, bold=no, border=1
##格式参考 https://aeg-dev.github.io/AegiSite/docs/3.2/ass_tags/
script-opts-append = playlist_osd-style_ass_tags={\rDefault\an7\fs12\b0\blur0\bord1\1c&H996F9A\3c&H000000\q2}
script-opts-append = playlist_osd-style_ass_tags={\rDefault\an7\fs24\b0\blur0\bord1\1c&H996F9A\3c&H000000\q2}
##播放列表标题(字符串之后将添加一个换行),下方为示例(默认值)。
## %mediatitle or %filename = 标题或当前播放的文件名 ; %pos = 当前播放文件的位置
## %cursor = 导航的位置 ; %plen = 列表长度 ; %N = 换行
Expand Down
2 changes: 1 addition & 1 deletion portable_config/script-opts/playlist_osd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ slice_longfilenames_amount=80
## {\fnUbuntu\fs10\b0\bord1} 相当于 font=Ubuntu, size=10, bold=no, border=1
##格式参考 https://aeg-dev.github.io/AegiSite/docs/3.2/ass_tags/
##留空则使用 mpv.conf 中的OSD设置
style_ass_tags={\rDefault\an7\fs12\b0\blur0\bord1\1c&H996F9A\3c&H000000\q2}
style_ass_tags={\rDefault\an7\fs24\b0\blur0\bord1\1c&H996F9A\3c&H000000\q2}

##播放列表标题(字符串之后将添加一个换行)示例即默认值
## %mediatitle or %filename = 标题或当前播放的文件名
Expand Down
11 changes: 3 additions & 8 deletions portable_config/scripts/playlist_osd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ local settings = {
slice_longfilenames = false,
slice_longfilenames_amount = 80,

style_ass_tags = "{\\rDefault\\an7\\fs12\\b0\\blur0\\bord1\\1c&H996F9A\\3c&H000000\\q2}",
style_ass_tags = "{\\rDefault\\an7\\fs24\\b0\\blur0\\bord1\\1c&H996F9A\\3c&H000000\\q2}",
playlist_header = "播放列表 [%cursor/%plen]",
normal_file = "{\\c&HFFFFFF&}□ %name",
hovered_file = "{\\c&H33FFFF&}■ %name",
Expand Down Expand Up @@ -158,9 +158,8 @@ function get_name_from_index(i, notitle)
local title = mp.get_property("playlist/" .. i .. "/title")
local name = mp.get_property("playlist/" .. i .. "/filename")

local should_use_title = settings.prefer_titles == "all" or is_protocol(name) and settings.prefer_titles == "url"
--check if file has a media title stored or as property
if not title and should_use_title then
if not title then
local mtitle = mp.get_property("media-title")
if i == pos and mp.get_property("filename") ~= mtitle then
if not title_table[name] then
Expand All @@ -173,7 +172,7 @@ function get_name_from_index(i, notitle)
end

--if we have media title use a more conservative strip
if title and not notitle and should_use_title then
if title and not notitle then
-- Escape a string for verbatim display on the OSD
-- Ref: https://github.com/mpv-player/mpv/blob/94677723624fb84756e65c8f1377956667244bc9/player/lua/stats.lua#L145
return stripfilename(title, true):gsub("\\", "\\\239\187\191"):gsub("{", "\\{"):gsub("^ ", "\\h")
Expand Down Expand Up @@ -240,10 +239,6 @@ function draw_playlist()
refresh_globals()
local ass = assdraw.ass_new()

local _, _, a = mp.get_osd_size()
local h = 360
local w = h * a

ass:append(settings.style_ass_tags)

if settings.playlist_header ~= "" then
Expand Down

0 comments on commit 2027fb8

Please sign in to comment.