Commit 0af7d430 authored by Rafaël Carré's avatar Rafaël Carré

folder meta data retriver: some enhancements

Add rockbox's cover.jpg to the list of known files
Give the possibility to add a custom filename with --album-art-filename
Properly handle URIs on Win32 and other
Cleaner code
parent 70e91fe2
...@@ -43,6 +43,15 @@ ...@@ -43,6 +43,15 @@
# define MAX_PATH 250 # define MAX_PATH 250
#endif #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 * Local prototypes
*****************************************************************************/ *****************************************************************************/
...@@ -55,7 +64,8 @@ static int FindMeta( vlc_object_t * ); ...@@ -55,7 +64,8 @@ static int FindMeta( vlc_object_t * );
vlc_module_begin () vlc_module_begin ()
set_shortname( N_( "Folder" ) ) set_shortname( N_( "Folder" ) )
set_description( N_("Folder meta data") ) 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_capability( "art finder", 90 )
set_callbacks( FindMeta, NULL ) set_callbacks( FindMeta, NULL )
vlc_module_end () vlc_module_end ()
...@@ -67,9 +77,10 @@ static int FindMeta( vlc_object_t *p_this ) ...@@ -67,9 +77,10 @@ static int FindMeta( vlc_object_t *p_this )
input_item_t *p_item = (input_item_t *)p_this->p_private; input_item_t *p_item = (input_item_t *)p_this->p_private;
bool b_have_art = false; bool b_have_art = false;
int i = 0; int i;
struct stat a; struct stat a;
char psz_filename[MAX_PATH]; char psz_filename[MAX_PATH];
if( !p_item ) if( !p_item )
return VLC_EGENERIC; return VLC_EGENERIC;
...@@ -77,43 +88,37 @@ static int FindMeta( vlc_object_t *p_this ) ...@@ -77,43 +88,37 @@ static int FindMeta( vlc_object_t *p_this )
if( !psz_dir ) if( !psz_dir )
return VLC_EGENERIC; return VLC_EGENERIC;
char *psz_buf = strrchr( psz_dir, '/' ); char *psz_path = psz_dir;
if( psz_buf ) if( strncmp( psz_path, "file://", 7 ) || !decode_URI( psz_path + 7 ) )
{
psz_buf++;
*psz_buf = '\0';
}
else
{ {
*psz_dir = '\0'; free( psz_dir );
return VLC_EGENERIC;
} }
char *psz_path = psz_dir; #if defined(WIN32) && !defined(UNDER_CE)
if( !strncmp( psz_path, "file://", 7 ) ) psz_path += 8;
#else
psz_path += 7; psz_path += 7;
#endif
for( i = 0; b_have_art == false && i < 3; i++ ) char *psz_buf = strrchr( psz_path, '/' );
if( psz_buf )
*++psz_buf = '\0';
else
*psz_path = '\0'; /* relative path */
for( i = -1; !b_have_art && i < i_covers; i++ )
{ {
switch( i ) if( i == -1 ) /* higher priority : configured filename */
{ {
case 0: char *psz_userfile = config_GetPsz( p_this, "filename" );
/* Windows Folder.jpg */ if( !psz_userfile )
snprintf( psz_filename, MAX_PATH, continue;
"%sFolder.jpg", psz_path ); snprintf( psz_filename, MAX_PATH, "%s%s", psz_path, psz_userfile );
break; free( psz_userfile );
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;
} }
else
snprintf( psz_filename, MAX_PATH, "%s%s", psz_path, cover_files[i] );
if( utf8_stat( psz_filename, &a ) != -1 ) if( utf8_stat( psz_filename, &a ) != -1 )
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment