[vlc-devel] [PATCH 2/3] Remeber the original URL of an item to its meta-url

Mario Speiß 1034-135 at online.de
Sat Jan 5 22:12:47 CET 2013


This patch remember the original url of the webpage parsed by lua scripts in
an items meta-url, if this is possible (i.e. the lua parsers did not parse
another meta-url).
This lets the fetcher find a better filename while downloading the item.

Regards,
Mario
---
 modules/lua/vlc.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
 mode change 100644 => 100755 modules/lua/vlc.c

diff --git a/modules/lua/vlc.c b/modules/lua/vlc.c
index 0c43e07..ee17229
--- a/modules/lua/vlc.c
+++ b/modules/lua/vlc.c
@@ -486,6 +486,7 @@ int vlclua_playlist_add_internal( vlc_object_t *p_this, lua_State *L,
                 /* playlist key item path */
                 if( lua_isstring( L, -1 ) )
                 {
+                    const char   *psz_oldurl   = NULL;
                     const char   *psz_path     = NULL;
                     char         *psz_u8path   = NULL;
                     const char   *psz_name     = NULL;
@@ -495,6 +496,8 @@ int vlclua_playlist_add_internal( vlc_object_t *p_this, lua_State *L,
                     input_item_t *p_input;
 
                     /* Read path and name */
+                    psz_oldurl = input_item_GetURI( p_parent );
+                    msg_Dbg( p_this, "old path: %s", psz_oldurl );
                     psz_path = lua_tostring( L, -1 );
                     msg_Dbg( p_this, "Path: %s", psz_path );
                     lua_getfield( L, -2, "name" );
@@ -542,6 +545,16 @@ int vlclua_playlist_add_internal( vlc_object_t *p_this, lua_State *L,
                     /* Read meta data: item must be on top of stack */
                     vlclua_read_meta_data( p_this, L, p_input );
 
+                    //copy the original URL to the meta data, if "URL" is still empty
+                    char* url = input_item_GetURL( p_input );
+                    if( url == NULL )
+                    {
+                        EnsureUTF8( psz_oldurl );
+                        msg_Dbg( p_this, "meta-URL: %s", psz_oldurl );
+                        input_item_SetURL ( p_input, psz_oldurl );
+                    }
+                    free( psz_oldurl );
+
                     /* Read custom meta data: item must be on top of stack*/
                     vlclua_read_custom_meta_data( p_this, L, p_input );
 
-- 
1.7.5.4




More information about the vlc-devel mailing list