33
33
-- %t ... iPTV channel name (user friendly stream title)
34
34
-- %T ... iPTV channel name in uppercase
35
35
36
+ local options = require (" mp.options" )
37
+ local utils = require (" mp.utils" )
38
+
36
39
-- defaults
37
40
local cfg = {
38
41
-- OSD text format
@@ -43,12 +46,25 @@ local cfg = {
43
46
ignorefilename = true
44
47
}
45
48
49
+ -- read lua-settings/show-stream-title.conf
50
+ options .read_options (cfg , ' show-stream-title' )
51
+
52
+ -- log active config
53
+ mp .msg .verbose (' cfg = ' .. utils .to_string (cfg ))
54
+
55
+ -- string v is empty
56
+ local function empty (v )
57
+ return not v or v == ' ' or string.find (v , " ^%s*$" )
58
+ end
59
+
46
60
-- check if string is valid title by cfg.valid pattern
47
61
-- valid: 'CP24,,0', 'TA News,,0'
48
62
-- invalid: 'index', 'DVR', 'iptv-streams.m3u8', 'rtmp://ip'
49
63
local function is_valid_title (s )
50
64
-- everything is valid (passthrough) if validation pattern is missing
51
65
if not cfg .valid then return true end
66
+ -- empty (nil) is invalid
67
+ if empty (s ) then return false end
52
68
-- validate with pattern
53
69
return string.match (s , cfg .valid )
54
70
end
66
82
-- [show_stream_title] property 'media-title' changed to 'index'
67
83
--
68
84
69
- -- string v is empty
70
- local function empty (v )
71
- return not v or v == ' ' or string.find (v , " ^%s*$" )
72
- end
73
-
74
85
-- format and show OSD forced media title val if not empty
75
86
local function force_media_title (name , val )
76
87
-- currently played filename
@@ -93,9 +104,9 @@ local function force_media_title(name, val)
93
104
end
94
105
95
106
-- pass as force media title if media title val is valid
96
- local function media_title (name , val )
107
+ local function media_title (name , val )
97
108
-- log
98
- mp .msg .info (" media_title(name:" .. name .. " , val:" .. val .. " )" )
109
+ mp .msg .info (" media_title(name:" .. name .. " , val:" .. utils . to_string ( val ) .. " )" )
99
110
-- val can be url (redirects ?)
100
111
if not is_valid_title (val ) then return end
101
112
0 commit comments