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() */
33 #include <vlc_meta_engine.h>
36 #ifdef HAVE_SYS_STAT_H
37 # include <sys/stat.h>
41 /*****************************************************************************
43 *****************************************************************************/
44 static int FindMeta( vlc_object_t * );
46 /*****************************************************************************
48 *****************************************************************************/
51 /* set_category( CAT_INTERFACE );
52 set_subcategory( SUBCAT_INTERFACE_CONTROL );*/
53 set_shortname( N_( "Dummy" ) );
54 set_description( _("Dummy meta data") );
56 set_capability( "meta engine", 1000 );
57 set_callbacks( FindMeta, NULL );
60 /*****************************************************************************
61 *****************************************************************************/
62 static int FindMeta( vlc_object_t *p_this )
64 meta_engine_t *p_me = (meta_engine_t *)p_this;
65 input_item_t *p_item = p_me->p_item;
67 if( !p_item->p_meta ) return VLC_EGENERIC;
70 #define CHECK( a, b ) \
71 if( p_item->p_meta->psz_ ## a && *p_item->p_meta->psz_ ## a ) \
72 i_meta |= VLC_META_ENGINE_ ## b;
75 CHECK( author, AUTHOR )
76 CHECK( artist, ARTIST )
78 CHECK( copyright, COPYRIGHT )
79 CHECK( album, COLLECTION )
80 CHECK( tracknum, SEQ_NUM )
81 CHECK( description, DESCRIPTION )
82 CHECK( rating, RATING )
85 CHECK( language, LANGUAGE )
86 CHECK( arturl, ART_URL )
88 if( !( i_meta & VLC_META_ENGINE_ART_URL )
89 && ( p_me->i_mandatory & VLC_META_ENGINE_ART_URL ) )
91 if( i_meta & VLC_META_ENGINE_COLLECTION
92 && i_meta & VLC_META_ENGINE_ARTIST )
96 asprintf( &psz_filename,
97 "file://%s/" CONFIG_DIR "/art/%s/%s/art.jpg", /* ahem ... we can have other filetype too... */
98 p_me->p_libvlc->psz_homedir,
99 p_item->p_meta->psz_artist,
100 p_item->p_meta->psz_album );
101 if( utf8_stat( psz_filename+7, &a ) != -1 )
103 vlc_meta_SetArtURL( p_item->p_meta, psz_filename );
104 i_meta |= VLC_META_ENGINE_ART_URL;
106 free( psz_filename );
110 /* Add checks for musicbrainz meta */
112 if( ( p_me->i_mandatory & i_meta ) == p_me->i_mandatory )