]> git.sesse.net Git - vlc/blobdiff - modules/demux/playlist/m3u.c
m3u: use the album art provided by jamendo along with the m3u files.
[vlc] / modules / demux / playlist / m3u.c
index cef756e0ed62d668d71b1adbb3b9330228f5a68b..2ac9622900895af3b5974f27e1329a4762dd3cc4 100644 (file)
@@ -136,6 +136,7 @@ static int Demux( demux_t *p_demux )
     char       *psz_line;
     char       *psz_name = NULL;
     char       *psz_artist = NULL;
+    char       *psz_album_art = NULL;
     int        i_parsed_duration = 0;
     mtime_t    i_duration = -1;
     const char**ppsz_options = NULL;
@@ -145,6 +146,7 @@ static int Demux( demux_t *p_demux )
     input_item_t *p_input;
 
     input_item_t *p_current_input = GetCurrentItem(p_demux);
+    input_item_node_t *p_subitems = input_item_node_Create( p_current_input );
 
     psz_line = stream_ReadLine( p_demux->s );
     while( psz_line )
@@ -170,6 +172,8 @@ static int Demux( demux_t *p_demux )
             {
                 /* Extended info */
                 psz_parse += sizeof("EXTINF:") - 1;
+                free(psz_name);
+                free(psz_artist);
                 parseEXTINF( psz_parse, &psz_artist, &psz_name, &i_parsed_duration );
                 if( i_parsed_duration >= 0 )
                     i_duration = i_parsed_duration * INT64_C(1000000);
@@ -191,6 +195,14 @@ static int Demux( demux_t *p_demux )
                     INSERT_ELEM( ppsz_options, i_options, i_options,
                                  psz_option );
             }
+            /* Special case for jamendo which provide the albumart */
+            else if( !strncasecmp( psz_parse, "EXTALBUMARTURL:",
+                     sizeof( "EXTALBUMARTURL:" ) -1 ) )
+            {
+                psz_parse += sizeof( "EXTALBUMARTURL:" ) - 1;
+                free( psz_album_art );
+                psz_album_art = pf_dup( psz_parse );
+            }
         }
         else if( !strncasecmp( psz_parse, "RTSPtext", sizeof("RTSPtext") -1 ) )
         {
@@ -208,7 +220,11 @@ static int Demux( demux_t *p_demux )
             psz_mrl = ProcessMRL( psz_parse, p_demux->p_sys->psz_prefix );
 
             b_cleanup = true;
-            if( !psz_mrl ) goto error;
+            if( !psz_mrl )
+            {
+                LocaleFree( psz_parse );
+                goto error;
+            }
 
             p_input = input_item_NewExt( p_demux, psz_mrl, psz_name,
                                         i_options, ppsz_options, 0, i_duration );
@@ -219,8 +235,10 @@ static int Demux( demux_t *p_demux )
             if ( psz_artist && *psz_artist )
                 input_item_SetArtist( p_input, psz_artist );
             if( psz_name ) input_item_SetTitle( p_input, psz_name );
+            if( !EMPTY_STR(psz_album_art) )
+                input_item_SetArtURL( p_input, psz_album_art );
 
-            input_item_AddSubItem( p_current_input, p_input );
+            input_item_node_AppendItem( p_subitems, p_input );
             vlc_gc_decref( p_input );
         }
 
@@ -241,12 +259,15 @@ static int Demux( demux_t *p_demux )
             psz_name = NULL;
             free( psz_artist );
             psz_artist = NULL;
+            free( psz_album_art );
+            psz_album_art = NULL;
             i_parsed_duration = 0;
             i_duration = -1;
 
             b_cleanup = false;
         }
     }
+    input_item_node_PostAndDelete( p_subitems );
     vlc_gc_decref(p_current_input);
     var_Destroy( p_demux, "m3u-extvlcopt" );
     return 0; /* Needed for correct operation of go back */