-
Notifications
You must be signed in to change notification settings - Fork 1
/
show-stream-title.lua
executable file
·80 lines (61 loc) · 2.24 KB
/
show-stream-title.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
-- local inspect = require('inspect')
function descriptor()
return {
title = 'Show Stream Title';
version = '0.1';
author = 'Dae';
url = 'https://github.com/EugeneDae/VLC-Show-Stream-Title';
description = 'Shows the title of the currently playing video stream '
.. 'using the built-in OSD functionality of VLC.';
shortdesc = 'Show Stream Title';
capabilities = {}
}
end
function main()
local item = nil
while true do
if vlc.volume.get() == -256 then break end
item = vlc.input.item()
if item and vlc.playlist.status() == 'playing' then
local meta = item:metas()
if meta.url then
if not meta.custom_title then
local parent = get_parent_for(vlc.playlist.current())
item:set_meta('custom_title', '(unknown)')
if parent then
local parent_meta = parent.item:metas()
if parent_meta.title then
item:set_meta('custom_title', parent_meta.title)
elseif meta.title then
item:set_meta('custom_title', meta.title)
end
end
meta = item:metas()
end
vlc.osd.message(meta.custom_title, 9999, 'bottom', 1.5 * 1000000)
end
end
sleep(1)
end
end
function sleep(sec)
vlc.misc.mwait(vlc.misc.mdate() + sec * 1000000)
end
function get_parent_for(item_id)
local playlist = vlc.playlist.get()
local result = nil
function finder(item)
if item.children then
for _, v in ipairs(item.children) do
if v.id == item_id then
result = item
break
end
finder(v)
end
end
end
finder(playlist)
return result
end
main()