]> git.sesse.net Git - vlc/commitdiff
Lua SD: freebox now should work correctly
authorFabio Ritrovato <sephiroth87@videolan.org>
Mon, 15 Feb 2010 22:58:45 +0000 (23:58 +0100)
committerFabio Ritrovato <sephiroth87@videolan.org>
Mon, 15 Feb 2010 22:59:30 +0000 (23:59 +0100)
share/lua/sd/freebox.lua

index b1e3cd1bef36c988bbf78d0f0659c46c6e6f888f..270b692ad9a4c372c7217374eeb50d9fd8095344 100644 (file)
 --]]
 
 function main()
-    vlc.sd.add_item( {url="http://mafreebox.freebox.fr/freeboxtv/playlist.m3u",options={"deinterlace=1"}} )
+    local fd = vlc.stream( "http://mafreebox.freebox.fr/freeboxtv/playlist.m3u" )
+    local line=  fd:readline()
+    if line ~= "#EXTM3U" then
+        return nil
+    end
+    line = fd:readline()
+    local duration, artist, name
+    local options={"deinterlace=1"}
+    while line ~= nil do
+        if( string.find( line, "#EXTINF" ) ) then
+            _, _, duration, artist, name = string.find( line, ":(%w+),(%w+)%s*-%s*(.+)" )
+            --TODO: fix the name not showing special characters correctly
+        elseif( string.find( line, "#EXTVLCOPT" ) ) then
+            _, _, option = string.find( line, ":(.+)" )
+            table.insert( options, option )
+        else
+            vlc.sd.add_item( {url=line,duration=duration,artist=artist,title=name,options=options} )
+            duration = nil
+            artist = nil
+            name = nil
+            options={"deinterlace=1"}
+        end
+        line = fd:readline()
+    end
 end