]> git.sesse.net Git - vlc/blob - share/lua/playlist/koreus.lua
66e7c7afd5d2952402155bd67747475db4471fce
[vlc] / share / lua / playlist / koreus.lua
1 --[[
2
3  Copyright © 2009 the VideoLAN team
4
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  GNU General Public License for more details.
14
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
18 --]]
19
20 -- Probe function.
21 function probe()
22     if vlc.access ~= "http" then
23         return false
24     end
25         koreus_site = string.match( vlc.path, "koreus" )
26     if not koreus_site then
27         return false
28     end
29     return (  string.match( vlc.path, "video" )  ) -- http://www.koreus.com/video/pouet.html
30 end
31
32 -- Parse function.
33 function parse()
34         while true do
35                 line = vlc.readline()
36                 if not line then break end
37                 if string.match( line, "<meta name=\"title\"" ) then
38                         _,_,name = string.find( line, "content=\"(.-)\"" )
39                 end
40                 if string.match( line, "<meta name=\"description\"" ) then
41                         _,_,description = string.find( line, "content=\"(.-)\"" )
42                 end
43                 if string.match( line, "<meta name=\"author\"" ) then
44                         _,_,artist = string.find( line, "content=\"(.-)\"" )
45                 end
46                 if string.match( line, "link rel=\"image_src\"" ) then
47                         _,_,arturl = string.find( line, "href=\"(.-)\"" )
48                 end
49
50                 if string.match( line, "videoDiv\"%)%.innerHTML" ) then
51                         vid_url = string.match( line, '(http://media%d?%.koreus%.com/%d+/%d+/[%w-]*%.mp4)' )
52                         if vid_url then
53                                 return { { path = vid_url; name = name; description = description; artist = artist; arturl = arturl } }
54                         end
55                 end
56         end
57 end