]> git.sesse.net Git - vlc/blob - modules/meta_engine/dummy.c
Fix include paths
[vlc] / modules / meta_engine / dummy.c
1 /*****************************************************************************
2  * dummy.c
3  *****************************************************************************
4  * Copyright (C) 2006 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Antoine Cellerier <dionoea -at- videolan -dot- org>
8  *
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.
13  *
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.
18  *
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  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #define _GNU_SOURCE
28 #include <stdlib.h>                                      /* malloc(), free() */
29
30 #include <vlc/vlc.h>
31 #include <vlc/intf.h>
32 #include <vlc_meta.h>
33 #include <vlc_meta.h>
34 #include <charset.h>
35
36 #ifdef HAVE_SYS_STAT_H
37 #   include <sys/stat.h>
38 #endif
39
40
41 /*****************************************************************************
42  * Local prototypes
43  *****************************************************************************/
44 static int FindMeta( vlc_object_t * );
45
46 /*****************************************************************************
47  * Module descriptor
48  *****************************************************************************/
49
50 vlc_module_begin();
51 /*    set_category( CAT_INTERFACE );
52     set_subcategory( SUBCAT_INTERFACE_CONTROL );*/
53     set_shortname( N_( "Dummy" ) );
54     set_description( _("Dummy meta data") );
55
56     set_capability( "meta engine", 0 );
57     set_callbacks( FindMeta, NULL );
58 vlc_module_end();
59
60 /*****************************************************************************
61  *****************************************************************************/
62 static int FindMeta( vlc_object_t *p_this )
63 {
64     meta_engine_t *p_me = (meta_engine_t *)p_this;
65     input_item_t *p_item = p_me->p_item;
66
67     if( !p_item->p_meta ) return VLC_EGENERIC;
68
69     uint32_t i_meta = 0;
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;
73
74     CHECK( title, TITLE )
75     CHECK( author, AUTHOR )
76     CHECK( artist, ARTIST )
77     CHECK( genre, GENRE )
78     CHECK( copyright, COPYRIGHT )
79     CHECK( album, COLLECTION )
80     CHECK( tracknum, SEQ_NUM )
81     CHECK( description, DESCRIPTION )
82     CHECK( rating, RATING )
83     CHECK( date, DATE )
84     CHECK( url, URL )
85     CHECK( language, LANGUAGE )
86     CHECK( arturl, ART_URL )
87
88     if( !( i_meta & VLC_META_ENGINE_ART_URL )
89         && ( p_me->i_mandatory & VLC_META_ENGINE_ART_URL ) )
90     {
91         if( i_meta & VLC_META_ENGINE_COLLECTION
92             && i_meta & VLC_META_ENGINE_ARTIST )
93         {
94             char *psz_filename;
95             struct stat a;
96             asprintf( &psz_filename,
97                       "file://%s" DIR_SEP CONFIG_DIR DIR_SEP "art"
98                       DIR_SEP "%s" DIR_SEP "%s" DIR_SEP "art.jpg", /* ahem ... we can have other filetype too... */
99                       p_me->p_libvlc->psz_homedir,
100                       p_item->p_meta->psz_artist,
101                       p_item->p_meta->psz_album );
102             if( utf8_stat( psz_filename+7, &a ) != -1 )
103             {
104                 vlc_meta_SetArtURL( p_item->p_meta, psz_filename );
105                 i_meta |= VLC_META_ENGINE_ART_URL;
106             }
107             free( psz_filename );
108         }
109     }
110
111     /* Add checks for musicbrainz meta */
112
113     if( ( p_me->i_mandatory & i_meta ) == p_me->i_mandatory )
114     {
115         return VLC_SUCCESS;
116     }
117     else
118     {
119         return VLC_EGENERIC;
120      }
121 }