From: Rafaël Carré Date: Sun, 1 Oct 2006 20:32:30 +0000 (+0000) Subject: Added psz_trackid, psz_artistid, psz_albumid to vlc_meta_t to store musicbrainz uniqu... X-Git-Tag: 0.9.0-test0~10060 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=17c15b2e631cc3480970dd2ccfff20d6013de71a;p=vlc Added psz_trackid, psz_artistid, psz_albumid to vlc_meta_t to store musicbrainz unique identifiers Make use of psz_trackid in audioscrobbler.c Reading of this data is only implemented in vorbis.c taglib.cpp and id3tag.c need to be updated --- diff --git a/THANKS b/THANKS index 73e19a9c22..2cec8d1774 100644 --- a/THANKS +++ b/THANKS @@ -126,7 +126,7 @@ Pavlov Konstantin “thresh” - several Linux build system fixes Petr Vacek - FTP cleartext authentication Philippe Van Hecke - SAP header hash patch Pierre Marc Dumuid - Playlist patches -Rafaël Carré - Audioscrobbler plugin +Rafaël Carré - Audioscrobbler plugin Régis Duchesne - original VLC code Remco Poortinga - IPv6 multicast patch Rene Gollent - BeOS interface fix diff --git a/include/vlc_meta.h b/include/vlc_meta.h index 372992110d..d12b432227 100644 --- a/include/vlc_meta.h +++ b/include/vlc_meta.h @@ -70,6 +70,9 @@ struct vlc_meta_t char *psz_publisher; char *psz_encodedby; char *psz_arturl; + char *psz_trackid; + char *psz_artistid; + char *psz_albumid; int i_status; #if 0 @@ -99,6 +102,10 @@ struct vlc_meta_t #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_SetArtURL( meta, b ) vlc_meta_Set( meta, arturl, b ); +#define vlc_meta_SetTrackID( meta, b ) vlc_meta_Set( meta, trackid, b ); +#define vlc_meta_SetArtistID( meta, b ) vlc_meta_Set( meta, artistid, b ); +#define vlc_meta_SetAlbumID( meta, b ) vlc_meta_Set( meta, albumid, b ); + static inline vlc_meta_t *vlc_meta_New( void ) { @@ -120,6 +127,9 @@ static inline vlc_meta_t *vlc_meta_New( void ) m->psz_publisher = NULL; m->psz_encodedby = NULL; m->psz_arturl = NULL; + m->psz_trackid = NULL; + m->psz_artistid = NULL; + m->psz_albumid = NULL; m->i_status = 0; return m; } @@ -141,6 +151,9 @@ static inline void vlc_meta_Delete( vlc_meta_t *m ) free( m->psz_nowplaying ); free( m->psz_publisher ); free( m->psz_encodedby ); + free( m->psz_trackid ); + free( m->psz_artistid ); + free( m->psz_albumid ); free( m->psz_arturl ); free( m ); @@ -169,6 +182,9 @@ static inline void vlc_meta_Merge( vlc_meta_t *dst, vlc_meta_t *src ) COPY_FIELD( nowplaying ); COPY_FIELD( publisher ); COPY_FIELD( encodedby ); + COPY_FIELD( trackid ); + COPY_FIELD( artistid ); + COPY_FIELD( albumid ); COPY_FIELD( arturl ); } /** \todo Track meta */ diff --git a/modules/codec/vorbis.c b/modules/codec/vorbis.c index 8ae6992448..d33e8bf0ca 100644 --- a/modules/codec/vorbis.c +++ b/modules/codec/vorbis.c @@ -626,13 +626,28 @@ static void ParseVorbisComments( decoder_t *p_dec ) else if( !strcasecmp( psz_name, "title" ) ) { vlc_meta_SetTitle( p_input->input.p_item->p_meta, - psz_value ); + psz_value ); p_input->input.p_item->psz_name = strdup( psz_value ); } else if( !strcasecmp( psz_name, "album" ) ) { vlc_meta_SetAlbum( p_input->input.p_item->p_meta, - psz_value ); + psz_value ); + } + else if( !strcasecmp( psz_name, "musicbrainz_trackid" ) ) + { + vlc_meta_SetTrackID( p_input->input.p_item->p_meta, + psz_value ); + } + else if( !strcasecmp( psz_name, "musicbrainz_artistid" ) ) + { + vlc_meta_SetArtistID( p_input->input.p_item->p_meta, + psz_value ); + } + else if( !strcasecmp( psz_name, "musicbrainz_albumid" ) ) + { + vlc_meta_SetAlbumID( p_input->input.p_item->p_meta, + psz_value ); } } /* FIXME */ diff --git a/modules/misc/audioscrobbler.c b/modules/misc/audioscrobbler.c index 019c2a7d30..c1d7fdb0e9 100644 --- a/modules/misc/audioscrobbler.c +++ b/modules/misc/audioscrobbler.c @@ -4,7 +4,7 @@ * Copyright (C) 2006 the VideoLAN team * $Id$ * - * Authors: Rafaël Carré + * Authors: Rafaël Carré * Kenneth Ostby * * This program is free software; you can redistribute it and/or modify @@ -59,8 +59,7 @@ typedef struct audioscrobbler_song_t char *psz_t; /* track title */ char *psz_b; /* track album */ int i_l; /* track length */ -/* vlc can't retrieve musicbrainz id, so let's ignore it */ -/* int i_m; */ /* musicbrainz id */ + char *psz_m; /* musicbrainz id */ char *psz_i; /* date */ time_t time_playing; /* date (epoch) */ } audioscrobbler_song_t; @@ -146,7 +145,7 @@ void DeleteQueue( audioscrobbler_queue_t *p_queue ); /* data to submit */ #define POST_DATA "u=%s&s=%s&a%%5B%d%%5D=%s&t%%5B%d%%5D=%s" \ - "&b%%5B%d%%5D=%s&m%%5B%d%%5D=&l%%5B%d%%5D=%d&i%%5B%d%%5D=%s" + "&b%%5B%d%%5D=%s&m%%5B%d%%5D=%s&l%%5B%d%%5D=%d&i%%5B%d%%5D=%s" vlc_module_begin(); set_category( CAT_INTERFACE ); @@ -378,7 +377,7 @@ static void Run( intf_thread_t *p_this ) i_song, p_sys->p_first_queue->p_queue[i_song]->psz_a, i_song, p_sys->p_first_queue->p_queue[i_song]->psz_t, i_song, p_sys->p_first_queue->p_queue[i_song]->psz_b, - i_song, + i_song, p_sys->p_first_queue->p_queue[i_song]->psz_m, i_song, p_sys->p_first_queue->p_queue[i_song]->i_l, i_song, p_sys->p_first_queue->p_queue[i_song]->psz_i ); @@ -711,6 +710,9 @@ static int AddToQueue ( intf_thread_t *p_this ) p_queue->p_queue[i_songs_nb]->psz_b = strdup( p_sys->p_current_song->psz_b ); + p_queue->p_queue[i_songs_nb]->psz_m = + strdup( p_sys->p_current_song->psz_m ); + p_queue->p_queue[i_songs_nb]->psz_i = strdup( p_sys->p_current_song->psz_i ); @@ -1019,6 +1021,7 @@ static int ReadLocalMetaData( intf_thread_t *p_this, input_thread_t *p_input ) char *psz_title = NULL; char *psz_artist = NULL; char *psz_album = NULL; + char *psz_trackid = NULL; int i_length = -1; vlc_bool_t b_waiting; int i_status; @@ -1077,6 +1080,19 @@ static int ReadLocalMetaData( intf_thread_t *p_this, input_thread_t *p_input ) } } + if ( p_input->input.p_item->p_meta->psz_trackid ) + { + psz_trackid = strdup( p_input->input.p_item->p_meta->psz_trackid ); + if ( !psz_trackid ) + { + goto error; + } + } + else + { + psz_trackid = calloc( 1, sizeof( char ) ); + } + if ( p_input->input.p_item->p_meta->psz_album ) { psz_album = encode_URI_component( @@ -1100,6 +1116,7 @@ static int ReadLocalMetaData( intf_thread_t *p_this, input_thread_t *p_input ) p_sys->p_current_song->psz_a = strdup( psz_artist ); p_sys->p_current_song->psz_t = strdup( psz_title ); p_sys->p_current_song->psz_b = strdup( psz_album ); + p_sys->p_current_song->psz_m = strdup( psz_trackid ); p_sys->p_current_song->i_l = i_length; p_sys->b_queued = VLC_FALSE; p_sys->b_metadata_read = VLC_TRUE; @@ -1111,6 +1128,7 @@ static int ReadLocalMetaData( intf_thread_t *p_this, input_thread_t *p_input ) free( psz_title ); free( psz_artist ); free( psz_album ); + free( psz_trackid ); return VLC_SUCCESS; } @@ -1136,5 +1154,6 @@ error: free( psz_artist ); free( psz_album ); free( psz_title ); + free( psz_trackid ); return VLC_ENOMEM; }