Commit 56010546 authored by Antoine Cellerier's avatar Antoine Cellerier

Start of meta engine stuff. src/input/input.c needs to be fixed a bit. I'll...

Start of meta engine stuff. src/input/input.c needs to be fixed a bit. I'll finish it today. @zorglub: now you have to use the psz_arturl meta to display stuff in the interface.
parent 18efcf5c
...@@ -443,6 +443,9 @@ typedef struct global_stats_t global_stats_t; ...@@ -443,6 +443,9 @@ typedef struct global_stats_t global_stats_t;
typedef struct update_t update_t; typedef struct update_t update_t;
typedef struct update_iterator_t update_iterator_t; typedef struct update_iterator_t update_iterator_t;
/* Meta engine */
typedef struct meta_engine_t meta_engine_t;
/***************************************************************************** /*****************************************************************************
* Variable callbacks * Variable callbacks
*****************************************************************************/ *****************************************************************************/
......
/***************************************************************************** /*****************************************************************************
* vlc_input.h: Core input structures * vlc_input.h: Core input structures
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2004 the VideoLAN team * Copyright (C) 1999-2006 the VideoLAN team
* $Id$ * $Id$
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
...@@ -307,7 +307,7 @@ static inline input_title_t *vlc_input_title_Duplicate( input_title_t *t ) ...@@ -307,7 +307,7 @@ static inline input_title_t *vlc_input_title_Duplicate( input_title_t *t )
/* "state" value */ /* "state" value */
enum input_state_e enum input_state_e
{ {
INIT_S, INIT_S,
OPENING_S, OPENING_S,
BUFFERING_S, BUFFERING_S,
PLAYING_S, PLAYING_S,
...@@ -465,6 +465,8 @@ VLC_EXPORT( input_thread_t *, __input_CreateThread, ( vlc_object_t *, input_item ...@@ -465,6 +465,8 @@ VLC_EXPORT( input_thread_t *, __input_CreateThread, ( vlc_object_t *, input_item
VLC_EXPORT( input_thread_t *, __input_CreateThread2, ( vlc_object_t *, input_item_t *, char * ) ); VLC_EXPORT( input_thread_t *, __input_CreateThread2, ( vlc_object_t *, input_item_t *, char * ) );
#define input_Preparse(a,b) __input_Preparse(VLC_OBJECT(a),b) #define input_Preparse(a,b) __input_Preparse(VLC_OBJECT(a),b)
VLC_EXPORT( int, __input_Preparse, ( vlc_object_t *, input_item_t * ) ); VLC_EXPORT( int, __input_Preparse, ( vlc_object_t *, input_item_t * ) );
#define input_SecondaryPreparse(a,b) __input_SecondaryPreparse(VLC_OBJECT(a),b)
VLC_EXPORT( int, __input_SecondaryPreparse, ( vlc_object_t *, input_item_t * ) );
#define input_Read(a,b,c) __input_Read(VLC_OBJECT(a),b, c) #define input_Read(a,b,c) __input_Read(VLC_OBJECT(a),b, c)
VLC_EXPORT( int, __input_Read, ( vlc_object_t *, input_item_t *, vlc_bool_t ) ); VLC_EXPORT( int, __input_Read, ( vlc_object_t *, input_item_t *, vlc_bool_t ) );
......
...@@ -43,6 +43,8 @@ ...@@ -43,6 +43,8 @@
#define VLC_META_PUBLISHER N_("Publisher") #define VLC_META_PUBLISHER N_("Publisher")
#define VLC_META_ENCODED_BY N_("Encoded by") #define VLC_META_ENCODED_BY N_("Encoded by")
#define VLC_META_ART_URL N_("Art URL")
#define VLC_META_CODEC_NAME N_("Codec Name") #define VLC_META_CODEC_NAME N_("Codec Name")
#define VLC_META_CODEC_DESCRIPTION N_("Codec Description") #define VLC_META_CODEC_DESCRIPTION N_("Codec Description")
...@@ -64,6 +66,7 @@ struct vlc_meta_t ...@@ -64,6 +66,7 @@ struct vlc_meta_t
char *psz_nowplaying; char *psz_nowplaying;
char *psz_publisher; char *psz_publisher;
char *psz_encodedby; char *psz_encodedby;
char *psz_arturl;
#if 0 #if 0
/* track meta information */ /* track meta information */
int i_track; int i_track;
...@@ -91,6 +94,7 @@ struct vlc_meta_t ...@@ -91,6 +94,7 @@ struct vlc_meta_t
#define vlc_meta_SetNowPlaying( meta, b ) vlc_meta_Set( meta, nowplaying, b ); #define vlc_meta_SetNowPlaying( meta, b ) vlc_meta_Set( meta, nowplaying, b );
#define vlc_meta_SetPublisher( meta, b ) vlc_meta_Set( meta, publisher, b ); #define vlc_meta_SetPublisher( meta, b ) vlc_meta_Set( meta, publisher, b );
#define vlc_meta_SetEncodedBy( meta, b ) vlc_meta_Set( meta, encodedby, b ); #define vlc_meta_SetEncodedBy( meta, b ) vlc_meta_Set( meta, encodedby, b );
#define vlc_meta_SetArtURL( meta, b ) vlc_meta_Set( meta, arturl, b );
static inline vlc_meta_t *vlc_meta_New( void ) static inline vlc_meta_t *vlc_meta_New( void )
{ {
...@@ -112,6 +116,7 @@ static inline vlc_meta_t *vlc_meta_New( void ) ...@@ -112,6 +116,7 @@ static inline vlc_meta_t *vlc_meta_New( void )
m->psz_nowplaying = NULL; m->psz_nowplaying = NULL;
m->psz_publisher = NULL; m->psz_publisher = NULL;
m->psz_encodedby = NULL; m->psz_encodedby = NULL;
m->psz_arturl = NULL;
return m; return m;
} }
...@@ -133,6 +138,7 @@ static inline void vlc_meta_Delete( vlc_meta_t *m ) ...@@ -133,6 +138,7 @@ static inline void vlc_meta_Delete( vlc_meta_t *m )
free( m->psz_nowplaying ); free( m->psz_nowplaying );
free( m->psz_publisher ); free( m->psz_publisher );
free( m->psz_encodedby ); free( m->psz_encodedby );
free( m->psz_arturl );
free( m ); free( m );
} }
...@@ -161,6 +167,7 @@ static inline void vlc_meta_Merge( vlc_meta_t *dst, vlc_meta_t *src ) ...@@ -161,6 +167,7 @@ static inline void vlc_meta_Merge( vlc_meta_t *dst, vlc_meta_t *src )
COPY_FIELD( nowplaying ); COPY_FIELD( nowplaying );
COPY_FIELD( publisher ); COPY_FIELD( publisher );
COPY_FIELD( encodedby ); COPY_FIELD( encodedby );
COPY_FIELD( arturl );
} }
/** \todo Track meta */ /** \todo Track meta */
......
/*****************************************************************************
* vlc_meta_engine.h: meta engine module.
*****************************************************************************
* Copyright (C) 2006 the VideoLAN team
* $Id$
*
* Authors: Antoine Cellerier <dionoea A videolan D org>
*
* 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.
*****************************************************************************/
#ifndef _VLC_META_ENGINE_H
#define _VLC_META_ENGINE_H
#include "vlc_meta.h"
#define VLC_META_ENGINE_TITLE 0x00000001
#define VLC_META_ENGINE_AUTHOR 0x00000002
#define VLC_META_ENGINE_ARTIST 0x00000004
#define VLC_META_ENGINE_GENRE 0x00000008
#define VLC_META_ENGINE_COPYRIGHT 0x00000010
#define VLC_META_ENGINE_COLLECTION 0x00000020
#define VLC_META_ENGINE_SEQ_NUM 0x00000040
#define VLC_META_ENGINE_DESCRIPTION 0x00000080
#define VLC_META_ENGINE_RATING 0x00000100
#define VLC_META_ENGINE_DATE 0x00000200
#define VLC_META_ENGINE_URL 0x00000400
#define VLC_META_ENGINE_LANGUAGE 0x00000800
#define VLC_META_ENGINE_ART_URL 0x00001000
#define VLC_META_ENGINE_MB_ARTIST_ID 0x00002000
#define VLC_META_ENGINE_MB_RELEASE_ID 0x00004000
#define VLC_META_ENGINE_MB_TRACK_ID 0x00008000
#define VLC_META_ENGINE_MB_TRM_ID 0x00010000
typedef struct meta_engine_sys_t meta_engine_sys_t;
struct meta_engine_t
{
VLC_COMMON_MEMBERS
module_t *p_module;
uint32_t i_mandatory; /**< Stuff which we really need to get */
uint32_t i_optional; /**< Stuff which we'd like to have */
input_item_t *p_item;
};
#endif
/***************************************************************************** /*****************************************************************************
* vlc_objects.h: vlc_object_t definition and manipulation methods * vlc_objects.h: vlc_object_t definition and manipulation methods
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 the VideoLAN team * Copyright (C) 2002-2006 the VideoLAN team
* $Id$ * $Id$
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
...@@ -32,38 +32,39 @@ ...@@ -32,38 +32,39 @@
*/ */
/* Object types */ /* Object types */
#define VLC_OBJECT_ROOT (-1) #define VLC_OBJECT_ROOT (-1)
#define VLC_OBJECT_LIBVLC (-2) #define VLC_OBJECT_LIBVLC (-2)
#define VLC_OBJECT_MODULE (-3) #define VLC_OBJECT_MODULE (-3)
#define VLC_OBJECT_INTF (-4) #define VLC_OBJECT_INTF (-4)
#define VLC_OBJECT_PLAYLIST (-5) #define VLC_OBJECT_PLAYLIST (-5)
#define VLC_OBJECT_ITEM (-6) #define VLC_OBJECT_ITEM (-6)
#define VLC_OBJECT_INPUT (-7) #define VLC_OBJECT_INPUT (-7)
#define VLC_OBJECT_DECODER (-8) #define VLC_OBJECT_DECODER (-8)
#define VLC_OBJECT_VOUT (-9) #define VLC_OBJECT_VOUT (-9)
#define VLC_OBJECT_AOUT (-10) #define VLC_OBJECT_AOUT (-10)
#define VLC_OBJECT_SOUT (-11) #define VLC_OBJECT_SOUT (-11)
#define VLC_OBJECT_HTTPD (-12) #define VLC_OBJECT_HTTPD (-12)
#define VLC_OBJECT_PACKETIZER (-13) #define VLC_OBJECT_PACKETIZER (-13)
#define VLC_OBJECT_ENCODER (-14) #define VLC_OBJECT_ENCODER (-14)
#define VLC_OBJECT_DIALOGS (-15) #define VLC_OBJECT_DIALOGS (-15)
#define VLC_OBJECT_VLM (-16) #define VLC_OBJECT_VLM (-16)
#define VLC_OBJECT_ANNOUNCE (-17) #define VLC_OBJECT_ANNOUNCE (-17)
#define VLC_OBJECT_DEMUX (-18) #define VLC_OBJECT_DEMUX (-18)
#define VLC_OBJECT_ACCESS (-19) #define VLC_OBJECT_ACCESS (-19)
#define VLC_OBJECT_STREAM (-20) #define VLC_OBJECT_STREAM (-20)
#define VLC_OBJECT_OPENGL (-21) #define VLC_OBJECT_OPENGL (-21)
#define VLC_OBJECT_FILTER (-22) #define VLC_OBJECT_FILTER (-22)
#define VLC_OBJECT_VOD (-23) #define VLC_OBJECT_VOD (-23)
#define VLC_OBJECT_SPU (-24) #define VLC_OBJECT_SPU (-24)
#define VLC_OBJECT_TLS (-25) #define VLC_OBJECT_TLS (-25)
#define VLC_OBJECT_SD (-26) #define VLC_OBJECT_SD (-26)
#define VLC_OBJECT_XML (-27) #define VLC_OBJECT_XML (-27)
#define VLC_OBJECT_OSDMENU (-28) #define VLC_OBJECT_OSDMENU (-28)
#define VLC_OBJECT_STATS (-29) #define VLC_OBJECT_STATS (-29)
#define VLC_OBJECT_HTTPD_HOST (-30) #define VLC_OBJECT_HTTPD_HOST (-30)
#define VLC_OBJECT_META_ENGINE (-31)
#define VLC_OBJECT_GENERIC (-666)
#define VLC_OBJECT_GENERIC (-666)
/* Object search mode */ /* Object search mode */
#define FIND_PARENT 0x0001 #define FIND_PARENT 0x0001
......
...@@ -145,6 +145,7 @@ struct playlist_t ...@@ -145,6 +145,7 @@ struct playlist_t
mtime_t i_vout_destroyed_date; mtime_t i_vout_destroyed_date;
mtime_t i_sout_destroyed_date; mtime_t i_sout_destroyed_date;
playlist_preparse_t *p_preparse; /**< Preparser object */ playlist_preparse_t *p_preparse; /**< Preparser object */
playlist_preparse_t *p_secondary_preparse; /**< Preparser object */
vlc_mutex_t gc_lock; /**< Lock to protect the garbage collection */ vlc_mutex_t gc_lock; /**< Lock to protect the garbage collection */
......
...@@ -538,6 +538,7 @@ struct module_symbols_t ...@@ -538,6 +538,7 @@ struct module_symbols_t
void (*aout_EnableFilter_inner) (vlc_object_t *, const char *, vlc_bool_t); void (*aout_EnableFilter_inner) (vlc_object_t *, const char *, vlc_bool_t);
void (*playlist_NodesPairCreate_inner) (playlist_t *, char *, playlist_item_t **, playlist_item_t **, vlc_bool_t); void (*playlist_NodesPairCreate_inner) (playlist_t *, char *, playlist_item_t **, playlist_item_t **, vlc_bool_t);
char * (*aout_VisualChange_inner) (vlc_object_t *, int); char * (*aout_VisualChange_inner) (vlc_object_t *, int);
int (*__input_SecondaryPreparse_inner) (vlc_object_t *, input_item_t *);
}; };
# if defined (__PLUGIN__) # if defined (__PLUGIN__)
# define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner # define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner
...@@ -1010,6 +1011,7 @@ struct module_symbols_t ...@@ -1010,6 +1011,7 @@ struct module_symbols_t
# define aout_EnableFilter (p_symbols)->aout_EnableFilter_inner # define aout_EnableFilter (p_symbols)->aout_EnableFilter_inner
# define playlist_NodesPairCreate (p_symbols)->playlist_NodesPairCreate_inner # define playlist_NodesPairCreate (p_symbols)->playlist_NodesPairCreate_inner
# define aout_VisualChange (p_symbols)->aout_VisualChange_inner # define aout_VisualChange (p_symbols)->aout_VisualChange_inner
# define __input_SecondaryPreparse (p_symbols)->__input_SecondaryPreparse_inner
# elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__) # elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__)
/****************************************************************** /******************************************************************
* STORE_SYMBOLS: store VLC APIs into p_symbols for plugin access. * STORE_SYMBOLS: store VLC APIs into p_symbols for plugin access.
...@@ -1485,6 +1487,7 @@ struct module_symbols_t ...@@ -1485,6 +1487,7 @@ struct module_symbols_t
((p_symbols)->aout_EnableFilter_inner) = aout_EnableFilter; \ ((p_symbols)->aout_EnableFilter_inner) = aout_EnableFilter; \
((p_symbols)->playlist_NodesPairCreate_inner) = playlist_NodesPairCreate; \ ((p_symbols)->playlist_NodesPairCreate_inner) = playlist_NodesPairCreate; \
((p_symbols)->aout_VisualChange_inner) = aout_VisualChange; \ ((p_symbols)->aout_VisualChange_inner) = aout_VisualChange; \
((p_symbols)->__input_SecondaryPreparse_inner) = __input_SecondaryPreparse; \
(p_symbols)->net_ConvertIPv4_deprecated = NULL; \ (p_symbols)->net_ConvertIPv4_deprecated = NULL; \
(p_symbols)->__playlist_ItemNew_deprecated = NULL; \ (p_symbols)->__playlist_ItemNew_deprecated = NULL; \
(p_symbols)->__playlist_ItemCopy_deprecated = NULL; \ (p_symbols)->__playlist_ItemCopy_deprecated = NULL; \
......
SOURCES_musicbrainz = musicbrainz.c
...@@ -29,173 +29,108 @@ ...@@ -29,173 +29,108 @@
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/intf.h> #include <vlc/intf.h>
#include <vlc_meta.h> #include <vlc_meta.h>
#include <vlc_meta_engine.h>
#include "musicbrainz/mb_c.h" #include "musicbrainz/mb_c.h"
/*****************************************************************************
* intf_sys_t: description and status of log interface
*****************************************************************************/
struct intf_sys_t
{
};
/***************************************************************************** /*****************************************************************************
* Local prototypes * Local prototypes
*****************************************************************************/ *****************************************************************************/
static int Open ( vlc_object_t * ); static int FindMeta( vlc_object_t * );
static void Close ( vlc_object_t * );
static int ItemChange( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * );
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
*****************************************************************************/ *****************************************************************************/
vlc_module_begin(); vlc_module_begin();
set_category( CAT_INTERFACE ); /* set_category( CAT_INTERFACE );
set_subcategory( SUBCAT_INTERFACE_CONTROL ); set_subcategory( SUBCAT_INTERFACE_CONTROL );*/
set_shortname( N_( "MusicBrainz" ) ); set_shortname( N_( "MusicBrainz" ) );
set_description( _("MusicBrainz meta data") ); set_description( _("MusicBrainz meta data") );
set_capability( "interface", 0 ); set_capability( "meta engine", 80 );
set_callbacks( Open, Close ); set_callbacks( FindMeta, NULL );
vlc_module_end(); vlc_module_end();
/***************************************************************************** /*****************************************************************************
* Open: initialize and create stuff
*****************************************************************************/ *****************************************************************************/
static int Open( vlc_object_t *p_this ) static int FindMeta( vlc_object_t *p_this )
{ {
intf_thread_t *p_intf = (intf_thread_t *)p_this; meta_engine_t *p_me = (meta_engine_t *)p_this;
playlist_t *p_playlist; input_item_t *p_item = p_me->p_item;
MALLOC_ERR( p_intf->p_sys, intf_sys_t );
p_playlist = pl_Yield( p_intf );
var_AddCallback( p_playlist, "item-change", ItemChange, p_intf );
var_AddCallback( p_playlist, "playlist-current", ItemChange, p_intf );
pl_Release( p_intf );
return VLC_SUCCESS;
}
/*****************************************************************************
* Close: destroy interface stuff
*****************************************************************************/
static void Close( vlc_object_t *p_this )
{
intf_thread_t *p_intf = (intf_thread_t *)p_this;
playlist_t *p_playlist = pl_Yield( p_this );
var_DelCallback( p_playlist, "item-change", ItemChange, p_intf );
var_DelCallback( p_playlist, "playlist-current", ItemChange, p_intf );
pl_Release( p_this );
/* Destroy structure */
free( p_intf->p_sys );
}
/*****************************************************************************
* ItemChange: Playlist item change callback
*****************************************************************************/
static int ItemChange( vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *param )
{
intf_thread_t *p_intf = (intf_thread_t *)param;
char *psz_title = NULL; char *psz_title = NULL;
char *psz_artist = NULL; char *psz_artist = NULL;
char *psz_album = NULL; char *psz_album = NULL;
input_thread_t *p_input;
playlist_t *p_playlist = pl_Yield( p_this );
p_input = p_playlist->p_input; char psz_buf[256];
pl_Release( p_this ); char psz_data[256];
char i_album_count, i;
char *ppsz_args[4];
if( !p_input ) return VLC_SUCCESS; if( !p_item->p_meta ) return VLC_EGENERIC;
vlc_object_yield( p_input ); psz_artist = p_item->p_meta->psz_artist;
psz_album = p_item->p_meta->psz_album;
psz_title = p_item->psz_name;
if( p_input->b_dead || !p_input->input.p_item->psz_name ) if( !psz_artist || !psz_album )
return VLC_EGENERIC;
musicbrainz_t p_mb;
p_mb = mb_New();
#ifdef WIN32
mb_WSAInit( p_mb );
#endif
mb_SetDepth( p_mb, 2 );
ppsz_args[0] = psz_album;
ppsz_args[1] = psz_artist;
ppsz_args[2] = NULL;
if( !mb_QueryWithArgs( p_mb,
"<mq:FindAlbum>\n" \
" <mq:depth>@DEPTH@</mq:depth>\n" \
" <mq:maxItems>@MAX_ITEMS@</mq:maxItems>\n" \
" <mq:albumName>@1@</mq:albumName>\n" \
" <mq:artistName>@2@</mq:artistName>\n" \
"</mq:FindAlbum>\n", ppsz_args ) )
{ {
/* Not playing anything ... */ mb_GetQueryError( p_mb, psz_buf, 256 );
vlc_object_release( p_input ); msg_Err( p_me, "Query failed: %s\n", psz_buf );
return VLC_SUCCESS; mb_Delete( p_mb );
return VLC_EGENERIC;
} }
/* Playing something ... */ i_album_count = mb_GetResultInt( p_mb, MBE_GetNumAlbums );
psz_artist = p_input->input.p_item->p_meta->psz_artist; if( i_album_count < 1 )
psz_album = p_input->input.p_item->p_meta->psz_album;
psz_title = p_input->input.p_item->psz_name;
if( psz_artist && psz_album /* && psz_title */ )
{ {
musicbrainz_t p_mb; msg_Err( p_me, "No albums found.\n" );
char psz_buf[256]; mb_Delete( p_mb );
char psz_data[256]; return VLC_EGENERIC;
char i_album_count, i; }
char *ppsz_args[4];
fprintf( stdout,"--> %s %s %s\n", psz_artist, psz_album, psz_title );
p_mb = mb_New();
#ifdef WIN32
mb_WSAInit( p_mb );
#endif
mb_SetDepth( p_mb, 2 );
ppsz_args[0] = psz_album;
ppsz_args[1] = psz_artist;
ppsz_args[2] = NULL;
if( !mb_QueryWithArgs( p_mb,
"<mq:FindAlbum>\n" \
" <mq:depth>@DEPTH@</mq:depth>\n" \
" <mq:maxItems>@MAX_ITEMS@</mq:maxItems>\n" \
" <mq:albumName>@1@</mq:albumName>\n" \
" <mq:artistName>@2@</mq:artistName>\n" \
"</mq:FindAlbum>\n", ppsz_args ) )
{
mb_GetQueryError( p_mb, psz_buf, 256 );
msg_Err( p_intf, "Query failed: %s\n", psz_buf );
mb_Delete( p_mb );
vlc_object_release( p_input );
return VLC_EGENERIC;
}
i_album_count = mb_GetResultInt( p_mb, MBE_GetNumAlbums ); msg_Dbg( p_me, "Found %d albums.\n", i_album_count );
if( i_album_count < 1 )
{ for( i = 1; i <= i_album_count; i++ )
msg_Err( p_intf, "No albums found.\n" ); {
mb_Delete( p_mb ); mb_Select( p_mb, MBS_Rewind );
vlc_object_release( p_input ); mb_Select1( p_mb, MBS_SelectAlbum, i );
return VLC_EGENERIC;
}
msg_Dbg( p_intf, "Found %d albums.\n", i_album_count ); mb_GetResultData( p_mb, MBE_AlbumGetAlbumId, psz_data, 256 );
mb_GetIDFromURL( p_mb, psz_data, psz_buf, 256 );
msg_Dbg( p_me, "Album Id: %s", psz_buf );
for( i = 1; i <= i_album_count; i++ ) if( mb_GetResultData( p_mb, MBE_AlbumGetAmazonAsin, psz_buf, 256 ) )
{ {
mb_Select( p_mb, MBS_Rewind ); msg_Dbg( p_me, "Amazon ASIN: %s", psz_buf );
mb_Select1( p_mb, MBS_SelectAlbum, i ); sprintf( psz_data, "http://images.amazon.com/images/P/%s.01._SCLZZZZZZZ_.jpg", psz_buf );
vlc_meta_SetArtURL( p_item->p_meta, psz_data );
mb_GetResultData( p_mb, MBE_AlbumGetAlbumId, psz_data, 256 ); break;
mb_GetIDFromURL( p_mb, psz_data, psz_buf, 256 );
msg_Dbg( p_intf, "Album Id: %s", psz_buf );
if( mb_GetResultData( p_mb, MBE_AlbumGetAmazonAsin, psz_buf, 256 ) )
{
msg_Dbg( p_intf, "Amazon ASIN: %s", psz_buf );
msg_Dbg( p_intf, "Album art url: " "http://images.amazon.com/images/P/%s.01._AA240_SCLZZZZZZZ_.jpg", psz_buf );
break;
}
} }
}
#ifdef WIN32 #ifdef WIN32
mb_WSAInit( p_mb ); mb_WSAInit( p_mb );
#endif #endif
mb_Delete( p_mb ); mb_Delete( p_mb );
}
vlc_object_release( p_input );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -12,4 +12,3 @@ SOURCES_gnutls = gnutls.c ...@@ -12,4 +12,3 @@ SOURCES_gnutls = gnutls.c
SOURCES_svg = svg.c SOURCES_svg = svg.c
SOURCES_profile_parser = profile_parser.c SOURCES_profile_parser = profile_parser.c
SOURCES_audioscrobbler = audioscrobbler.c SOURCES_audioscrobbler = audioscrobbler.c
SOURCES_musicbrainz = musicbrainz.c
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include "vlc_playlist.h" #include "vlc_playlist.h"
#include "vlc_interface.h" #include "vlc_interface.h"
#include "vlc_interaction.h" #include "vlc_interaction.h"
#include "vlc_meta_engine.h"
#include "charset.h" #include "charset.h"
...@@ -344,6 +345,110 @@ int __input_Preparse( vlc_object_t *p_parent, input_item_t *p_item ) ...@@ -344,6 +345,110 @@ int __input_Preparse( vlc_object_t *p_parent, input_item_t *p_item )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
int __input_SecondaryPreparse( vlc_object_t *p_parent, input_item_t *p_item )
{
struct meta_engine_t *p_me;
/* FIXME: don't launch any module if we already have all the needed
* info. Easiest way to do this would be to add a dummy module.
* I'll do that later */
p_me = vlc_object_create( p_parent, VLC_OBJECT_META_ENGINE );
p_me->i_flags |= OBJECT_FLAGS_NOINTERACT;
p_me->i_mandatory = VLC_META_ENGINE_TITLE
| VLC_META_ENGINE_AUTHOR
| VLC_META_ENGINE_ARTIST
| VLC_META_ENGINE_ART_URL;
p_me->i_optional = 0;
p_me->p_item = p_item;
p_me->p_module = module_Need( p_me, "meta engine", 0, VLC_FALSE );
if( !p_me->p_module )
{
msg_Err( p_parent, "no suitable meta engine module" );
return VLC_EGENERIC;
}
module_Unneed( p_me, p_me->p_module );
if( p_item->p_meta