2 Translate MegaVideo video webpages URLs to the corresponding FLV URL.
6 Copyright © 2008 the VideoLAN team
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.
25 return vlc.access == "http"
26 and string.match( vlc.path, "megavideo.com" )
32 -- we have to get the xml
33 if string.match( vlc.path, "www.megavideo.com.*&v=.*&u=.*" ) then
34 _,_,id = string.find( vlc.path, "www.megavideo.com.*v=([^&]*)" )
35 path = "http://www.megavideo.com/xml/videolink.php?v=" .. id
36 return { { path = path } }
42 if not line then break end
45 if string.match( line, "<ROWS><ROW url=\"" )
49 -- buffer the full xml
50 xml = xml .. line .. '\n'
53 -- now gets the encoded url
54 _,_,s = string.find( xml, ".*ROW url=\"(.-)\"" )
59 if c % 4 < 2 then mod = 0 else mod = 4 end
60 if c < 16 and c > 3 then key = 61 + mod
61 elseif c < 96 and c > 67 then key = 189 + mod
62 elseif c < 20 and c > 6 then key = 65
63 else vlc.msg.err("Oops, please report URL to developers")
66 path = path .. string.char(key - c)
69 if path then break end
72 return { { path = path } }