X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=modules%2Fmeta_engine%2Ffolder.c;h=fbb96190ca070aa59a16a5dda91dcc1289313d58;hb=179450e645f04755a2fae880811a52a1a8580f32;hp=4f9856fff911e08d193d560ed94e74163bf5149e;hpb=9a746cfa3078c53eed57d2102002b39c283c6ab4;p=vlc diff --git a/modules/meta_engine/folder.c b/modules/meta_engine/folder.c index 4f9856fff9..fbb96190ca 100644 --- a/modules/meta_engine/folder.c +++ b/modules/meta_engine/folder.c @@ -32,7 +32,9 @@ #include #include #include +#include #include +#include #ifdef HAVE_SYS_STAT_H # include @@ -42,6 +44,15 @@ # define MAX_PATH 250 #endif +static const char* cover_files[] = { + "Folder.jpg", /* Windows */ + "AlbumArtSmall.jpg", /* Windows */ + ".folder.png", /* KDE? */ + "cover.jpg", /* rockbox */ +}; + +static const int i_covers = (sizeof(cover_files)/sizeof(cover_files[0])); + /***************************************************************************** * Local prototypes *****************************************************************************/ @@ -54,7 +65,8 @@ static int FindMeta( vlc_object_t * ); vlc_module_begin () set_shortname( N_( "Folder" ) ) set_description( N_("Folder meta data") ) - + add_file( "album-art-filename", NULL, NULL, + N_("Album art filename"), N_("Filename to look for album art in current directory"), false ); set_capability( "art finder", 90 ) set_callbacks( FindMeta, NULL ) vlc_module_end () @@ -63,12 +75,14 @@ vlc_module_end () *****************************************************************************/ static int FindMeta( vlc_object_t *p_this ) { - input_item_t *p_item = (input_item_t *)p_this->p_private; + art_finder_t *p_finder = (art_finder_t *)p_this; + input_item_t *p_item = p_finder->p_item; bool b_have_art = false; - int i = 0; + int i; struct stat a; char psz_filename[MAX_PATH]; + if( !p_item ) return VLC_EGENERIC; @@ -76,43 +90,37 @@ static int FindMeta( vlc_object_t *p_this ) if( !psz_dir ) return VLC_EGENERIC; - char *psz_buf = strrchr( psz_dir, '/' ); - if( psz_buf ) - { - psz_buf++; - *psz_buf = '\0'; - } - else + char *psz_path = psz_dir; + if( strncmp( psz_path, "file://", 7 ) || !decode_URI( psz_path + 7 ) ) { - *psz_dir = '\0'; + free( psz_dir ); + return VLC_EGENERIC; } - char *psz_path = psz_dir; - if( !strncmp( psz_path, "file://", 7 ) ) - psz_path += 7; +#if defined(WIN32) && !defined(UNDER_CE) + psz_path += 8; +#else + psz_path += 7; +#endif + + char *psz_buf = strrchr( psz_path, '/' ); + if( psz_buf ) + *++psz_buf = '\0'; + else + *psz_path = '\0'; /* relative path */ - for( i = 0; b_have_art == false && i < 3; i++ ) + for( i = -1; !b_have_art && i < i_covers; i++ ) { - switch( i ) + if( i == -1 ) /* higher priority : configured filename */ { - case 0: - /* Windows Folder.jpg */ - snprintf( psz_filename, MAX_PATH, - "%sFolder.jpg", psz_path ); - break; - - case 1: - /* Windows AlbumArtSmall.jpg == small version of Folder.jpg */ - snprintf( psz_filename, MAX_PATH, - "%sAlbumArtSmall.jpg", psz_path ); - break; - - case 2: - /* KDE (?) .folder.png */ - snprintf( psz_filename, MAX_PATH, - "%s.folder.png", psz_path ); - break; + char *psz_userfile = config_GetPsz( p_this, "album-art-filename" ); + if( !psz_userfile ) + continue; + snprintf( psz_filename, MAX_PATH, "%s%s", psz_path, psz_userfile ); + free( psz_userfile ); } + else + snprintf( psz_filename, MAX_PATH, "%s%s", psz_path, cover_files[i] ); if( utf8_stat( psz_filename, &a ) != -1 ) {