[vlc-devel] [PATCH] lua: Add sd for french Senate live feeds

François Revol revol at free.fr
Wed Feb 18 15:34:54 CET 2015


Lists flv and m3u8 feeds for the hemicycle and the two commission rooms.

Could probably be merged someday with assembleenationale.lua.
---
 share/lua/sd/senatfr.lua | 174 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 174 insertions(+)
 create mode 100644 share/lua/sd/senatfr.lua

diff --git a/share/lua/sd/senatfr.lua b/share/lua/sd/senatfr.lua
new file mode 100644
index 0000000..e4e0d3d
--- /dev/null
+++ b/share/lua/sd/senatfr.lua
@@ -0,0 +1,174 @@
+--[[
+ $Id$
+
+ Copyright © 2015 VideoLAN and AUTHORS
+
+ Authors: François Revol <revol at free dot fr>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+--]]
+
+function descriptor()
+    return { title="Sénat (FR)" }
+end
+
+-- web entry points:
+--
+-- hemicycle:
+-- http://videos.senat.fr/video/seance_direct.html
+-- iframe: http://videos.senat.fr/video/iframe-direct2.html
+-- also has an m3u8 URL
+--
+-- commissions:
+-- http://videos.senat.fr/video/audcom_direct.html
+-- iframe: http://videos.senat.fr/video/iframe-clemenceau2.html
+-- http://videos.senat.fr/video/audcom_direct2.html
+-- iframe: http://videos.senat.fr/video/iframe-medicis2.html
+-- m3u8 URLs are mentionned in the help page:
+-- http://videos.senat.fr/video/aide_direct/audcom.html
+--
+-- There are "smaller" iframes but they point to the same flv URLs
+
+function main()
+    local duration, artist, name, arturl, title, stream_type
+    local line, idx
+
+    arturl = "http://videos.senat.fr/vidimg/logo.png"
+    artist = "Sénat français"
+    title = "Séance en direct"
+
+    -- fetch the main page
+    fd, msg = vlc.stream( "http://videos.senat.fr/video/seance_direct.html" )
+    if not fd then
+        vlc.msg.warn(msg)
+        return nil
+    end
+
+    line = fd:readline()
+    while line ~= nil do
+        -- there is an rtmpt: audio object as well, but it is broken
+        if( string.find( line, "param name=\"flashvars\" value.*flv" ) ) then
+            _, _, path = string.find( line, "file=([^&\"]+)" )
+            stream_type = "flv"
+            if( string.find( path, "audio" ) ) then
+                stream_type = "audio"
+            elseif( string.find( path, "rtmp" ) ) then
+                stream_type = "rtmp"
+            end
+
+            local options={}
+            vlc.sd.add_item( {path=path,
+            duration=duration,
+            artist=artist,
+            title=title .. " (" .. stream_type .. ")",
+            arturl=arturl,
+            options=options} )
+        elseif( string.find( line, "Format MP4/H264" ) ) then
+            _, _, path = string.find( line, "[Hh][Rr][Ee][Ff]=\"([^\"]+)\"" )
+
+            local options={}
+            vlc.sd.add_item( {path=path,
+            duration=duration,
+            artist=artist,
+            title=title .. " (m3u8)",
+            arturl=arturl,
+            options=options} )
+        end
+        line = fd:readline()
+    end
+
+    title = "Commission en direct"
+
+    -- fetch the first commission iframe page
+    fd, msg = vlc.stream( "http://videos.senat.fr/video/iframe-clemenceau2.html" )
+    if not fd then
+        vlc.msg.warn(msg)
+        return nil
+    end
+
+    line = fd:readline()
+    while line ~= nil do
+        if( string.find( line, "param name=\"flashvars\" value.*flv" ) ) then
+            _, _, path = string.find( line, "file=([^&\"]+)" )
+            stream_type = "flv"
+            if( string.find( path, "rtmp" ) ) then
+                stream_type = "rtmp"
+            end
+
+            local options={}
+            vlc.sd.add_item( {path=path,
+            duration=duration,
+            artist=artist,
+            title=title .. " (1) (" .. stream_type .. ")",
+            arturl=arturl,
+            options=options} )
+        end
+        line = fd:readline()
+    end
+
+    -- fetch the second commission iframe page
+    fd, msg = vlc.stream( "http://videos.senat.fr/video/iframe-medicis2.html" )
+    if not fd then
+        vlc.msg.warn(msg)
+        return nil
+    end
+
+    line = fd:readline()
+    while line ~= nil do
+        if( string.find( line, "param name=\"flashvars\" value.*flv" ) ) then
+            _, _, path = string.find( line, "file=([^&\"]+)" )
+            stream_type = "flv"
+            if( string.find( path, "rtmp" ) ) then
+                stream_type = "rtmp"
+            end
+
+            local options={}
+            vlc.sd.add_item( {path=path,
+            duration=duration,
+            artist=artist,
+            title=title .. " (2) (" .. stream_type .. ")",
+            arturl=arturl,
+            options=options} )
+        end
+        line = fd:readline()
+    end
+
+
+    -- fetch the help page to get commissions URLs
+    fd, msg = vlc.stream( "http://videos.senat.fr/video/aide_direct/audcom.html" )
+    if not fd then
+        vlc.msg.warn(msg)
+        return nil
+    end
+
+    line = fd:readline()
+    idx = 1
+    while line ~= nil do
+        if( string.find( line, "m3u8</a>" ) ) then
+            -- one of the href is broken (doubled quote)
+            _, _, path = string.find( line, "href=\"+([^\"]+)\">" )
+
+            local options={}
+            vlc.sd.add_item( {path=path,
+            duration=duration,
+            artist=artist,
+            title=title .. " (" .. idx .. ") (m3u8)",
+            arturl=arturl,
+            options=options} )
+            idx = idx + 1
+        end
+        line = fd:readline()
+    end
+end
-- 
2.1.4




More information about the vlc-devel mailing list