]> git.sesse.net Git - vlc/commitdiff
fix dailymotion parser, choosing VP6 as the default of the multiple streams available
authorRafaël Carré <funman@videolan.org>
Thu, 21 Feb 2008 01:47:15 +0000 (01:47 +0000)
committerRafaël Carré <funman@videolan.org>
Thu, 21 Feb 2008 01:47:15 +0000 (01:47 +0000)
note that a prebuilt table of preferred codecs, or even user interaction would be better

share/luaplaylist/dailymotion.lua

index bd50437f795558adbf21f9e87c0abd2ca8899b58..41b7cd6be5ec5ac4fc214e32e55ded5d8f48d480 100644 (file)
@@ -34,24 +34,36 @@ function parse()
     do 
         line = vlc.readline()
         if not line then break end
-        if string.match( line, "param name=\"flashvars\" value=\".*url=http" )
+        if string.match( line, "param name=\"flashvars\" value=\".*video=" )
         then
-            path = vlc.decode_uri( string.gsub( line, "^.*param name=\"flashvars\" value=\".*url=(http[^&]*).*$", "%1" ) )
+            arturl = vlc.decode_uri( string.gsub( line, "^.*param name=\"flashvars\" value=\".*preview=([^&]*).*$", "%1" ) )
+            videos = vlc.decode_uri( string.gsub( line, "^.*param name=\"flashvars\" value=\".*video=([^&]*).*$", "%1" ) )
+       --[[ 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
+
+            Ideally, VLC would propose the different streams available, codecs
+            and resolutions (the resolutions are part of the URL)
+         ]]
+            for n in string.gmatch(videos, "[^|]+") do
+                i = string.find(n, "@@")
+                if i then
+                    video = string.sub( n, 0, i - 1)
+                    codec = string.sub( n, i + 2 )
+                    if video and codec and string.match(codec, "vp6") then
+                        path = "http://dailymotion.com" .. video
+                        break
+                    end
+                end
+            end
         end
-        --[[ if string.match( line, "<title>" )
-        then
-            title = vlc.decode_uri( string.gsub( line, "^.*<title>([^<]*).*$", "%1" ) )
-        end ]]
         if string.match( line, "<meta name=\"description\"" )
         then
             name = vlc.resolve_xml_special_chars( string.gsub( line, "^.*name=\"description\" content=\"%w+ (.*) %w+ %w+ %w+ %w+ Videos\..*$", "%1" ) )
             description = vlc.resolve_xml_special_chars( string.gsub( line, "^.*name=\"description\" content=\"%w+ .* %w+ %w+ %w+ %w+ Videos\. ([^\"]*)\".*$", "%1" ) )
         end
-        if string.match( line, "\\\"videoPreview\\\"" )
-        then
-            arturl = string.gsub( line, "^.*\\\"videoPreview\\\":\\\"([^\"]*).*$", "%1" )
-            arturl = string.gsub( 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 } }