-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathyoutube-search-kdialog.lua
More file actions
36 lines (32 loc) · 896 Bytes
/
youtube-search-kdialog.lua
File metadata and controls
36 lines (32 loc) · 896 Bytes
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
--
-- Based on 'mpv-zenity-open-files'(https://github.com/alifarazz/mpv-zenity-open-files)
--
-- Default keybindings:
-- CTRL+SHIFT+s: search video in youtube.
--
table.unpack = table.unpack or unpack
utils = require 'mp.utils'
limit = 5
function invoke_kdialog(args)
return utils.subprocess({
args = { 'kdialog', table.unpack(args) },
cancellable = false,
})
end
function search_youtube()
local url_select = invoke_kdialog({
'--icon',
'mpv',
'--title',
'Search Youtube',
'--inputbox',
'Enter Search Text:'
})
if (url_select.status ~= 0) then
return
end
for filename in string.gmatch(url_select.stdout, '[^\n]+') do
mp.commandv('loadfile', "ytdl://ytsearch" .. limit .. ":" .. filename, 'append')
end
end
mp.add_key_binding("CTRL+SHIFT+s", "search_youtube", search_youtube)