Commit 21c130af authored by Rafaël Carré's avatar Rafaël Carré Committed by Rémi Duraffort

fixes dailymotion parser

get the SD video (in flv), the HD and HQ videos (in mp4) causes seeking
back and forth and the video is unplayable
(cherry picked from commit e778af8bb60ba6a67c47e8b30c175874726414ee)
Signed-off-by: default avatarRémi Duraffort <ivoire@videolan.org>
parent 0b706f50
...@@ -38,56 +38,37 @@ function parse() ...@@ -38,56 +38,37 @@ function parse()
while true while true
do do
line = vlc.readline() line = vlc.readline()
if not line then break end if not line
if string.match( line, "param name=\"flashvars\" value=\".*video=" )
then then
arturl = find( line, "param name=\"flashvars\" value=\".*preview=([^&]*)" ) vlc.msg.err("Couldn't extract the video URL from dailymotion")
videos = vlc.strings.decode_uri( find( line, "param name=\"flashvars\" value=\".*video=([^&]*)" ) ) return { }
end
if string.match( line, "\"sequence\",")
then
line = vlc.strings.decode_uri(line):gsub("\\/", "/")
arturl = find( line, "\"videoPreviewURL\":\"([^\"]*)\"")
name = find( line, "\"videoTitle\":\"([^\"]*)\"")
description = find( line, "\"videoDescription\":\"([^\"]*)\"")
--[[ we get a list of different streams available, at various codecs --[[ we get a list of different streams available, at various codecs
and resolutions: and resolutions:
/A@@spark||/B@@spark-mini||/C@@vp6-hd||/D@@vp6||/E@@h264
Not everybody can decode HD, not everybody has a 80x60 screen,
H264/MP4 is buggy , so i choose VP6 as the highest priority
Ideally, VLC would propose the different streams available, codecs Ideally, VLC would propose the different streams available,
and resolutions (the resolutions are part of the URL) codecs and resolutions (the resolutions are part of the URL)
For now we just built a list of preferred codecs : lowest value For now we just built a list of preferred codecs : lowest value
means highest priority means highest priority
]] ]]--
local pref = { ["vp6"]=0, ["spark"]=1, ["h264"]=2, ["vp6-hd"]=3, ["spark-mini"]=4 }
local available = {} -- FIXME: the hd/hq versions (in mp4) cause a lot of seeks,
for n in string.gmatch(videos, "[^|]+") do -- for now we only get the sd (in flv) URL
i = string.find(n, "@@")
if i then -- if not path then path = find( line, "\"hqURL\":\"([^\"]*)\"") end
available[string.sub(n, i+2)] = string.sub(n, 0, i-1) -- if not path then path = find( line, "\"hdURL\":\"([^\"]*)\"") end
end if not path then path = find( line, "\"sdURL\":\"([^\"]*)\"") end
end
local score = 666 return { { path = path; name = name; description = description; url = vlc.path; arturl = arturl } }
local bestcodec
for codec,_ in pairs(available) do
if pref[codec] == nil then
vlc.msg.warn( "Unknown codec: " .. codec )
pref[codec] = 42 -- try the 1st unknown codec if other fail
end
if pref[codec] < score then
bestcodec = codec
score = pref[codec]
end
end
if bestcodec then
path = "http://dailymotion.com" .. available[bestcodec]
end
end
if string.match( line, "<meta name=\"title\"" )
then
name = vlc.strings.resolve_xml_special_chars( find( line, "name=\"title\" content=\"(.-)\"" ) )
end
if string.match( line, "<meta name=\"description\"" )
then
description = vlc.strings.resolve_xml_special_chars( vlc.strings.resolve_xml_special_chars( find( line, "name=\"description\" lang=\".-\" content=\"(.-)\"" ) ) )
end end
if path and name and description and arturl then break end
end end
return { { path = path; name = name; description = description; url = vlc.path; arturl = arturl } }
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