]> git.sesse.net Git - vlc/blob - modules/meta_engine/taglib.cpp
taglib: cleaning.
[vlc] / modules / meta_engine / taglib.cpp
1 /*****************************************************************************
2  * taglib.cpp: Taglib tag parser/writer
3  *****************************************************************************
4  * Copyright (C) 2003-2008 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Clément Stenac <zorglub@videolan.org>
8  *          Rafaël Carré <funman@videolanorg>
9  *          Rémi Duraffort <ivoire@videolan.org>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24  *****************************************************************************/
25
26 #ifdef HAVE_CONFIG_H
27 # include "config.h"
28 #endif
29
30 #include <vlc_common.h>
31 #include <vlc_plugin.h>
32 #include <vlc_playlist.h>
33 #include <vlc_meta.h>
34 #include <vlc_demux.h>
35 #include <vlc_strings.h>
36 #include <vlc_charset.h>
37
38 #ifdef WIN32
39 # include <io.h>
40 #else
41 # include <unistd.h>
42 #endif
43
44
45 // Taglib headers
46 #include <fileref.h>
47 #include <tag.h>
48 #include <tbytevector.h>
49
50 #include <apetag.h>
51 #include <id3v2tag.h>
52 #include <xiphcomment.h>
53
54 #include <flacfile.h>
55 #include <mpcfile.h>
56 #include <mpegfile.h>
57 #include <oggfile.h>
58 #include <oggflacfile.h>
59 #include <speexfile.h>
60 #include <trueaudiofile.h>
61 #include <vorbisfile.h>
62 #include <wavpackfile.h>
63
64 #include <attachedpictureframe.h>
65 #include <textidentificationframe.h>
66 #include <uniquefileidentifierframe.h>
67
68
69 // Local functions
70 static int ReadMeta    ( vlc_object_t * );
71 static int DownloadArt ( vlc_object_t * );
72 static int WriteMeta   ( vlc_object_t * );
73
74 vlc_module_begin ()
75     set_capability( "meta reader", 1000 )
76     set_callbacks( ReadMeta, NULL )
77     add_submodule ()
78         set_capability( "art downloader", 50 )
79         set_callbacks( DownloadArt, NULL )
80     add_submodule ()
81         set_capability( "meta writer", 50 )
82         set_callbacks( WriteMeta, NULL )
83 vlc_module_end ()
84
85 using namespace TagLib;
86
87
88 /* Try detecting embedded art */
89 static void DetectImage( FileRef f, demux_t *p_demux )
90 {
91     demux_meta_t        *p_demux_meta   = (demux_meta_t *)p_demux->p_private;
92     vlc_meta_t          *p_meta         = p_demux_meta->p_meta;
93     int                 i_score         = -1;
94
95     /* Preferred type of image
96      * The 21 types are defined in id3v2 standard:
97      * http://www.id3.org/id3v2.4.0-frames */
98     static const int pi_cover_score[] = {
99         0,  /* Other */
100         5,  /* 32x32 PNG image that should be used as the file icon */
101         4,  /* File icon of a different size or format. */
102         20, /* Front cover image of the album. */
103         19, /* Back cover image of the album. */
104         13, /* Inside leaflet page of the album. */
105         18, /* Image from the album itself. */
106         17, /* Picture of the lead artist or soloist. */
107         16, /* Picture of the artist or performer. */
108         14, /* Picture of the conductor. */
109         15, /* Picture of the band or orchestra. */
110         9,  /* Picture of the composer. */
111         8,  /* Picture of the lyricist or text writer. */
112         7,  /* Picture of the recording location or studio. */
113         10, /* Picture of the artists during recording. */
114         11, /* Picture of the artists during performance. */
115         6,  /* Picture from a movie or video related to the track. */
116         1,  /* Picture of a large, coloured fish. */
117         12, /* Illustration related to the track. */
118         3,  /* Logo of the band or performer. */
119         2   /* Logo of the publisher (record company). */
120     };
121
122     if( MPEG::File *mpeg = dynamic_cast<MPEG::File *>(f.file() ) )
123     {
124         ID3v2::Tag  *p_tag = mpeg->ID3v2Tag();
125         if( !p_tag )
126             return;
127         ID3v2::FrameList list = p_tag->frameListMap()[ "APIC" ];
128         if( list.isEmpty() )
129             return;
130         ID3v2::AttachedPictureFrame *p_apic;
131
132         TAB_INIT( p_demux_meta->i_attachments, p_demux_meta->attachments );
133         for( ID3v2::FrameList::Iterator iter = list.begin();
134                 iter != list.end(); iter++ )
135         {
136             p_apic = dynamic_cast<ID3v2::AttachedPictureFrame*>(*iter);
137             input_attachment_t *p_attachment;
138
139             const char *psz_name, *psz_mime, *psz_description;
140             ByteVector p_data_taglib; const char *p_data; int i_data;
141
142             psz_mime = p_apic->mimeType().toCString(true);
143             psz_description = psz_name = p_apic->description().toCString(true);
144
145             /* some old iTunes version not only sets incorrectly the mime type
146              * or the description of the image,
147              * but also embeds incorrectly the image.
148              * Recent versions seem to behave correctly */
149             if( !strncmp( psz_mime, "PNG", 3 ) ||
150                 !strncmp( psz_name, "\xC2\x89PNG", 5 ) )
151             {
152                 msg_Warn( p_demux,
153                     "%s: Invalid picture embedded by broken iTunes version, "
154                     "you really shouldn't use this crappy software.",
155                     (const char *)f.file()->name() );
156                 break;
157             }
158
159             p_data_taglib = p_apic->picture();
160             p_data = p_data_taglib.data();
161             i_data = p_data_taglib.size();
162
163             msg_Dbg( p_demux, "Found embedded art: %s (%s) is %i bytes",
164                     psz_name, psz_mime, i_data );
165
166             p_attachment = vlc_input_attachment_New( psz_name, psz_mime,
167                     psz_description, p_data, i_data );
168             TAB_APPEND_CAST( (input_attachment_t**),
169                     p_demux_meta->i_attachments, p_demux_meta->attachments,
170                     p_attachment );
171
172             if( pi_cover_score[p_apic->type()] > i_score )
173             {
174                 i_score = pi_cover_score[p_apic->type()];
175                 char *psz_url;
176                 if( asprintf( &psz_url, "attachment://%s",
177                         p_attachment->psz_name ) == -1 )
178                     return;
179                 vlc_meta_SetArtURL( p_meta, psz_url );
180                 free( psz_url );
181             }
182         }
183     }
184     else
185     if( Ogg::Vorbis::File *oggv = dynamic_cast<Ogg::Vorbis::File *>(f.file() ) )
186     {
187         Ogg::XiphComment *p_tag = oggv->tag();
188         if( !p_tag )
189             return;
190
191         StringList mime_list = p_tag->fieldListMap()[ "COVERARTMIME" ];
192         StringList art_list = p_tag->fieldListMap()[ "COVERART" ];
193
194         /* we support only one cover in ogg/vorbis */
195         if( mime_list.size() != 1 || art_list.size() != 1 )
196             return;
197
198         input_attachment_t *p_attachment;
199
200         const char *psz_name, *psz_mime, *psz_description;
201         uint8_t *p_data;
202         int i_data;
203
204         psz_name = "cover";
205         psz_mime = mime_list[0].toCString(true);
206         psz_description = "cover";
207
208         i_data = vlc_b64_decode_binary( &p_data, art_list[0].toCString(true) );
209
210         msg_Dbg( p_demux, "Found embedded art: %s (%s) is %i bytes",
211                     psz_name, psz_mime, i_data );
212
213         TAB_INIT( p_demux_meta->i_attachments, p_demux_meta->attachments );
214         p_attachment = vlc_input_attachment_New( psz_name, psz_mime,
215                 psz_description, p_data, i_data );
216         free( p_data );
217
218         TAB_APPEND_CAST( (input_attachment_t**),
219                 p_demux_meta->i_attachments, p_demux_meta->attachments,
220                 p_attachment );
221
222         vlc_meta_SetArtURL( p_meta, "attachment://cover" );
223     }
224
225 #if 0
226     //flac embedded images are extracted in the flac demuxer
227     else if( FLAC::File *flac =
228              dynamic_cast<FLAC::File *>(f.file() ) )
229     {
230         p_tag = flac->ID3v2Tag();
231         if( p_tag )
232             return;
233         ID3v2::FrameList l = p_tag->frameListMap()[ "APIC" ];
234         if( l.isEmpty() )
235             return;
236             vlc_meta_SetArtURL( p_meta, "APIC" );
237     }
238 #endif
239 #if 0
240 /* TagLib doesn't support MP4 file yet */
241     else if( MP4::File *mp4 =
242                dynamic_cast<MP4::File *>( f.file() ) )
243     {
244         MP4::Tag *mp4tag =
245                 dynamic_cast<MP4::Tag *>( mp4->tag() );
246         if( mp4tag && mp4tag->cover().size() )
247             vlc_meta_SetArtURL( p_meta, "MP4C" );
248     }
249 #endif
250 }
251
252
253
254 /**
255  * Read meta informations from APE tags
256  * @param tag: the APE tag
257  * @param p_meta: the meta
258  * @return VLC_SUCCESS if everything goes ok
259  */
260 static int ReadMetaFromAPE( APE::Tag* tag, vlc_meta_t* p_meta )
261 {
262     APE::Item item;
263 #define SET( keyName, metaName ) \
264     item = tag->itemListMap()[keyName]; \
265     vlc_meta_Set##metaName( p_meta, item.toString().toCString( true ) );\
266
267     SET( "COPYRIGHT", Copyright );
268     SET( "LANGUAGE", Language );
269     SET( "PUBLISHER", Publisher );
270
271 #undef SET
272     return VLC_SUCCESS;
273 }
274
275
276
277 /**
278  * Read meta information from id3v2 tags
279  * @param tag: the id3v2 tag
280  * @param p_meta: the meta
281  * @return VLC_SUCCESS if everything goes ok
282  */
283 static int ReadMetaFromId2v2( ID3v2::Tag* tag, vlc_meta_t* p_meta )
284 {
285     // Get the unique file identifier
286     ID3v2::FrameList list = tag->frameListMap()["UFID"];
287     ID3v2::FrameList::Iterator iter;
288     for( iter = list.begin(); iter != list.end(); iter++ )
289     {
290         ID3v2::UniqueFileIdentifierFrame* p_ufid =
291                 dynamic_cast<ID3v2::UniqueFileIdentifierFrame*>(*iter);
292         const char *owner = p_ufid->owner().toCString();
293         if (!strcmp( owner, "http://musicbrainz.org" ))
294         {
295             /* ID3v2 UFID contains up to 64 bytes binary data
296              * but in our case it will be a '\0'
297              * terminated string */
298             char psz_ufid[64];
299             int j = 0;
300             int max_size = p_ufid->identifier().size() < 63 ?
301                            p_ufid->identifier().size() : 63;
302             while( j < max_size )
303                 psz_ufid[j] = p_ufid->identifier()[j++];
304             psz_ufid[j] = '\0';
305             vlc_meta_SetTrackID( p_meta, psz_ufid );
306         }
307     }
308
309     // Get the use text
310     list = tag->frameListMap()["TXXX"];
311     for( iter = list.begin(); iter != list.end(); iter++ )
312     {
313         ID3v2::UserTextIdentificationFrame* p_txxx =
314                 dynamic_cast<ID3v2::UserTextIdentificationFrame*>(*iter);
315         vlc_meta_AddExtra( p_meta, p_txxx->description().toCString( true ),
316                            p_txxx->fieldList().toString().toCString( true ) );
317     }
318
319     // Get some more informations
320 #define SET( tagName, metaName )                                               \
321     list = tag->frameListMap()[tagName];                                       \
322     if( !list.isEmpty() )                                                      \
323         vlc_meta_Set##metaName( p_meta,                                        \
324                                 (*list.begin())->toString().toCString( true ) );
325
326     SET( "TCOP", Copyright );
327     SET( "TENC", EncodedBy );
328     SET( "TLAN", Language );
329     SET( "TPUB", Publisher );
330
331 #undef SET
332     return VLC_SUCCESS;
333 }
334
335
336
337 /**
338  * Read the meta informations from XiphComments
339  * @param tag: the Xiph Comment
340  * @param p_meta: the meta
341  * @return VLC_SUCCESS if everything goes ok
342  */
343 static int ReadMetaFromXiph( Ogg::XiphComment* tag, vlc_meta_t* p_meta )
344 {
345 #define SET( keyName, metaName )                                               \
346     StringList list = tag->fieldListMap()[keyName];                            \
347     if( !list.isEmpty() )                                                      \
348         vlc_meta_Set##metaName( p_meta, (*list.begin()).toCString( true ) );
349
350     SET( "COPYRIGHT", Copyright );
351 #undef SET
352     return VLC_SUCCESS;
353 }
354
355
356
357 /**
358  * Get the tags from the file using TagLib
359  * @param p_this: the demux object
360  * @return VLC_SUCCESS if the operation success
361  */
362 static int ReadMeta( vlc_object_t* p_this)
363 {
364     demux_t*        p_demux = (demux_t*)p_this;
365     demux_meta_t*   p_demux_meta = (demux_meta_t*)p_demux->p_private;
366     vlc_meta_t*     p_meta;
367     TagLib::FileRef f;
368
369     p_demux_meta->p_meta = NULL;
370     const char* local_name = ToLocale( p_demux->psz_path );
371     if( !local_name )
372         return VLC_EGENERIC;
373     f = FileRef( local_name );
374     LocaleFree( local_name );
375
376     if( f.isNull() )
377         return VLC_EGENERIC;
378     if( !f.tag() || f.tag()->isEmpty() )
379         return VLC_EGENERIC;
380
381     p_demux_meta->p_meta = p_meta = vlc_meta_New();
382     if( !p_meta )
383         return VLC_ENOMEM;
384
385
386     // Read the tags from the file
387     Tag* p_tag = f.tag();
388
389 #define SET( tag, meta )                                                       \
390     if( !p_tag->tag().isNull() && !p_tag->tag().isEmpty() )                    \
391         vlc_meta_Set##meta( p_meta, p_tag->tag().toCString(true) )
392 #define SETINT( tag, meta )                                                    \
393     if( p_tag->tag() )                                                         \
394     {                                                                          \
395         char psz_tmp[10];                                                      \
396         snprintf( psz_tmp, 10, "%d", p_tag->tag() );                           \
397         vlc_meta_Set##meta( p_meta, psz_tmp );                                 \
398     }
399
400     SET( title, Title );
401     SET( artist, Artist );
402     SET( album, Album );
403     SET( comment, Description );
404     SET( genre, Genre );
405     SETINT( year, Date );
406     SETINT( track, Tracknum );
407
408 #undef SETINT
409 #undef SET
410
411
412     // Try now to read special tags
413     if( FLAC::File* flac = dynamic_cast<FLAC::File*>(f.file()) )
414     {
415         if( flac->ID3v2Tag() )
416             ReadMetaFromId2v2( flac->ID3v2Tag(), p_meta );
417         else if( flac->xiphComment() )
418             ReadMetaFromXiph( flac->xiphComment(), p_meta );
419     }
420     else if( MPC::File* mpc = dynamic_cast<MPC::File*>(f.file()) )
421     {
422         if( mpc->APETag() )
423             ReadMetaFromAPE( mpc->APETag(), p_meta );
424     }
425     else if( MPEG::File* mpeg = dynamic_cast<MPEG::File*>(f.file()) )
426     {
427         if( mpeg->ID3v2Tag() )
428             ReadMetaFromId2v2( mpeg->ID3v2Tag(), p_meta );
429         else if( mpeg->APETag() )
430             ReadMetaFromAPE( mpeg->APETag(), p_meta );
431     }
432     else if( Ogg::File* ogg = dynamic_cast<Ogg::File*>(f.file()) )
433     {
434         if( Ogg::FLAC::File* ogg_flac = dynamic_cast<Ogg::FLAC::File*>(f.file()))
435             ReadMetaFromXiph( ogg_flac->tag(), p_meta );
436         else if( Ogg::Speex::File* ogg_speex = dynamic_cast<Ogg::Speex::File*>(f.file()) )
437             ReadMetaFromXiph( ogg_speex->tag(), p_meta );
438         else if( Ogg::Vorbis::File* ogg_vorbis = dynamic_cast<Ogg::Vorbis::File*>(f.file()) )
439             ReadMetaFromXiph( ogg_vorbis->tag(), p_meta );
440     }
441     else if( TrueAudio::File* trueaudio = dynamic_cast<TrueAudio::File*>(f.file()) )
442     {
443         if( trueaudio->ID3v2Tag() )
444             ReadMetaFromId2v2( trueaudio->ID3v2Tag(), p_meta );
445     }
446     else if( WavPack::File* wavpack = dynamic_cast<WavPack::File*>(f.file()) )
447     {
448         if( wavpack->APETag() )
449             ReadMetaFromAPE( wavpack->APETag(), p_meta );
450     }
451
452     // Try now to find a image
453     DetectImage( f, p_demux );
454
455     return VLC_SUCCESS;
456 }
457
458
459
460 /**
461  * Write meta informations to APE tags
462  * @param tag: the APE tag
463  * @param p_item: the input item
464  * @return VLC_SUCCESS if everything goes ok
465  */
466 static int WriteMetaToAPE( APE::Tag* tag, input_item_t* p_item )
467 {
468     char* psz_meta;
469 #define WRITE( metaName, keyName )                      \
470     psz_meta = input_item_Get##metaName( p_item );      \
471     if( psz_meta )                                      \
472     {                                                   \
473         String key( keyName, String::UTF8 );            \
474         String value( psz_meta, String::UTF8 );         \
475         tag->addValue( key, value, true );              \
476     }                                                   \
477     free( psz_meta );
478
479     WRITE( Copyright, "COPYRIGHT" );
480     WRITE( Language, "LANGUAGE" );
481     WRITE( Publisher, "PUBLISHER" );
482
483 #undef WRITE
484
485     return VLC_SUCCESS;
486 }
487
488
489
490 /**
491  * Write meta information to id3v2 tags
492  * @param tag: the id3v2 tag
493  * @param p_input: the input item
494  * @return VLC_SUCCESS if everything goes ok
495  */
496 static int WriteMetaToId2v2( ID3v2::Tag* tag, input_item_t* p_item )
497 {
498     char* psz_meta;
499 #define WRITE( metaName, tagName )                                            \
500     psz_meta = input_item_Get##metaName( p_item );                            \
501     if( psz_meta )                                                            \
502     {                                                                         \
503         ByteVector p_byte( tagName, 4 );                                      \
504         tag->removeFrames( p_byte );                                         \
505         ID3v2::TextIdentificationFrame* p_frame =                             \
506             new ID3v2::TextIdentificationFrame( p_byte, String::UTF8 );       \
507         p_frame->setText( psz_meta );                                         \
508         tag->addFrame( p_frame );                                             \
509     }                                                                         \
510     free( psz_meta );
511
512     WRITE( Copyright, "TCOP" );
513     WRITE( EncodedBy, "TENC" );
514     WRITE( Language,  "TLAN" );
515     WRITE( Publisher, "TPUB" );
516
517 #undef WRITE
518     return VLC_SUCCESS;
519 }
520
521
522
523 /**
524  * Write the meta informations to XiphComments
525  * @param tag: the Xiph Comment
526  * @param p_input: the input item
527  * @return VLC_SUCCESS if everything goes ok
528  */
529 static int WriteMetaToXiph( Ogg::XiphComment* tag, input_item_t* p_item )
530 {
531     char* psz_meta;
532 #define WRITE( metaName, keyName )                      \
533     psz_meta = input_item_Get##metaName( p_item );      \
534     if( psz_meta )                                      \
535     {                                                   \
536         String key( keyName, String::UTF8 );            \
537         String value( psz_meta, String::UTF8 );         \
538         tag->addField( key, value, true );              \
539     }                                                   \
540     free( psz_meta );
541
542     WRITE( Copyright, "COPYRIGHT" );
543
544 #undef WRITE
545     return VLC_SUCCESS;
546 }
547
548
549
550 /**
551  * Set the tags to the file using TagLib
552  * @param p_this: the demux object
553  * @return VLC_SUCCESS if the operation success
554  */
555
556 static int WriteMeta( vlc_object_t *p_this )
557 {
558     playlist_t *p_playlist = (playlist_t *)p_this;
559     meta_export_t *p_export = (meta_export_t *)p_playlist->p_private;
560     input_item_t *p_item = p_export->p_item;
561
562     if( !p_item )
563     {
564         msg_Err( p_this, "Can't save meta data of an empty input" );
565         return VLC_EGENERIC;
566     }
567
568     FileRef f( p_export->psz_file );
569     if( f.isNull() || !f.tag() || f.file()->readOnly() )
570     {
571         msg_Err( p_this, "File %s can't be opened for tag writing\n",
572             p_export->psz_file );
573         return VLC_EGENERIC;
574     }
575
576     msg_Dbg( p_this, "Writing metadata for %s", p_export->psz_file );
577
578     Tag *p_tag = f.tag();
579
580     char *psz_meta;
581
582 #define SET( a, b )                                         \
583     if( b )                                                 \
584     {                                                       \
585         String* psz_tmp = new String( b, String::UTF8 );    \
586         p_tag->set##a( *psz_tmp );                          \
587         delete psz_tmp;                                     \
588     }
589
590     // Saving all common fields
591     // If the title is empty, use the name
592     psz_meta = input_item_GetTitle( p_item );
593     if( !psz_meta ) psz_meta = input_item_GetName( p_item );
594     SET( Title, psz_meta );
595     free( psz_meta );
596
597     psz_meta = input_item_GetArtist( p_item );
598     SET( Artist, psz_meta );
599     free( psz_meta );
600
601     psz_meta = input_item_GetAlbum( p_item );
602     SET( Album, psz_meta );
603     free( psz_meta );
604
605     psz_meta = input_item_GetDescription( p_item );
606     SET( Comment, psz_meta );
607     free( psz_meta );
608
609     psz_meta = input_item_GetGenre( p_item );
610     SET( Genre, psz_meta );
611     free( psz_meta );
612
613 #undef SET
614
615     psz_meta = input_item_GetDate( p_item );
616     if( psz_meta ) p_tag->setYear( atoi( psz_meta ) );
617     free( psz_meta );
618
619     psz_meta = input_item_GetTrackNum( p_item );
620     if( psz_meta ) p_tag->setTrack( atoi( psz_meta ) );
621     free( psz_meta );
622
623
624     // Try now to write special tags
625     if( FLAC::File* flac = dynamic_cast<FLAC::File*>(f.file()) )
626     {
627         if( flac->ID3v2Tag() )
628             WriteMetaToId2v2( flac->ID3v2Tag(), p_item );
629         else if( flac->xiphComment() )
630             WriteMetaToXiph( flac->xiphComment(), p_item );
631     }
632     else if( MPC::File* mpc = dynamic_cast<MPC::File*>(f.file()) )
633     {
634         if( mpc->APETag() )
635             WriteMetaToAPE( mpc->APETag(), p_item );
636     }
637     else if( MPEG::File* mpeg = dynamic_cast<MPEG::File*>(f.file()) )
638     {
639         if( mpeg->ID3v2Tag() )
640             WriteMetaToId2v2( mpeg->ID3v2Tag(), p_item );
641         else if( mpeg->APETag() )
642             WriteMetaToAPE( mpeg->APETag(), p_item );
643     }
644     else if( Ogg::File* ogg = dynamic_cast<Ogg::File*>(f.file()) )
645     {
646         if( Ogg::FLAC::File* ogg_flac = dynamic_cast<Ogg::FLAC::File*>(f.file()))
647             WriteMetaToXiph( ogg_flac->tag(), p_item );
648         else if( Ogg::Speex::File* ogg_speex = dynamic_cast<Ogg::Speex::File*>(f.file()) )
649             WriteMetaToXiph( ogg_speex->tag(), p_item );
650         else if( Ogg::Vorbis::File* ogg_vorbis = dynamic_cast<Ogg::Vorbis::File*>(f.file()) )
651             WriteMetaToXiph( ogg_vorbis->tag(), p_item );
652     }
653     else if( TrueAudio::File* trueaudio = dynamic_cast<TrueAudio::File*>(f.file()) )
654     {
655         if( trueaudio->ID3v2Tag() )
656             WriteMetaToId2v2( trueaudio->ID3v2Tag(), p_item );
657     }
658     else if( WavPack::File* wavpack = dynamic_cast<WavPack::File*>(f.file()) )
659     {
660         if( wavpack->APETag() )
661             WriteMetaToAPE( wavpack->APETag(), p_item );
662     }
663
664     // Save the meta data
665     f.save();
666
667     return VLC_SUCCESS;
668 }
669
670
671
672 static int DownloadArt( vlc_object_t *p_this )
673 {
674     /* We need to be passed the file name
675      * Fetch the thing from the file, save it to the cache folder
676      */
677     return VLC_EGENERIC;
678 }
679