mux: mp4: fix recording of rtsp
[vlc.git] / share / lua / playlist / koreus.lua
blob400cff32a668e1e321b476ea7778f2fe36dd4886
1 --[[
3 Copyright © 2009 the VideoLAN team
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.
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.
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 --]]
20 -- Probe function.
21 function probe()
22 local path = vlc.path:gsub("^www%.", "")
23 return ( vlc.access == "http" or vlc.access == "https" )
24 and string.match( path, "^koreus%.com/video/.+" )
25 end
27 -- Parse function.
28 function parse()
29 while true do
30 line = vlc.readline()
31 if not line then break end
32 if string.match( line, "<meta name=\"title\"" ) then
33 _,_,name = string.find( line, "content=\"(.-)\"" )
34 name = vlc.strings.resolve_xml_special_chars( name )
35 end
37 if string.match( line, "<meta property=\"og:description\"" ) then
38 _,_,description = string.find( line, "content=\"(.-)\"" )
39 if (description ~= nil) then
40 description = vlc.strings.resolve_xml_special_chars( description )
41 end
42 end
43 if string.match( line, "<span id=\"spoil\" style=\"display:none\">" ) then
44 _,_,desc_spoil = string.find( line, "<span id=\"spoil\" style=\"display:none\">(.-)</span>" )
45 desc_spoil = vlc.strings.resolve_xml_special_chars( desc_spoil )
46 description = description .. "\n\r" .. desc_spoil
47 end
49 if string.match( line, "<meta name=\"author\"" ) then
50 _,_,artist = string.find( line, "content=\"(.-)\"" )
51 artist = vlc.strings.resolve_xml_special_chars( artist )
52 end
53 if string.match( line, "link rel=\"image_src\"" ) then
54 _,_,arturl = string.find( line, "href=\"(.-)\"" )
55 end
57 vid_url = string.match( line, '(http://embed%.koreus%.com/%d+/%d+/[%w-]*%.mp4)' )
58 if vid_url then
59 path_url = vid_url
60 end
62 vid_url_hd = string.match( line, '(http://embed%.koreus%.com/%d+/%d+/[%w-]*%-hd%.mp4)' )
63 if vid_url_hd then
64 path_url_hd = vid_url_hd
65 end
67 vid_url_webm = string.match( line, '(http://embed%.koreus%.com/%d+/%d+/[%w-]*%.webm)' )
68 if vid_url_webm then
69 path_url_webm = vid_url_webm
70 end
72 vid_url_flv = string.match( line, '(http://embed%.koreus%.com/%d+/%d+/[%w-]*%.flv)' )
73 if vid_ulr_flv then
74 path_url_flv = vid_url_flv
75 end
77 end
79 if path_url_hd then
80 if vlc.access == 'https' then path_url_hd = path_url_hd:gsub('http','https') end
81 return { { path = path_url_hd; name = name; description = description; artist = artist; arturl = arturl } }
82 elseif path_url then
83 if vlc.access == 'https' then path_url = path_url:gsub('http','https') end
84 return { { path = path_url; name = name; description = description; artist = artist; arturl = arturl } }
85 elseif path_url_webm then
86 if vlc.access == 'https' then path_url_webm = path_url_webm:gsub('http','https') end
87 return { { path = path_url_webm; name = name; description = description; artist = artist; arturl = arturl } }
88 elseif path_url_flv then
89 if vlc.access == 'https' then path_url_flv = path_url_flv:gsub('http','https') end
90 return { { path = path_url_flv; name = name; description = description; artist = artist; arturl = arturl } }
91 else
92 return {}
93 end
94 end