6
6
-- (see mpv doc for more details, lookup playlist/N/current, playlist/N/playing )
7
7
-- To display correct stream2.title from playlist use this script.
8
8
--
9
+ -- Note: Optional stream specific mpv properties can be set in the second comma separated section.
10
+ -- For example to activate subtitles id 1 and audio id 2 for "Film Europe" use playlist line:
11
+ -- #EXTINF:0,Film Europe,sid="1" aid="3",0
12
+ --
9
13
-- Note: 'force-media-title' property get updated also with empty value so
10
14
-- testing for empty value is required before formatting and OSDing
11
15
--
@@ -41,7 +45,7 @@ local cfg = {
41
45
-- OSD text format
42
46
format = " %N. %t" ,
43
47
-- validate title from playlist (empty for passthrough = valid all)
44
- valid = " ^.+,,0$" ,
48
+ valid = " ^.+,.* ,0$" ,
45
49
-- ignore title matching filename property
46
50
ignorefilename = true
47
51
}
@@ -50,13 +54,29 @@ local cfg = {
50
54
options .read_options (cfg , ' show-stream-title' )
51
55
52
56
-- log active config
53
- mp .msg .verbose (' cfg = ' .. utils .to_string (cfg ))
57
+ mp .msg .verbose (' cfg = ' .. utils .to_string (cfg ))
54
58
55
59
-- string v is empty
56
60
local function empty (v )
57
61
return not v or v == ' ' or string.find (v , " ^%s*$" )
58
62
end
59
63
64
+ -- key,val iterator from string key1="val1" key2="val2"
65
+ local function key_val_iter (s )
66
+ -- start idx
67
+ local idx = 0
68
+ -- closure
69
+ return function ()
70
+ -- extract key,val from string key="val"
71
+ _ , idx , key , val = string.find (s , ' ([%w-]+)="([^"]+)"' , idx )
72
+ -- return found key/val
73
+ if idx then
74
+ mp .msg .verbose (" found key(" .. key .. " ) = val(" .. val .. " ) at idx:" .. idx )
75
+ return key , val
76
+ end
77
+ end
78
+ end
79
+
60
80
-- check if string is valid title by cfg.valid pattern
61
81
-- valid: 'CP24,,0', 'TA News,,0'
62
82
-- invalid: 'index', 'DVR', 'iptv-streams.m3u8', 'rtmp://ip'
@@ -113,6 +133,12 @@ local function media_title(name, val)
113
133
-- SMPlayer playlist val = 'Title,,0'
114
134
-- playlist val = 'Title'
115
135
136
+ -- set custom stream options
137
+ for pname ,pval in key_val_iter (val ) do
138
+ mp .msg .info (" set_property(" .. pname .. " , " .. pval .. " )" )
139
+ mp .set_property (pname , pval )
140
+ end
141
+
116
142
-- get comma position or entire length
117
143
local compos = string.find (val .. " ," , " ," )
118
144
-- strip commas from stream title
0 commit comments