Commit 2d8becef authored by Ilkka Ollakka's avatar Ilkka Ollakka

fix appletrailers playlist parser

parent e9d9cae0
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
function probe() function probe()
return vlc.access == "http" return vlc.access == "http"
and string.match( vlc.path, "trailers.apple.com" ) and string.match( vlc.path, "trailers.apple.com" )
and string.match( vlc.path, "web.inc" )
end end
function find( haystack, needle ) function find( haystack, needle )
...@@ -63,8 +64,9 @@ function parse() ...@@ -63,8 +64,9 @@ function parse()
line = vlc.readline() line = vlc.readline()
if not line then break end if not line then break end
if string.match( line, "class=\".-first" ) then if string.match( line, "h%d>.-</h%d" ) then
description = find( line, "h%d.->(.-)</h%d") .. ' ' description = find( line, "h%d>(.+)</h%d")
vlc.msg.dbg(description)
end end
if string.match( line, 'img src=') then if string.match( line, 'img src=') then
for img in string.gmatch(line, '<img src="(http://.*%.jpg)" ') do for img in string.gmatch(line, '<img src="(http://.*%.jpg)" ') do
...@@ -73,20 +75,19 @@ function parse() ...@@ -73,20 +75,19 @@ function parse()
for i,value in pairs(playlist) do for i,value in pairs(playlist) do
if value.arturl == '' then if value.arturl == '' then
playlist[i].arturl = art_url playlist[i].arturl = art_url
else break end end
end end
end end
if string.match( line, 'class="hd".-%.mov') then if string.match( line, 'class="hd".-%.mov') then
for urlline,resolution in string.gmatch(line, 'class="hd".-href="(.-%.mov)".-(%d+.-p)') do for urlline,resolution in string.gmatch(line, 'class="hd".-href="(.-%.mov)".->(%d+.-p)') do
urlline = string.gsub( urlline, "_"..resolution, "_h"..resolution ) urlline = string.gsub( urlline, "_"..resolution, "_h"..resolution )
table.insert( playlist, { path = urlline, table.insert( playlist, { path = urlline,
name = description .. '(' .. resolution .. ')', name = description.." "..resolution,
arturl = art_url, arturl = art_url,
options = {":http-user-agent=QuickTime/7.5", ":play-and-pause"} } ) options = {":http-user-agent=QuickTime/7.5", ":play-and-pause", ":demux=avformat"} } )
end end
end end
end end
table.sort(playlist, sort)
return playlist return playlist
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment