]> git.sesse.net Git - vlc/commitdiff
* luaplaylist.c, README.txt: add support for VLC options.
authorAntoine Cellerier <dionoea@videolan.org>
Sat, 19 May 2007 14:28:16 +0000 (14:28 +0000)
committerAntoine Cellerier <dionoea@videolan.org>
Sat, 19 May 2007 14:28:16 +0000 (14:28 +0000)
* *.lua: misc fixes.

modules/demux/playlist/luaplaylist.c
share/luaplaylist/README.txt
share/luaplaylist/dailymotion.lua
share/luaplaylist/youtube_homepage.lua

index 4956943aa8a683730ca3e7878b083fcc6e455ea0..d59f696f80c2a3d9449d37e8e9536c4a796dcf6d 100644 (file)
@@ -472,35 +472,71 @@ static int Demux( demux_t *p_demux )
             {
                 if( lua_istable( p_state, t+2 ) )
                 {
-                    const char *psz_url = NULL;
-                    const char *psz_title = NULL;
                     lua_getfield( p_state, t+2, "path" );
                     if( lua_isstring( p_state, t+3 ) )
                     {
-                        psz_url = lua_tostring( p_state, t+3 );
-                        msg_Dbg( p_demux, "Path: %s", psz_url );
+                        const char  *psz_path     = NULL;
+                        const char  *psz_name     = NULL;
+                        char       **ppsz_options = NULL;
+                        int          i_options    = 0;
+
+                        /* Read path and name */
+                        psz_path = lua_tostring( p_state, t+3 );
+                        msg_Dbg( p_demux, "Path: %s", psz_path );
                         lua_getfield( p_state, t+2, "name" );
                         if( lua_isstring( p_state, t+4 ) )
                         {
-                            psz_title = lua_tostring( p_state, t+4 );
-                            msg_Dbg( p_demux, "Name: %s", psz_title );
+                            psz_name = lua_tostring( p_state, t+4 );
+                            msg_Dbg( p_demux, "Name: %s", psz_name );
                         }
                         else
                         {
-                            psz_title = psz_url;
+                            psz_name = psz_path;
                         }
-                        p_input = input_ItemNewExt( p_playlist, psz_url,
-                                                    psz_title, 0, NULL, -1 );
-                        p_input->p_meta = vlc_meta_New();
 
-#define TRY_META( a, b )                                                      \
-                        lua_getfield( p_state, t+2, a );                      \
-                        if( lua_isstring( p_state, t+5 ) )                    \
-                        {                                                     \
-                            psz_title = lua_tostring( p_state, t+5 );         \
-                            msg_Dbg( p_demux, #b ": %s", psz_title );         \
-                            vlc_meta_Set ## b ( p_input->p_meta, psz_title ); \
-                        }                                                     \
+                        /* Read options */
+                        lua_getfield( p_state, t+2, "options" );
+                        if( lua_istable( p_state, t+5 ) )
+                        {
+                            lua_pushnil( p_state );
+                            while( lua_next( p_state, t+5 ) )
+                            {
+                                if( lua_isstring( p_state, t+7 ) )
+                                {
+                                    char *psz_option = strdup(
+                                        lua_tostring( p_state, t+7 ) );
+                                    msg_Dbg( p_demux, "Option: %s",
+                                             psz_option );
+                                    INSERT_ELEM( ppsz_options, i_options,
+                                                 i_options, psz_option );
+                                }
+                                else
+                                {
+                                    msg_Warn( p_demux,
+                                              "Option should be a string" );
+                                }
+                                lua_pop( p_state, 1 ); /* pop option */
+                            }
+                        }
+                        lua_pop( p_state, 1 ); /* pop "options" */
+
+                        /* Create input item */
+                        p_input = input_ItemNewExt( p_playlist, psz_path,
+                                                    psz_name, i_options,
+                                                    (const char **)ppsz_options,
+                                                    -1 );
+                        lua_pop( p_state, 1 ); /* pop "name" */
+
+                        /* Read meta data */
+                        p_input->p_meta = vlc_meta_New();
+#define TRY_META( a, b )                                                     \
+                        lua_getfield( p_state, t+2, a );                     \
+                        if( lua_isstring( p_state, t+4 ) )                   \
+                        {                                                    \
+                            psz_name = lua_tostring( p_state, t+4 );         \
+                            msg_Dbg( p_demux, #b ": %s", psz_name );         \
+                            vlc_meta_Set ## b ( p_input->p_meta, psz_name ); \
+                        }                                                    \
                         lua_pop( p_state, 1 ); /* pop a */
                         TRY_META( "title", Title );
                         TRY_META( "artist", Artist );
@@ -520,12 +556,16 @@ static int Demux( demux_t *p_demux )
                         TRY_META( "arturl", ArtURL );
                         TRY_META( "trackid", TrackID );
 
+                        /* Append item to playlist */
                         playlist_BothAddInput(
                             p_playlist, p_input,
                             p_item_in_category,
                             PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
                             PLAYLIST_END, NULL, NULL, VLC_FALSE );
-                        lua_pop( p_state, 1 ); /* pop "name" */
+
+                        while( i_options > 0 )
+                            free( ppsz_options[--i_options] );
+                        free( ppsz_options );
                     }
                     else
                     {
@@ -541,7 +581,6 @@ static int Demux( demux_t *p_demux )
                 lua_pop( p_state, 1 ); /* pop the value, keep the key for
                                         * the next lua_next() call */
             }
-            lua_pop( p_state, 1 ); /* pop the last key */
         }
         else
         {
index 84589855ff2f3464d66db2586c01c792ce8bc15c..79e4b069ffd5837aa01d7533d61c015dd5e5ff8b 100644 (file)
@@ -1,7 +1,8 @@
 Instructions to code your own VLC Lua playlist script.
 $Id$
 
-Examples: See dailymotion.lua, googlevideo.lua, metacafe.lua and youbtube.lua.
+Examples: See dailymotion.lua, googlevideo.lua, metacafe.lua, youbtube.lua
+          and youtube_homepage.lua .
 
 VLC Lua playlist modules should define two functions:
  * probe(): returns true if we want to handle the playlist in this script
@@ -27,6 +28,8 @@ VLC Lua playlist modules should define two functions:
                 .encodedby: the item's EncodedBy (OPTIONAL, meta data)
                 .arturl: the item's ArtURL (OPTIONAL, meta data)
                 .trackid: the item's TrackID (OPTIONAL, meta data)
+                .options: a list of VLC options (OPTIONAL)
+                          example: .options = { "fullscreen" }
             Invalid playlist items will be discarded by VLC.
 
 VLC defines a global vlc object with the following members:
index 4f88816c45115eb4a44772cc30defee6444ed95a..b5182d0b8f874a27c84c50f5215debf5d9448155 100644 (file)
@@ -4,7 +4,7 @@
 function probe()
     return vlc.access == "http"
         and string.match( vlc.path, "dailymotion.com" ) 
-        and vlc.peek( 9 ) == "<!DOCTYPE"
+        and string.match( vlc.peek( 256 ), "<!DOCTYPE.*<title>Video " )
 end
 
 -- Parse function.
index de4df97a58fef5a62a4d48e41e58189dd5575145..00a7cdc68316c3baf91829d7da8b2211d3673ad6 100644 (file)
@@ -1,5 +1,5 @@
 function probe()
-    return vlc.access == "http" and ( string.match( vlc.path, "youtube.com/$" ) or string.match( vlc.path, "youtube.com/browse" ) )
+    return vlc.access == "http" and ( string.match( vlc.path, "youtube.com/?$" ) or string.match( vlc.path, "youtube.com/browse" ) )
 end
 
 function parse()