[vlc-devel] [PATCH] Improve the playlist experience

Mario Speiß 1034-135 at online.de
Fri Feb 8 11:12:19 CET 2013


If playlists containing youtube urls are exported or imported, these patches
improve the usability of the playlist.

Lua remembers the original url (i.e. the website _containing_ the
content) if no other url is passed by the lua parsers. It also puts the
content title to the meta-title entry.

XSPF export / import now saves the meta-url as link within the xspf-file.

Regards,
Mario
---
 modules/demux/playlist/xspf.c |    5 ++++-
 modules/lua/vlc.c             |   20 ++++++++++++++++++++
 modules/misc/playlist/xspf.c  |    6 ++++++
 3 files changed, 30 insertions(+), 1 deletions(-)

diff --git a/modules/demux/playlist/xspf.c b/modules/demux/playlist/xspf.c
index 92c60c2..709e4b6 100644
--- a/modules/demux/playlist/xspf.c
+++ b/modules/demux/playlist/xspf.c
@@ -360,7 +360,7 @@ static bool parse_track_node COMPLEX_INTERFACE
           {"album",        {.smpl = set_item_info}, false },
           {"trackNum",     {.smpl = set_item_info}, false },
           {"duration",     {.smpl = set_item_info}, false },
-          {"link",         {NULL}, false },
+          {"link",         {.smpl = set_item_info}, false },
           {"meta",         {NULL}, false },
           {"extension",    {.cmplx = parse_extension_node}, true },
         };
@@ -547,6 +547,8 @@ static bool set_item_info SIMPLE_INTERFACE
         input_item_SetDescription(p_input, psz_value);
     else if (!strcmp(psz_name, "image"))
         input_item_SetArtURL(p_input, psz_value);
+    else if (!strcmp(psz_name, "link"))
+        input_item_SetURL(p_input, psz_value);
     return true;
 }
 
@@ -816,3 +818,4 @@ static bool skip_element COMPLEX_INTERFACE
 
     return true;
 }
+
diff --git a/modules/lua/vlc.c b/modules/lua/vlc.c
index 0c43e07..964b6c8 100644
--- 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 ) )
                 {
+                    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,23 @@ 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( url );
+                    free( psz_oldurl );
+
+                    /* copy the psz_name to the meta data, if "Title" is still empty */
+                    char* title = input_item_GetTitle( p_input );
+                    if( title == NULL )
+                        input_item_SetTitle ( p_input, psz_name );
+                    free( title );
+
                     /* Read custom meta data: item must be on top of stack*/
                     vlclua_read_custom_meta_data( p_this, L, p_input );
 
diff --git a/modules/misc/playlist/xspf.c b/modules/misc/playlist/xspf.c
index ffc1cee..52532a4 100644
--- a/modules/misc/playlist/xspf.c
+++ b/modules/misc/playlist/xspf.c
@@ -132,6 +132,11 @@ static void xspf_export_item( playlist_item_t *p_item, FILE *p_file,
         fprintf( p_file, "\t\t\t<image>%s</image>\n", psz );
     free( psz );
 
+    psz = input_xml( p_input, input_item_GetURL );
+    if( psz && *psz )
+        fprintf( p_file, "\t\t\t<link>%s</link>\n", psz );
+    free( psz );
+
 xspfexportitem_end:
     /* -> the duration */
     i_duration = input_item_GetDuration( p_item->p_input );
@@ -262,3 +267,4 @@ int xspf_export_playlist( vlc_object_t *p_this )
 
     return VLC_SUCCESS;
 }
+
-- 
1.7.5.4




More information about the vlc-devel mailing list