Changeset 7ad20f39651e9afd5868f720d2d73565dbdbfe8a

Show
Ignore:
Timestamp:
08/20/07 03:27:38 (1 year ago)
Author:
Rafaël Carré <funman@videolan.org>
git-committer:
Rafaël Carré <funman@videolan.org> 1187573258 +0000
git-parent:

[4b359de0582f1f78f63dbeadf5a8c649d29696b7]

git-author:
Rafaël Carré <funman@videolan.org> 1187573258 +0000
Message:

Reads more metadata from ID3v2 tags

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/meta_engine/taglib.cpp

    r9de81b0 r7ad20f3  
    4242#include <vorbisproperties.h> 
    4343#include <uniquefileidentifierframe.h> 
    44  
    45 #if 0 //for artist and album id 
    4644#include <textidentificationframe.h> 
    47 #endif 
     45//#include <relativevolumeframe.h> /* parse the tags without taglib helpers? */ 
    4846 
    4947static int  ReadMeta    ( vlc_object_t * ); 
     
    175173 
    176174#define SET( foo, bar ) vlc_meta_Set##foo( p_meta, tag->bar ().toCString(true)) 
     175#define SETINT( foo, bar ) { \ 
     176            char psz_tmp[10]; \ 
     177            snprintf( (char*)psz_tmp, 10, "%d", tag->bar() ); \ 
     178            vlc_meta_Set##foo( p_meta, (char*)psz_tmp ); \ 
     179        } 
     180 
    177181            SET( Title, title ); 
    178182            SET( Artist, artist ); 
    179183            SET( Album, album ); 
    180 //            SET( Comment, comment ); 
     184            SET( Description, comment ); 
    181185            SET( Genre, genre ); 
    182 //            SET( Year, year ); Gra, this is an int, need to convert 
    183 //            SET( Tracknum , track ); Same 
     186            SETINT( Date, year ); 
     187            SETINT( Tracknum , track ); 
    184188#undef SET 
     189#undef SETINT 
    185190 
    186191            if( TagLib::MPEG::File *p_mpeg = 
     
    212217                        } 
    213218                    } 
    214                     /* musicbrainz artist and album id: not useful (yet?) */ 
    215 #if 0 
     219 
    216220                    list = tag->frameListMap()["TXXX"]; 
    217221                    TagLib::ID3v2::UserTextIdentificationFrame* p_txxx; 
     
    221225                        p_txxx = dynamic_cast<TagLib::ID3v2::UserTextIdentificationFrame*>(*iter); 
    222226                        const char *psz_desc= p_txxx->description().toCString(); 
     227#if 0 /* musicbrainz artist and album id: not useful (yet?) */ 
    223228                        if( !strncmp( psz_desc, "MusicBrainz Artist Id", 21 ) ) 
    224229                            vlc_meta_SetArtistID( p_meta, 
     
    227232                            vlc_meta_SetAlbumID( p_meta, 
    228233                                    p_txxx->fieldList().toString().toCString()); 
    229                     } 
    230 #endif 
     234#endif 
     235                        vlc_meta_AddExtra( p_meta, psz_desc,  
     236                                    p_txxx->fieldList().toString().toCString()); 
     237                    } 
     238#if 0 
     239                    list = tag->frameListMap()["RVA2"]; 
     240                    TagLib::ID3v2::RelativeVolumeFrame* p_rva2; 
     241                    for( TagLib::ID3v2::FrameList::Iterator iter = list.begin(); 
     242                            iter != list.end(); iter++ ) 
     243                    { 
     244                        p_rva2 = dynamic_cast<TagLib::ID3v2::RelativeVolumeFrame*>(*iter); 
     245                        /* TODO: process rva2 frames */ 
     246                    } 
     247#endif 
     248                    list = tag->frameList(); 
     249                    TagLib::ID3v2::Frame* p_t; 
     250                    char psz_tag[4]; 
     251                    for( TagLib::ID3v2::FrameList::Iterator iter = list.begin(); 
     252                            iter != list.end(); iter++ ) 
     253                    { 
     254                        p_t = dynamic_cast<TagLib::ID3v2::Frame*> (*iter); 
     255                        memcpy( psz_tag, p_t->frameID().data(), 4); 
     256 
     257#define SET( foo, bar ) if( !strncmp( psz_tag, foo, 4 ) ) \ 
     258    vlc_meta_Set##bar( p_meta, p_t->toString().toCString(true)) 
     259                        SET( "TPUB", Publisher ); 
     260                        SET( "TCOP", Copyright ); 
     261                        SET( "TENC", EncodedBy ); 
     262                        SET( "TLAN", Language ); 
     263                        //SET( "POPM", Rating ); 
     264                        //if( !strncmp( psz_tag, "RVA2", 4 ) ) 
     265                            /* TODO */ 
     266#undef SET 
     267                    } 
    231268                } 
    232269            }