1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2006 the VideoLAN team
7 * Authors: Antoine Cellerier <dionoea -at- videolan -dot- org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
28 #include <stdlib.h> /* malloc(), free() */
31 #include <vlc_interface.h>
33 #include <vlc_playlist.h>
34 #include <vlc_input.h>
35 #include <vlc_charset.h>
37 #ifdef HAVE_SYS_STAT_H
38 # include <sys/stat.h>
45 /*****************************************************************************
47 *****************************************************************************/
48 static int FindMeta( vlc_object_t * );
50 /*****************************************************************************
52 *****************************************************************************/
55 set_shortname( N_( "Folder" ) );
56 set_description( _("Folder meta data") );
58 set_capability( "art finder", 90 );
59 set_callbacks( FindMeta, NULL );
62 /*****************************************************************************
63 *****************************************************************************/
64 static int FindMeta( vlc_object_t *p_this )
66 playlist_t *p_playlist = (playlist_t *)p_this;
67 input_item_t *p_item = (input_item_t *)(p_playlist->p_private);
68 vlc_bool_t b_have_art = VLC_FALSE;
72 char psz_filename[MAX_PATH];
73 char *psz_dir = strdup( p_item->psz_uri );
74 char *psz_buf = strrchr( psz_dir, '/' );
86 char *psz_path = psz_dir;
87 if( !strncmp( psz_path, "file://", 7 ) )
90 for( i = 0; b_have_art == VLC_FALSE && i < 3; i++ )
95 /* Windows Folder.jpg */
96 snprintf( psz_filename, MAX_PATH,
97 "file://%sFolder.jpg", psz_path );
101 /* Windows AlbumArtSmall.jpg == small version of Folder.jpg */
102 snprintf( psz_filename, MAX_PATH,
103 "file://%sAlbumArtSmall.jpg", psz_path );
107 /* KDE (?) .folder.png */
108 snprintf( psz_filename, MAX_PATH,
109 "file://%s.folder.png", psz_path );
113 if( utf8_stat( psz_filename+7, &a ) != -1 )
115 input_item_SetArtURL( p_item, psz_filename );
116 b_have_art = VLC_TRUE;
122 return b_have_art ? VLC_SUCCESS : VLC_EGENERIC;