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.
23 function get_prefres()
25 if vlc.var and vlc.var.inherit then
26 prefres = vlc.var.inherit(nil, "preferred-resolution")
27 if prefres == nil then
36 return vlc.access == "http"
37 and string.match( vlc.path, "extreme.com/." )
38 or string.match( vlc.path, "freecaster.tv/." )
39 or string.match( vlc.path, "player.extreme.com/info/.")
44 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
47 if not line then break end
48 -- Try to find id of the video
49 if string.match( line, "http://player.extreme.com/FCPlayer.swf" ) then
50 _,_,vid = string.find( line, "id=(.*)\"" )
54 return { { path = "http://player.extreme.com/info/" .. vid; name = "extreme.com video"; } }
57 if string.match( vlc.path, "player.extreme.com/info/." ) then
58 prefres = get_prefres()
62 if not line then break end
63 -- Try to find the video's title
64 if string.match( line, "title>(.*)<" ) then
65 _,_,name = string.find( line, "<title>(.*)<" )
68 -- Try to find image for thumbnail
69 if string.match( line, "<path>(*.)</path>" ) then
70 _,_,arturl = string.find( line, "<path>(*.)</path>" )
73 -- Try to find out if its a freecaster streaming or just a link to some
74 -- other video streaming website
75 -- FIXME: I was unable to find any http-based freecaster streams,
76 -- but I remember there were some a few months back.
77 -- Right now we assume everything is streamed using RTMP, so we feed them to avio.
78 if string.match( line, "<streams type=\"5\" server=\"(.*)\">" )
80 _,_,rtmpserver = string.find( line, "<streams type=\"5\" server=\"(.*)\">" )
84 -- if we're going outside, we need to find out the path
86 if string.match( line, ">(.*)</stream>" ) then
87 _,_,path = string.find( line, "bitrate=\"0\" duration=\"\">(.*)</stream>" )
91 -- and if we're using freecaster, use appropriate resolution
92 if not gostraight then
93 if string.match( line, "height=\"(.*)\" duration" ) then
94 _,_,height = string.find( line, "height=\"(%d+)\" duration" )
95 _,_,playpath = string.find( line, "\">(.*)</stream>" )
96 if ( prefres < 0 or tonumber( height ) <= prefres ) then
97 path = "avio://" .. rtmpserver .. " playpath=" .. playpath
103 return { { path = path; name = name; arturl = arturl } }