+ sub = string.sub(data, first, last-1)
+
+ -- Clean data
+ sub = string.gsub(sub, "%s+", " ")
+ sub = string.gsub(sub, "</?p>", "<br/>")
+ sub = string.gsub(sub, "</?div[^>]*>", "")
+ sub = string.gsub(sub, "</?span[^>]*>", "")
+ sub = string.gsub(sub, "<%!%-%-[^%-]+%-%->", "")
+ sub = string.gsub(sub, "<br%s*/>%s*<br%s*/>", "<br/>")
+ page = string.gsub(sub, "Synopsis :.*$", "")
+
+ -- Style
+ local synopsis = string.gsub(sub, ".*Synopsis :(.*)", "<h2>Synposis</h2>%1")
+
+ -- Note
+ first, _ = string.find(data, "Note Moyenne:")
+ if first then
+ local _, note = string.find(data, "span class=\"lighten\">%(", first)
+ if note then
+ note = string.sub(data, note+1, note+3)
+ note = string.gsub(note, "%).*$", "")
+ page = page .. "Note moyenne: <b>" .. note .. " / 4</b>"
+ local nbpeople = string.gsub(data, ".*pour (%d+) notes.*", "%1")
+ if nbpeople then
+ page = page .. " (" .. nbpeople .. " votes)"
+ end
+ end
+ end
+
+ -- Synopsis
+ page = page .. synopsis
+
+ -- Movie title
+ if string.find(data, '<h1>.*</h1>') then
+ name = string.gsub(data, '^.*<h1>%s*(.*)%s*</h1>.*$', '%1')
+ name = trim(name)
+ end
+
+ page = page .. "<h2>Source</h2>"
+ if name then
+ page = page .. name .. " sur <a href='" .. url .. "'>Allociné</a>"
+ else
+ page = page .. "<a href='" .. url .. "'>Allociné</a>"
+ end
+
+ page = string.gsub(page, "href=([\"'])/", "href=%1http://www.allocine.fr/")
+ html:set_text(page)