[vlc-commits] commit: fixes dailymotion parser ( Rafaël Carré )
git at videolan.org
git at videolan.org
Mon Jul 19 19:52:44 CEST 2010
vlc/vlc-1.1 | branch: master | Rafaël Carré <rafael.carre at gmail.com> | Mon Jul 12 00:26:00 2010 +0200| [21c130afe7fe6fd186925223b0fbdcf8078a1da6] | committer: 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: Rémi Duraffort <ivoire at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.1.git/?a=commit;h=21c130afe7fe6fd186925223b0fbdcf8078a1da6
---
share/lua/playlist/dailymotion.lua | 79 ++++++++++++++----------------------
1 files changed, 30 insertions(+), 49 deletions(-)
diff --git a/share/lua/playlist/dailymotion.lua b/share/lua/playlist/dailymotion.lua
index fd88028..5a69d86 100644
--- a/share/lua/playlist/dailymotion.lua
+++ b/share/lua/playlist/dailymotion.lua
@@ -24,7 +24,7 @@
-- Probe function.
function probe()
return vlc.access == "http"
- and string.match( vlc.path, "dailymotion." )
+ and string.match( vlc.path, "dailymotion." )
and string.match( vlc.peek( 2048 ), "<!DOCTYPE.*video_type" )
end
@@ -36,58 +36,39 @@ end
-- Parse function.
function parse()
while true
- do
+ do
line = vlc.readline()
- if not line then break end
- if string.match( line, "param name=\"flashvars\" value=\".*video=" )
+ if not line
then
- arturl = find( line, "param name=\"flashvars\" value=\".*preview=([^&]*)" )
- videos = vlc.strings.decode_uri( find( line, "param name=\"flashvars\" value=\".*video=([^&]*)" ) )
- --[[ we get a list of different streams available, at various codecs
- 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
- and resolutions (the resolutions are part of the URL)
-
- For now we just built a list of preferred codecs : lowest value
- means highest priority
- ]]
- local pref = { ["vp6"]=0, ["spark"]=1, ["h264"]=2, ["vp6-hd"]=3, ["spark-mini"]=4 }
- local available = {}
- for n in string.gmatch(videos, "[^|]+") do
- i = string.find(n, "@@")
- if i then
- available[string.sub(n, i+2)] = string.sub(n, 0, i-1)
- end
- end
- local score = 666
- 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=\"(.-)\"" ) )
+ vlc.msg.err("Couldn't extract the video URL from dailymotion")
+ return { }
end
- if string.match( line, "<meta name=\"description\"" )
+ if string.match( line, "\"sequence\",")
then
- description = vlc.strings.resolve_xml_special_chars( vlc.strings.resolve_xml_special_chars( find( line, "name=\"description\" lang=\".-\" content=\"(.-)\"" ) ) )
+ 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
+ and resolutions:
+
+ Ideally, VLC would propose the different streams available,
+ codecs and resolutions (the resolutions are part of the URL)
+
+ For now we just built a list of preferred codecs : lowest value
+ means highest priority
+ ]]--
+
+ -- FIXME: the hd/hq versions (in mp4) cause a lot of seeks,
+ -- for now we only get the sd (in flv) URL
+
+ -- if not path then path = find( line, "\"hqURL\":\"([^\"]*)\"") end
+ -- if not path then path = find( line, "\"hdURL\":\"([^\"]*)\"") end
+ if not path then path = find( line, "\"sdURL\":\"([^\"]*)\"") end
+
+ return { { path = path; name = name; description = description; url = vlc.path; arturl = arturl } }
end
- if path and name and description and arturl then break end
end
- return { { path = path; name = name; description = description; url = vlc.path; arturl = arturl } }
end
More information about the vlc-commits
mailing list