]> git.sesse.net Git - vlc/blob - share/lua/playlist/koreus.lua
Koreus: improve parsing and improve HTTPS
[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" and vlc.access ~= "https" 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                         name = vlc.strings.resolve_xml_special_chars( name )
40                 end
41                 if string.match( line, "<meta name=\"description\"" ) then
42                         _,_,description = string.find( line, "content=\"(.-)\"" )
43             if (description ~= nil) then
44                 description = vlc.strings.resolve_xml_special_chars( description )
45             end
46                 end
47                 if string.match( line, "<meta name=\"author\"" ) then
48                         _,_,artist = string.find( line, "content=\"(.-)\"" )
49                         artist = vlc.strings.resolve_xml_special_chars( artist )
50                 end
51                 if string.match( line, "link rel=\"image_src\"" ) then
52                         _,_,arturl = string.find( line, "href=\"(.-)\"" )
53                 end
54
55                 vid_url = string.match( line, '(http://embed%.koreus%.com/%d+/%d+/[%w-]*%.mp4)' )
56                 if vid_url then
57                         path_url = vid_url
58                 end
59
60         vid_url_hd = string.match( line, '(http://embed%.koreus%.com/%d+/%d+/[%w-]*%-hd%.mp4)' )
61                 if vid_url_hd then
62                         path_url_hd = vid_url_hd
63                 end
64
65                 vid_url_webm = string.match( line, '(http://embed%.koreus%.com/%d+/%d+/[%w-]*%.webm)' )
66                 if vid_url_webm then
67                         path_url_webm = vid_url_webm
68                 end
69
70                 vid_url_flv = string.match( line, '(http://embed%.koreus%.com/%d+/%d+/[%w-]*%.flv)' )
71                 if vid_ulr_flv then
72                         path_url_flv = vid_url_flv
73                 end
74
75         end
76
77         if path_url_hd then
78                 return { { path = path_url_hd; name = name; description = description; artist = artist; arturl = arturl } }
79         elseif path_url then
80                 return { { path = path_url; name = name; description = description; artist = artist; arturl = arturl } }
81         elseif path_url_webm then
82                 return { { path = path_url_webm; name = name; description = description; artist = artist; arturl = arturl } }
83         elseif path_url_flv then
84                 return { { path = path_url_flv; name = name; description = description; artist = artist; arturl = arturl } }
85         else
86                 return {}
87         end
88 end