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 *****************************************************************************/
32 #include <vlc_common.h>
33 #include <vlc_plugin.h>
34 #include <vlc_interface.h>
36 #include <vlc_playlist.h>
37 #include <vlc_input.h>
38 #include <vlc_charset.h>
40 #ifdef HAVE_SYS_STAT_H
41 # include <sys/stat.h>
48 /*****************************************************************************
50 *****************************************************************************/
51 static int FindMeta( vlc_object_t
* );
53 /*****************************************************************************
55 *****************************************************************************/
58 set_shortname( N_( "Folder" ) );
59 set_description( N_("Folder meta data") );
61 set_capability( "art finder", 90 );
62 set_callbacks( FindMeta
, NULL
);
65 /*****************************************************************************
66 *****************************************************************************/
67 static int FindMeta( vlc_object_t
*p_this
)
69 playlist_t
*p_playlist
= (playlist_t
*)p_this
;
70 input_item_t
*p_item
= (input_item_t
*)(p_playlist
->p_private
);
71 bool b_have_art
= false;
75 char psz_filename
[MAX_PATH
];
79 char *psz_dir
= input_item_GetURI( p_item
);
83 char *psz_buf
= strrchr( psz_dir
, '/' );
94 char *psz_path
= psz_dir
;
95 if( !strncmp( psz_path
, "file://", 7 ) )
98 for( i
= 0; b_have_art
== false && i
< 3; i
++ )
103 /* Windows Folder.jpg */
104 snprintf( psz_filename
, MAX_PATH
,
105 "file://%sFolder.jpg", psz_path
);
109 /* Windows AlbumArtSmall.jpg == small version of Folder.jpg */
110 snprintf( psz_filename
, MAX_PATH
,
111 "file://%sAlbumArtSmall.jpg", psz_path
);
115 /* KDE (?) .folder.png */
116 snprintf( psz_filename
, MAX_PATH
,
117 "file://%s.folder.png", psz_path
);
121 if( utf8_stat( psz_filename
+7, &a
) != -1 )
123 input_item_SetArtURL( p_item
, psz_filename
);
130 return b_have_art
? VLC_SUCCESS
: VLC_EGENERIC
;