mux: mp4: fix recording of rtsp
[vlc.git] / share / lua / playlist / extreme.lua
blob23fb0a817ea9c7900c688f8db51758df2cba56f8
1 --[[
2 $Id$
4 Copyright © 2011 the VideoLAN team
6 Authors: Konstantin Pavlov (thresh@videolan.org)
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 --]]
23 -- Probe function.
24 function probe()
25 local path = vlc.path:gsub("^www%.", "")
26 return vlc.access == "http"
27 and ( string.match( vlc.path, "^extreme%.com/.+" )
28 or string.match( vlc.path, "^freecaster%.tv/.+" )
29 or string.match( vlc.path, "^player%.extreme%.com/info/.+") )
30 end
32 -- Parse function.
33 function parse()
34 if (string.match( vlc.path, "extreme%.com/." ) or string.match( vlc.path, "freecaster%.tv/." )) and not string.match( vlc.path, "player%.extreme%.com/info/") then
35 while true do
36 line = vlc.readline()
37 if not line then break end
38 -- Try to find id of the video
39 if string.match( line, "http://player.extreme.com/FCPlayer.swf" ) then
40 _,_,vid = string.find( line, "id=(.*)\"" )
41 break
42 end
43 end
44 return { { path = "http://player.extreme.com/info/" .. vid; name = "extreme.com video"; } }
45 end
47 if string.match( vlc.path, "player%.extreme%.com/info/." ) then
48 prefres = vlc.var.inherit(nil, "preferred-resolution")
49 gostraight = true
50 while true do
51 line = vlc.readline()
52 if not line then break end
53 -- Try to find the video's title
54 if string.match( line, "title>(.*)<" ) then
55 _,_,name = string.find( line, "<title>(.*)<" )
56 end
58 -- Try to find image for thumbnail
59 if string.match( line, "<path>(*.)</path>" ) then
60 _,_,arturl = string.find( line, "<path>(*.)</path>" )
61 end
63 -- Try to find out if its a freecaster streaming or just a link to some
64 -- other video streaming website
65 -- We assume freecaster now streams in http
66 if string.match( line, "<streams type=\"5\" server=\"(.*)\">" )
67 then
68 _,_,videoserver = string.find( line, "<streams type=\"5\" server=\"(.*)\">" )
69 gostraight = false
70 end
72 -- if we're going outside, we need to find out the path
73 if gostraight then
74 if string.match( line, ">(.*)</stream>" ) then
75 _,_,path = string.find( line, "bitrate=\"0\" duration=\"\">(.*)</stream>" )
76 end
77 end
79 -- and if we're using freecaster, use appropriate resolution
80 if not gostraight then
81 if string.match( line, "height=\"(.*)\" duration" ) then
82 _,_,height = string.find( line, "height=\"(%d+)\" duration" )
83 _,_,playpath = string.find( line, "\">(.*)</stream>" )
84 if ( prefres < 0 or tonumber( height ) <= prefres ) then
85 path = videoserver .. playpath
86 end
87 end
88 end
89 end
91 return { { path = path; name = name; arturl = arturl } }
93 end
95 end