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" )
29 function find( haystack, needle )
30 local _,_,r = string.find( haystack, needle )
35 if(a == nil) then return false end
36 if(b == nil) then return false end
41 if(string.find(a.name, '%(') == 1) then
42 str_a = tonumber(string.sub(a.name, 2, string.find(a.name, 'p') - 1))
43 str_b = tonumber(string.sub(b.name, 2, string.find(b.name, 'p') - 1))
45 str_a = string.sub(a.name, 1, string.find(a.name, '%(') - 2)
46 str_b = string.sub(b.name, 1, string.find(b.name, '%(') - 2)
47 if(str_a == str_b) then
48 str_a = tonumber(string.sub(a.name, string.len(str_a) + 3, string.find(a.name, 'p', string.len(str_a) + 3) - 1))
49 str_b = tonumber(string.sub(b.name, string.len(str_b) + 3, string.find(b.name, 'p', string.len(str_b) + 3) - 1))
52 if(str_a > str_b) then return false else return true end
58 local description = ''
64 if not line then break end
66 if string.match( line, "class=\".-first" ) then
67 description = find( line, "h%d.->(.-)</h%d") .. ' '
69 if string.match( line, 'img src=') then
70 for img in string.gmatch(line, '<img src="(http://.*\.jpg)" ') do
73 for i,value in pairs(playlist) do
74 if value.arturl == '' then
75 playlist[i].arturl = art_url
79 if string.match( line, "class=\"hd\".-\.mov") then
80 for urlline,resolution in string.gmatch(line, "class=\"hd\".-href=\"(.-.mov)\".-(%d+.-p)") do
81 urlline = string.gsub( urlline, "_"..resolution, "_h"..resolution )
82 table.insert( playlist, { path = urlline,
83 name = description .. '(' .. resolution .. ')',
85 options = {":http-user-agent=QuickTime/7.2", ":demux=avformat,ffmpeg",":play-and-pause"} } )
90 table.sort(playlist, sort)