[vlc-devel] commit: DM: Use built-in priority for known codecs ( Rafaël Carré )

git version control git at videolan.org
Fri Mar 21 18:02:29 CET 2008


vlc | branch: master | Rafaël Carré <funman at videolan.org> | Thu Mar 20 23:48:45 2008 +0100| [fd0cdccc7cf66bc0734889ce53f9c7d958774a9b]

DM: Use built-in priority for known codecs

Not every dailymotion video is available in vp6

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=fd0cdccc7cf66bc0734889ce53f9c7d958774a9b
---

 share/luaplaylist/dailymotion.lua |   25 ++++++++++++++++++-------
 1 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/share/luaplaylist/dailymotion.lua b/share/luaplaylist/dailymotion.lua
index 41b7cd6..2cbae59 100644
--- a/share/luaplaylist/dailymotion.lua
+++ b/share/luaplaylist/dailymotion.lua
@@ -42,22 +42,33 @@ function parse()
             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
+            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
-                    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
+                    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] < 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=\"description\"" )
         then




More information about the vlc-devel mailing list