2 Translate trailers.apple.com video webpages URLs to the corresponding
6 Copyright © 2007-2010 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, "trailers.apple.com" )
27 and string.match( vlc.path, "web.inc" )
30 function find( haystack, needle )
31 local _,_,r = string.find( haystack, needle )
36 if(a == nil) then return false end
37 if(b == nil) then return false end
42 if(string.find(a.name, '%(') == 1) then
43 str_a = tonumber(string.sub(a.name, 2, string.find(a.name, 'p') - 1))
44 str_b = tonumber(string.sub(b.name, 2, string.find(b.name, 'p') - 1))
46 str_a = string.sub(a.name, 1, string.find(a.name, '%(') - 2)
47 str_b = string.sub(b.name, 1, string.find(b.name, '%(') - 2)
48 if(str_a == str_b) then
49 str_a = tonumber(string.sub(a.name, string.len(str_a) + 3, string.find(a.name, 'p', string.len(str_a) + 3) - 1))
50 str_b = tonumber(string.sub(b.name, string.len(str_b) + 3, string.find(b.name, 'p', string.len(str_b) + 3) - 1))
53 if(str_a > str_b) then return false else return true end
59 local description = ''
65 if not line then break end
67 if string.match( line, "h3>.-</h3" ) then
68 description = find( line, "h3>(.-)</h3")
69 vlc.msg.dbg(description)
71 if string.match( line, 'img src=') then
72 for img in string.gmatch(line, '<img src="(http://.*%.jpg)" ') do
75 for i,value in pairs(playlist) do
76 if value.arturl == '' then
77 playlist[i].arturl = art_url
81 if string.match( line, 'class="hd".-%.mov') then
82 for urlline,resolution in string.gmatch(line, 'class="hd".-href="(.-%.mov)".->(%d+.-p)') do
83 urlline = string.gsub( urlline, "_"..resolution, "_h"..resolution )
84 table.insert( playlist, { path = urlline,
85 name = description.." "..resolution,
87 options = {":http-user-agent=QuickTime/7.5", ":play-and-pause", ":demux=avformat"} } )