From: Rafaël Carré Date: Wed, 27 May 2009 19:36:22 +0000 (+0200) Subject: Fix xspf reading/writing X-Git-Tag: 1.1.0-ff~5665^2^2~1 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=a654d4a14edf1a3925cfa731c965652832f01ef2;p=vlc Fix xspf reading/writing When reading a file:// URL from an xspf entry, store the decoded file path; else store the unmodified URL Always keep album art URLs always encoded and decode the path when needed Interfaces & plugins only use file paths Playlist core extract attachment:// URLs (from file meta data), http:// or other (from meta data fetchers like lua) and cache them to a file Thanks to courmisch for clarification Signed-off-by: Rémi Denis-Courmont --- diff --git a/modules/control/http/http.c b/modules/control/http/http.c index 75f24c2af4..6987029e48 100644 --- a/modules/control/http/http.c +++ b/modules/control/http/http.c @@ -27,6 +27,7 @@ #include "http.h" #include +#include #include @@ -787,7 +788,8 @@ int ArtCallback( httpd_handler_sys_t *p_args, psz_art = input_item_GetArtURL( p_item ); } - if( psz_art && !strncmp( psz_art, "file://", strlen( "file://" ) ) ) + if( psz_art && !strncmp( psz_art, "file://", strlen( "file://" ) ) && + decode_URI( psz_art + 7 ) ) { FILE *f; char *psz_ext; diff --git a/modules/demux/playlist/xspf.c b/modules/demux/playlist/xspf.c index ed1ed924a8..eee5b8502d 100644 --- a/modules/demux/playlist/xspf.c +++ b/modules/demux/playlist/xspf.c @@ -546,32 +546,31 @@ static bool parse_track_node COMPLEX_INTERFACE /* special case: location */ if( !strcmp( p_handler->name, "location" ) ) { - char *psz_uri = NULL; - psz_uri = decode_URI_duplicate( psz_value ); + char *psz_location = psz_value; + if( !strncmp( psz_value, "file://", 7 ) ) + psz_location = decode_URI( psz_value + 7 ); - if( !psz_uri ) + if( !psz_location ) { FREE_ATT(); return false; } - if( p_demux->p_sys->psz_base && !strstr( psz_uri, "://" ) ) + if( p_demux->p_sys->psz_base && !strstr( psz_value, "://" ) ) { char* psz_tmp; if( asprintf( &psz_tmp, "%s%s", p_demux->p_sys->psz_base, - psz_uri ) == -1 ) + psz_location ) == -1 ) { - free( psz_uri ); FREE_ATT(); return NULL; } - free( psz_uri ); - psz_uri = psz_tmp; + input_item_SetURI( p_new_input, psz_tmp ); + free( psz_tmp ); } - input_item_SetURI( p_new_input, psz_uri ); - free( psz_uri ); + else + input_item_SetURI( p_new_input, psz_location ); input_item_CopyOptions( p_input_item, p_new_input ); - psz_uri = NULL; FREE_ATT(); p_handler = NULL; } @@ -652,9 +651,7 @@ static bool set_item_info SIMPLE_INTERFACE } else if( !strcmp( psz_name, "image" ) ) { - char *psz_uri = decode_URI_duplicate( psz_value ); - input_item_SetArtURL( p_input, psz_uri ); - free( psz_uri ); + input_item_SetArtURL( p_input, psz_value ); } return true; } diff --git a/modules/gui/macosx/playlistinfo.m b/modules/gui/macosx/playlistinfo.m index 6a2b8ce8c6..972f1a66a7 100644 --- a/modules/gui/macosx/playlistinfo.m +++ b/modules/gui/macosx/playlistinfo.m @@ -29,6 +29,7 @@ #include "intf.h" #include "playlistinfo.h" #include "playlist.h" +#include /***************************************************************************** * VLCPlaylistInfo Implementation @@ -292,7 +293,7 @@ static VLCInfo *_o_sharedInstance = nil; char *psz_meta; NSImage *o_image; psz_meta = input_item_GetArtURL( p_item ); - if( psz_meta && !strncmp( psz_meta, "file://", 7 ) ) + if( psz_meta && !strncmp( psz_meta, "file://", 7 ) && decode_URI( psz_meta + 7 ) ) o_image = [[NSImage alloc] initWithContentsOfFile: [NSString stringWithUTF8String: psz_meta+7]]; else o_image = [[NSImage imageNamed: @"noart.png"] retain]; diff --git a/modules/gui/qt4/input_manager.cpp b/modules/gui/qt4/input_manager.cpp index 0b456ad086..1fc1f497b0 100644 --- a/modules/gui/qt4/input_manager.cpp +++ b/modules/gui/qt4/input_manager.cpp @@ -29,6 +29,7 @@ #include "input_manager.hpp" #include +#include #include @@ -589,12 +590,12 @@ void InputManager::UpdateArt() if( hasInput() ) { char *psz_art = input_item_GetArtURL( input_GetItem( p_input ) ); - url = qfu( psz_art ); + if( psz_art && !strncmp( psz_art, "file://", 7 ) && + decode_URI( psz_art + 7 ) ) + url = qfu( psz_art + 7); free( psz_art ); } - url = url.replace( "file://", QString("" ) ); - /* Taglib seems to define a attachment://, It won't work yet */ - url = url.replace( "attachment://", QString("" ) ); + /* Update Art meta */ emit artChanged( url ); } diff --git a/modules/meta_engine/folder.c b/modules/meta_engine/folder.c index 4d41b0ac19..4f9856fff9 100644 --- a/modules/meta_engine/folder.c +++ b/modules/meta_engine/folder.c @@ -98,26 +98,31 @@ static int FindMeta( vlc_object_t *p_this ) case 0: /* Windows Folder.jpg */ snprintf( psz_filename, MAX_PATH, - "file://%sFolder.jpg", psz_path ); + "%sFolder.jpg", psz_path ); break; case 1: /* Windows AlbumArtSmall.jpg == small version of Folder.jpg */ snprintf( psz_filename, MAX_PATH, - "file://%sAlbumArtSmall.jpg", psz_path ); + "%sAlbumArtSmall.jpg", psz_path ); break; case 2: /* KDE (?) .folder.png */ snprintf( psz_filename, MAX_PATH, - "file://%s.folder.png", psz_path ); + "%s.folder.png", psz_path ); break; } - if( utf8_stat( psz_filename+7, &a ) != -1 ) + if( utf8_stat( psz_filename, &a ) != -1 ) { - input_item_SetArtURL( p_item, psz_filename ); - b_have_art = true; + char *psz_uri = make_URI( psz_filename ); + if( psz_uri ) + { + input_item_SetArtURL( p_item, psz_uri ); + free( psz_uri ); + b_have_art = true; + } } } diff --git a/modules/misc/notify/growl.m b/modules/misc/notify/growl.m index c0503b09a4..95ad205235 100644 --- a/modules/misc/notify/growl.m +++ b/modules/misc/notify/growl.m @@ -58,6 +58,7 @@ #include #include #include +#include /***************************************************************************** @@ -210,7 +211,7 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var, char *psz_arturl = input_item_GetArtURL( p_item ); CFDataRef art = NULL; if( psz_arturl && !strncmp( psz_arturl, "file://", 7 ) && - strlen( psz_arturl ) > 7 ) + decode_URI( psz_arturl + 7 ) ) art = (CFDataRef) readFile( psz_arturl + 7 ); free( psz_title ); diff --git a/modules/misc/notify/notify.c b/modules/misc/notify/notify.c index 6b3be7cb41..6fa084af1b 100644 --- a/modules/misc/notify/notify.c +++ b/modules/misc/notify/notify.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -221,12 +222,11 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var, vlc_object_release( p_input ); if( psz_arturl && !strncmp( psz_arturl, "file://", 7 ) && - strlen( psz_arturl ) > 7 ) + decode_URI( psz_arturl + 7 ) ) { /* scale the art to show it in notify popup */ GError *p_error = NULL; pix = gdk_pixbuf_new_from_file_at_scale( &psz_arturl[7], 72, 72, TRUE, &p_error ); - free( psz_arturl ); } else /* else we show state-of-the art logo */ { @@ -239,6 +239,8 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var, } } + free( psz_arturl ); + /* we need to replace '&' with '&' because '&' is a keyword of * notification-daemon parser */ const int i_len = strlen( psz_tmp ); diff --git a/modules/misc/playlist/xspf.c b/modules/misc/playlist/xspf.c index 0f5f82c5c0..6765adbd9d 100644 --- a/modules/misc/playlist/xspf.c +++ b/modules/misc/playlist/xspf.c @@ -212,9 +212,7 @@ static void xspf_export_item( playlist_item_t *p_item, FILE *p_file, if( psz == NULL ) psz = strdup( "" ); if( !EMPTY_STR( psz ) ) { - psz_uri = make_URI( psz ); - fprintf( p_file, "\t\t\t%s\n", psz_uri ); - free( psz_uri ); + fprintf( p_file, "\t\t\t%s\n", psz ); } free( psz ); diff --git a/share/lua/meta/10_googleimage.lua b/share/lua/meta/10_googleimage.lua index e203c9c9a6..8dc1e04c46 100644 --- a/share/lua/meta/10_googleimage.lua +++ b/share/lua/meta/10_googleimage.lua @@ -44,9 +44,5 @@ function fetch_art() page = fd:read( 65653 ) fd = nil _, _, arturl = string.find( page, "imgurl=([^&]+)" ) - if arturl then - return vlc.strings.decode_uri(arturl) - else - return nil - end + return arturl end diff --git a/share/lua/playlist/dailymotion.lua b/share/lua/playlist/dailymotion.lua index e850bcf6c1..f4545c6487 100644 --- a/share/lua/playlist/dailymotion.lua +++ b/share/lua/playlist/dailymotion.lua @@ -41,7 +41,7 @@ function parse() if not line then break end if string.match( line, "param name=\"flashvars\" value=\".*video=" ) then - arturl = vlc.strings.decode_uri( find( line, "param name=\"flashvars\" value=\".*preview=([^&]*)" ) ) + arturl = find( line, "param name=\"flashvars\" value=\".*preview=([^&]*)" ) videos = vlc.strings.decode_uri( find( line, "param name=\"flashvars\" value=\".*video=([^&]*)" ) ) --[[ we get a list of different streams available, at various codecs and resolutions: diff --git a/share/lua/playlist/youtube.lua b/share/lua/playlist/youtube.lua index 452400f16f..238d3eb1ab 100644 --- a/share/lua/playlist/youtube.lua +++ b/share/lua/playlist/youtube.lua @@ -26,7 +26,7 @@ end function get_arturl( path, video_id ) if string.match( vlc.path, "iurl=" ) then - return vlc.strings.decode_uri( get_url_param( vlc.path, "iurl" ) ) + return vlc.strings( get_url_param( vlc.path, "iurl" ) ) end if not arturl then return "http://img.youtube.com/vi/"..video_id.."/default.jpg" diff --git a/src/playlist/art.c b/src/playlist/art.c index 002ec6ed33..2cffcbbf8f 100644 --- a/src/playlist/art.c +++ b/src/playlist/art.c @@ -132,7 +132,7 @@ static char *ArtCacheName( input_item_t *p_item, const char *psz_type ) char *psz_ext = filename_sanitize( psz_type ? psz_type : "" ); char *psz_filename; - if( asprintf( &psz_filename, "file://%s" DIR_SEP "art%s", psz_path, psz_ext ) < 0 ) + if( asprintf( &psz_filename, "%s" DIR_SEP "art%s", psz_path, psz_ext ) < 0 ) psz_filename = NULL; free( psz_ext ); @@ -164,12 +164,19 @@ int playlist_FindArtInCache( input_item_t *p_item ) if( !strncmp( psz_filename, "art", 3 ) ) { char *psz_file; - if( asprintf( &psz_file, "file://%s" DIR_SEP "%s", + if( asprintf( &psz_file, "%s" DIR_SEP "%s", psz_path, psz_filename ) < 0 ) psz_file = NULL; if( psz_file ) - input_item_SetArtURL( p_item, psz_file ); - free( psz_file ); + { + char *psz_uri = make_URI( psz_file ); + if( psz_uri ) + { + input_item_SetArtURL( p_item, psz_uri ); + free( psz_uri ); + } + free( psz_file ); + } b_found = true; } @@ -192,17 +199,25 @@ int playlist_SaveArt( playlist_t *p_playlist, input_item_t *p_item, if( !psz_filename ) return VLC_EGENERIC; + char *psz_uri = make_URI( psz_filename ); + if( !psz_uri ) + { + free( psz_filename ); + return VLC_EGENERIC; + } + /* Check if we already dumped it */ struct stat s; - if( !utf8_stat( psz_filename+7, &s ) ) + if( !utf8_stat( psz_filename, &s ) ) { - input_item_SetArtURL( p_item, psz_filename ); + input_item_SetArtURL( p_item, psz_uri ); free( psz_filename ); + free( psz_uri ); return VLC_SUCCESS; } /* Dump it otherwise */ - FILE *f = utf8_fopen( psz_filename+7, "wb" ); + FILE *f = utf8_fopen( psz_filename, "wb" ); if( f ) { if( fwrite( p_buffer, i_buffer, 1, f ) != 1 ) @@ -212,11 +227,12 @@ int playlist_SaveArt( playlist_t *p_playlist, input_item_t *p_item, else { msg_Dbg( p_playlist, "album art saved to %s", psz_filename ); - input_item_SetArtURL( p_item, psz_filename ); + input_item_SetArtURL( p_item, psz_uri ); } fclose( f ); } free( psz_filename ); + free( psz_uri ); return VLC_SUCCESS; }