]> git.sesse.net Git - vlc/commitdiff
Lua demuxers: show the original URL in playlist
authorMario Speiß <1034-135@online.de>
Sun, 10 Feb 2013 21:31:58 +0000 (22:31 +0100)
committerJean-Baptiste Kempf <jb@videolan.org>
Mon, 15 Apr 2013 09:44:12 +0000 (11:44 +0200)
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 uses the <info> to deal with the meta-url.

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/demux/playlist/xspf.c
modules/lua/vlc.c
modules/misc/playlist/xspf.c

index 92c60c20e3ae87dd0d17aaf35acf6b75ddf8d8d6..86067596a87a0fa82b4085bf719a8a096dad839b 100644 (file)
@@ -355,7 +355,7 @@ static bool parse_track_node COMPLEX_INTERFACE
           {"title",        {.smpl = set_item_info}, false },
           {"creator",      {.smpl = set_item_info}, false },
           {"annotation",   {.smpl = set_item_info}, false },
-          {"info",         {NULL}, false },
+          {"info",         {.smpl = set_item_info}, false },
           {"image",        {.smpl = set_item_info}, false },
           {"album",        {.smpl = set_item_info}, false },
           {"trackNum",     {.smpl = set_item_info}, false },
@@ -545,6 +545,8 @@ static bool set_item_info SIMPLE_INTERFACE
     }
     else if (!strcmp(psz_name, "annotation"))
         input_item_SetDescription(p_input, psz_value);
+    else if (!strcmp(psz_name, "info"))
+        input_item_SetURL(p_input, psz_value);
     else if (!strcmp(psz_name, "image"))
         input_item_SetArtURL(p_input, psz_value);
     return true;
index 90ea73ebf09727c049c7c5b6d45257e4d8b01768..1da88ced8c169228d0d11d93c6683cd21ca83b94 100644 (file)
@@ -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 );
 
index ffc1ceeb6385ba7a7859e54512ba55f3c57170fe..e41cd258dd7e855b217e8a34efc01f6435ab273d 100644 (file)
@@ -127,6 +127,11 @@ static void xspf_export_item( playlist_item_t *p_item, FILE *p_file,
         fprintf( p_file, "\t\t\t<annotation>%s</annotation>\n", psz );
     free( psz );
 
+    psz = input_xml( p_input, input_item_GetURL );
+    if( psz && *psz )
+        fprintf( p_file, "\t\t\t<info>%s</info>\n", psz );
+    free( psz );
+
     psz = input_xml( p_input, input_item_GetArtURL );
     if( psz && *psz )
         fprintf( p_file, "\t\t\t<image>%s</image>\n", psz );