Commit c63918e3 authored by Jean-Philippe André's avatar Jean-Philippe André Committed by Jean-Baptiste Kempf

Lua: fix Allocine extension

It was broken a looong time ago because the XML structure
of their web page is broken
(cherry picked from commit e9196c3fc2ca2daf438c1fd90bd10f8404fd4f4a)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 76560471
...@@ -172,6 +172,9 @@ function click_chercher() ...@@ -172,6 +172,9 @@ function click_chercher()
-- Read <table> tag as xml -- Read <table> tag as xml
local substring = string.sub(data, first, last or -1) local substring = string.sub(data, first, last or -1)
-- Fix Allocine's broken XML (!!!)
substring = string.gsub(substring, "<div class=\"spacer vmargin10\">", "")
local xml = simplexml.parse_string(substring) local xml = simplexml.parse_string(substring)
for _, tr in ipairs(xml.children) do for _, tr in ipairs(xml.children) do
-- Get film title & year -- Get film title & year
...@@ -317,18 +320,15 @@ function open_fiche(url) ...@@ -317,18 +320,15 @@ function open_fiche(url)
local synopsis = string.gsub(sub, ".*Synopsis :(.*)", "<h2>Synposis</h2>%1") local synopsis = string.gsub(sub, ".*Synopsis :(.*)", "<h2>Synposis</h2>%1")
-- Note -- Note
first, _ = string.find(data, "Note Moyenne:") for w in string.gmatch(data, "property=\"v:average\"[^>]*>([^<]+)</span>") do
if first then local note = trim(w)
local _, note = string.find(data, "span class=\"lighten\">%(", first) page = page .. "Note moyenne: <b>" .. note .. " / 4</b>"
if note then for y in string.gmatch(data, "property=\"v:count\"[^>]*>([^<]+)</span>") do
note = string.sub(data, note+1, note+3) local nbpeople = trim(y)
note = string.gsub(note, "%).*$", "") page = page .. " (" .. nbpeople .. " votes)"
page = page .. "Note moyenne: <b>" .. note .. " / 4</b>" break
local nbpeople = string.gsub(data, ".*pour (%d+) notes.*", "%1")
if nbpeople then
page = page .. " (" .. nbpeople .. " votes)"
end
end end
break
end end
-- Synopsis -- Synopsis
......
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