From 3b7408fac22adfb43dc4d16c892181023be1863c Mon Sep 17 00:00:00 2001 From: Antoine Cellerier Date: Sat, 23 Sep 2006 16:56:12 +0000 Subject: [PATCH] Add dummy meta engine with highest priority. Will check if meta is already available. --- modules/meta_engine/Modules.am | 1 + modules/meta_engine/dummy.c | 116 +++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+) create mode 100644 modules/meta_engine/dummy.c diff --git a/modules/meta_engine/Modules.am b/modules/meta_engine/Modules.am index 042633aa2f..4dbbd9995c 100644 --- a/modules/meta_engine/Modules.am +++ b/modules/meta_engine/Modules.am @@ -1 +1,2 @@ SOURCES_musicbrainz = musicbrainz.c +SOURCES_dummy = dummy.c diff --git a/modules/meta_engine/dummy.c b/modules/meta_engine/dummy.c new file mode 100644 index 0000000000..c31ffba163 --- /dev/null +++ b/modules/meta_engine/dummy.c @@ -0,0 +1,116 @@ +/***************************************************************************** + * dummy.c + ***************************************************************************** + * Copyright (C) 2006 the VideoLAN team + * $Id$ + * + * Authors: Antoine Cellerier + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +/***************************************************************************** + * Preamble + *****************************************************************************/ +#define _GNU_SOURCE +#include /* malloc(), free() */ + +#include +#include +#include +#include +#include + +/***************************************************************************** + * Local prototypes + *****************************************************************************/ +static int FindMeta( vlc_object_t * ); + +/***************************************************************************** + * Module descriptor + *****************************************************************************/ + +vlc_module_begin(); +/* set_category( CAT_INTERFACE ); + set_subcategory( SUBCAT_INTERFACE_CONTROL );*/ + set_shortname( N_( "Dummy" ) ); + set_description( _("Dummy meta data") ); + + set_capability( "meta engine", 1000 ); + set_callbacks( FindMeta, NULL ); +vlc_module_end(); + +/***************************************************************************** + *****************************************************************************/ +static int FindMeta( vlc_object_t *p_this ) +{ + meta_engine_t *p_me = (meta_engine_t *)p_this; + input_item_t *p_item = p_me->p_item; + + if( !p_item->p_meta ) return VLC_EGENERIC; + + uint32_t i_meta = 0; +#define CHECK( a, b ) \ + if( p_item->p_meta->psz_ ## a && *p_item->p_meta->psz_ ## a ) \ + i_meta |= VLC_META_ENGINE_ ## b; + + CHECK( title, TITLE ) + CHECK( author, AUTHOR ) + CHECK( artist, ARTIST ) + CHECK( genre, GENRE ) + CHECK( copyright, COPYRIGHT ) + CHECK( album, COLLECTION ) + CHECK( tracknum, SEQ_NUM ) + CHECK( description, DESCRIPTION ) + CHECK( rating, RATING ) + CHECK( date, DATE ) + CHECK( url, URL ) + CHECK( language, LANGUAGE ) + CHECK( arturl, ART_URL ) + + if( !(i_meta & VLC_META_ENGINE_ART_URL) ) + { + if( i_meta & VLC_META_ENGINE_COLLECTION + && i_meta & VLC_META_ENGINE_ARTIST ) + { + FILE *p_file; + char *psz_filename; + asprintf( &psz_filename, + "file://%s/" CONFIG_DIR "/art/%s/%s/art.jpg", /* ahem ... we can have other filetype too... */ + p_me->p_libvlc->psz_homedir, + p_item->p_meta->psz_artist, + p_item->p_meta->psz_album ); + p_file = utf8_fopen( psz_filename+7, "r" ); + if( p_file ) + { + fclose( p_file ); + vlc_meta_SetArtURL( p_item->p_meta, psz_filename ); + i_meta |= VLC_META_ENGINE_ART_URL; + } + free( psz_filename ); + } + } + + /* Add checks for musicbrainz meta */ + + if( ( p_me->i_mandatory & i_meta ) == p_me->i_mandatory ) + { + return VLC_SUCCESS; + } + else + { + return VLC_EGENERIC; + } +} -- 2.39.2