Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
a1ad2378
Commit
a1ad2378
authored
Jun 04, 2010
by
Jean-Philippe André
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lua: update Allociné script & remove debug
parent
a7c0e2a0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
16 deletions
+67
-16
share/lua/extensions/allocine-fr.lua
share/lua/extensions/allocine-fr.lua
+67
-16
No files found.
share/lua/extensions/allocine-fr.lua
View file @
a1ad2378
...
...
@@ -37,7 +37,7 @@ films = {}
function
descriptor
()
return
{
title
=
"Allociné (France)"
;
version
=
"1.0"
;
author
=
"
Jean-Philippe André
"
;
author
=
"
VideoLAN
"
;
url
=
'http://www.allocine.fr/'
;
shortdesc
=
"Allocine.com"
;
description
=
"<center><b>ALLOCINE.COM</b></center>"
...
...
@@ -171,9 +171,6 @@ function click_chercher()
if
category
==
"Films"
or
category
==
"Séries TV"
then
-- Read <table> tag as xml
local
substring
=
string.sub
(
data
,
first
,
last
or
-
1
)
print
(
"
\n
"
)
print
(
substring
)
print
(
"
\n
"
)
local
xml
=
simplexml
.
parse_string
(
substring
)
for
_
,
tr
in
ipairs
(
xml
.
children
)
do
...
...
@@ -254,13 +251,9 @@ function click_okay()
local
selection
=
list
:
get_selection
()
if
not
selection
then
return
end
local
sel
=
nil
for
idx
,
selectedItem
in
pairs
(
selection
)
do
sel
=
idx
break
end
local
sel
,
_
=
next
(
selection
,
nil
)
if
not
sel
then
return
end
message_text
=
"<center><a href=\"" .. films[sel].url .. "
\
">"
..
films
[
sel
].
title
..
"</a></center>"
message
:
set_text
(
message_text
)
dlg
:
update
()
...
...
@@ -287,14 +280,72 @@ function open_fiche(url)
local
s
=
vlc
.
stream
(
url
)
local
data
=
s
:
read
(
65535
)
-- HACK: use directly HTML data from webpage
local
first
,
_
=
string.find
(
data
,
'<div class="rubric">'
)
-- Buffer & temp variables
local
first
=
nil
local
last
=
nil
local
page
=
nil
local
sub
=
nil
local
name
=
nil
first
,
_
=
string.find
(
data
,
'<div class="rubric">'
)
if
not
first
then
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>."
)
dlg
:
del_widget
(
html
)
return
end
-- Extract information
local
last
,
_
=
string.find
(
data
,
'<ul id="link_open"'
)
if
not
last
then
last
,
_
=
string.find
(
data
,
'notationbar'
)
end
local
subdata
=
string.sub
(
data
,
first
,
(
last
or
0
)
-
1
)
subdata
=
string.gsub
(
subdata
,
"%s+"
,
" "
)
subdata
=
string.gsub
(
subdata
,
"href=([\"
'])/", "href=%1http://www.allocine.fr/")
html:set_text(subdata)
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)
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment