Commit f4827eb2 authored by Jean-Philippe André's avatar Jean-Philippe André

Lua: fix IMDb script and listen to input changes

parent 4a50f0a7
...@@ -32,12 +32,12 @@ function descriptor() ...@@ -32,12 +32,12 @@ function descriptor()
.. "Movie Database (IMDb).\nThis Extension will show " .. "Movie Database (IMDb).\nThis Extension will show "
.. "you the cast, a short plot summary and a link to " .. "you the cast, a short plot summary and a link to "
.. "the web page on imdb.org." ; .. "the web page on imdb.org." ;
capabilities = {} } capabilities = { "input-listener" } }
end end
-- Update title text field. Removes file extensions. -- Update title text field. Removes file extensions.
function update_title() function update_title()
local item = vlc.item() local item = vlc.input.item()
local title = item and item:name() local title = item and item:name()
if title ~= nil then if title ~= nil then
title = string.gsub(title, "(.*)(%.%w+)$", "%1") title = string.gsub(title, "(.*)(%.%w+)$", "%1")
...@@ -47,11 +47,15 @@ function update_title() ...@@ -47,11 +47,15 @@ function update_title()
end end
end end
function input_changed()
update_title()
end
function create_dialog() function create_dialog()
dlg = vlc.dialog("IMDb Search") dlg = vlc.dialog("IMDb Search")
dlg:add_label("The Internet Movie Database", 1, 1, 4, 1) dlg:add_label("The Internet Movie Database", 1, 1, 4, 1)
dlg:add_label("<b>Movie Title</b>", 1, 2, 1, 1) dlg:add_label("<b>Movie Title</b>", 1, 2, 1, 1)
local item = vlc.item() local item = vlc.input.item()
txt = dlg:add_text_input(item and item:name() or "", 2, 2, 1, 1) txt = dlg:add_text_input(item and item:name() or "", 2, 2, 1, 1)
dlg:add_button("Okay", "click_okay", 3, 2, 1, 1) dlg:add_button("Okay", "click_okay", 3, 2, 1, 1)
dlg:add_button("*", "update_title", 4, 2, 1, 1) dlg:add_button("*", "update_title", 4, 2, 1, 1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment