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

Lua: use the spin icon in Allocine

parent 15f94976
...@@ -31,6 +31,7 @@ message = nil -- Label ...@@ -31,6 +31,7 @@ message = nil -- Label
list = nil -- List widget list = nil -- List widget
okay = nil -- Okay button okay = nil -- Okay button
html = nil -- HTML box html = nil -- HTML box
spin = nil -- spinning icon
films = {} films = {}
-- Extension description -- Extension description
...@@ -82,6 +83,7 @@ function create_dialog() ...@@ -82,6 +83,7 @@ function create_dialog()
dlg:add_label("<b>Titre du film:</b>", 1, 1, 1, 1) dlg:add_label("<b>Titre du film:</b>", 1, 1, 1, 1)
title = dlg:add_text_input(get_title(), 2, 1, 1, 1) title = dlg:add_text_input(get_title(), 2, 1, 1, 1)
dlg:add_button("Rechercher", click_chercher, 3, 1, 1, 1) dlg:add_button("Rechercher", click_chercher, 3, 1, 1, 1)
spin = dlg:add_spin_icon(4, 1, 1, 1)
end end
-- Get clean title from filename -- Get clean title from filename
...@@ -129,7 +131,7 @@ function click_chercher() ...@@ -129,7 +131,7 @@ function click_chercher()
-- Please wait... -- Please wait...
local message_text = "Recherche <a href=\"" .. url .. "\">" .. string.gsub(name, "%+", " ") .. "</a> sur Allociné..." local message_text = "Recherche <a href=\"" .. url .. "\">" .. string.gsub(name, "%+", " ") .. "</a> sur Allociné..."
if not message then if not message then
message = dlg:add_label(message_text, 1, 2, 3, 1) message = dlg:add_label(message_text, 1, 2, 4, 1)
else else
message:set_text(message_text) message:set_text(message_text)
end end
...@@ -139,12 +141,17 @@ function click_chercher() ...@@ -139,12 +141,17 @@ function click_chercher()
list = nil list = nil
okay = nil okay = nil
html = nil html = nil
-- Show progress
spin:animate()
dlg:update() dlg:update()
-- Open URL -- Open URL
local s, msg = vlc.stream(url) local s, msg = vlc.stream(url)
if not s then if not s then
vlc.msg.warn("[ALLOCINE.COM] " .. msg) vlc.msg.warn("[ALLOCINE.COM] " .. msg)
spin:stop()
return
end end
-- Fetch HTML data (max 65 kb) -- Fetch HTML data (max 65 kb)
...@@ -238,14 +245,17 @@ function click_chercher() ...@@ -238,14 +245,17 @@ function click_chercher()
if #films > 1 then if #films > 1 then
message_text = tostring(#films) .. " films ou séries TV trouvés sur Allociné :" message_text = tostring(#films) .. " films ou séries TV trouvés sur Allociné :"
message:set_text(message_text) message:set_text(message_text)
list = dlg:add_list(1, 3, 3, 1) list = dlg:add_list(1, 3, 4, 1)
for idx, film in ipairs(films) do for idx, film in ipairs(films) do
local txt = film.title local txt = film.title
if film.year then txt = txt .. " (" .. film.year .. ")" end if film.year then txt = txt .. " (" .. film.year .. ")" end
list:add_value(txt, idx) list:add_value(txt, idx)
end end
okay = dlg:add_button("Voir la fiche", click_okay, 3, 4, 1, 1) okay = dlg:add_button("Voir la fiche", click_okay, 3, 4, 2, 1)
end end
-- We're done now
spin:stop()
end end
-- Click after selection -- Click after selection
...@@ -259,7 +269,11 @@ function click_okay() ...@@ -259,7 +269,11 @@ function click_okay()
message_text = "<center><a href=\"" .. films[sel].url .. "\">" .. films[sel].title .. "</a></center>" message_text = "<center><a href=\"" .. films[sel].url .. "\">" .. films[sel].title .. "</a></center>"
message:set_text(message_text) message:set_text(message_text)
-- Show progress
spin:animate()
dlg:update() dlg:update()
open_fiche(films[sel].url) open_fiche(films[sel].url)
end end
...@@ -275,7 +289,7 @@ function open_fiche(url) ...@@ -275,7 +289,7 @@ function open_fiche(url)
end end
if not html then if not html then
html = dlg:add_html("<center><i>Chargement en cours...</i></center>", 1, 3, 3, 1) html = dlg:add_html("<center><i>Chargement en cours...</i></center>", 1, 3, 4, 1)
end end
dlg:update() dlg:update()
...@@ -297,6 +311,7 @@ function open_fiche(url) ...@@ -297,6 +311,7 @@ function open_fiche(url)
message:set_text("<h2>Erreur !</h2>Désolé, une erreur est survenue pendant le chargement de la fiche.<br />" message:set_text("<h2>Erreur !</h2>Désolé, une erreur est survenue pendant le chargement de la fiche.<br />"
.. "<a href=\"" .. url .. "\">Cliquez ici pour consulter la page sur Allociné.fr</a>.") .. "<a href=\"" .. url .. "\">Cliquez ici pour consulter la page sur Allociné.fr</a>.")
dlg:del_widget(html) dlg:del_widget(html)
spin:stop()
return return
end end
...@@ -349,4 +364,6 @@ function open_fiche(url) ...@@ -349,4 +364,6 @@ function open_fiche(url)
page = string.gsub(page, "href=([\"'])/", "href=%1http://www.allocine.fr/") page = string.gsub(page, "href=([\"'])/", "href=%1http://www.allocine.fr/")
html:set_text(page) html:set_text(page)
spin:stop()
end end
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