Ticket #5820: musicbrainz_compilation.patch

File musicbrainz_compilation.patch, 5.0 KB (added by drdaz7 at gmail dot com, 16 years ago)
  • mythmusic/metaiotaglib.cpp

     
    3131        return false;
    3232
    3333    File *taglib = new TagLib::MPEG::File(mdata->Filename().local8Bit());
    34 
    3534    Tag *tag = taglib->tag();
    3635
    3736    if (!tag)
     
    4847    UserTextIdentificationFrame *musicbrainz = NULL;
    4948    musicbrainz = find(taglib->ID3v2Tag(), "MusicBrainz Album Artist Id");
    5049
    51     // Compilation Artist (TPE4)
     50    // Compilation Artist (TPE2)
    5251    TextIdentificationFrame *tpeframe = NULL;
    53     TagLib::ID3v2::FrameList tpelist = taglib->ID3v2Tag()->frameListMap()["TPE4"];
     52    TagLib::ID3v2::FrameList tpelist = taglib->ID3v2Tag()->frameListMap()["TPE2"];
    5453    if (!tpelist.isEmpty())
    5554        tpeframe = (TextIdentificationFrame *)tpelist.front();
    5655
     
    6968        if (!mdata->CompilationArtist().isEmpty())
    7069        {
    7170            if (!tpeframe) {
    72                 tpeframe = new TextIdentificationFrame(TagLib::ByteVector("TPE4"), TagLib::String::UTF8);
     71                tpeframe = new TextIdentificationFrame(TagLib::ByteVector("TPE2"), TagLib::String::UTF8);
    7372                taglib->ID3v2Tag()->addFrame(tpeframe);
    7473            }
    7574
     
    155154    // ID3V2 Only Tags
    156155    if (taglib->ID3v2Tag())
    157156    {
    158         // Compilation Artist (TPE4)
    159         if(!taglib->ID3v2Tag()->frameListMap()["TPE4"].isEmpty())
     157        // Compilation Artist (TPE2)
     158        if(!taglib->ID3v2Tag()->frameListMap()["TPE2"].isEmpty())
    160159        {
    161160            compilation_artist = TStringToQString(
    162             taglib->ID3v2Tag()->frameListMap()["TPE4"].front()->toString())
     161            taglib->ID3v2Tag()->frameListMap()["TPE2"].front()->toString())
    163162            .stripWhiteSpace();
    164163        }
    165164
    166165        // Look for MusicBrainz Album+Artist ID in TXXX Frame
    167166        UserTextIdentificationFrame *musicbrainz = find(taglib->ID3v2Tag(),
    168167                "MusicBrainz Album Artist Id");
    169 
     168        UserTextIdentificationFrame *musicbrainzalbumtype = find(taglib->ID3v2Tag(),
     169                "MusicBrainz Album Type");
     170       
    170171        if (musicbrainz)
    171172        {
    172173            // If the MusicBrainz ID is the special "Various Artists" ID
     
    176177                == TStringToQString(musicbrainz->fieldList().front()));
    177178        }
    178179
     180        if (!compilation && musicbrainzalbumtype)
     181        {
     182            // If the MusicBrainz Album Type is 'compilation', then compilation is TRUE
     183            QString albumtype;
     184            if (! musicbrainzalbumtype->fieldList().isEmpty())
     185                albumtype = TStringToQString(musicbrainzalbumtype->fieldList().front());
     186                compilation = (albumtype.contains(QString("compilation")) || albumtype.contains(QString("soundtrack")));
     187        }
     188
    179189        // Length
    180190        if(!taglib->ID3v2Tag()->frameListMap()["TLEN"].isEmpty())
    181191            length = taglib->ID3v2Tag()->frameListMap()["TLEN"].front()->toString().toInt();
  • mythmusic/metaiooggvorbiscomment.cpp

     
    1313// MythTV headers
    1414#include <mythtv/compat.h>
    1515#include <mythtv/util.h>
     16#include <mythtv/mythcontext.h>
    1617
    1718// MythMusic headers
    1819#include "metaiooggvorbiscomment.h"
     
    306307            genre = getComment(comment, MYTH_VORBISCOMMENT_GENRE);
    307308            tracknum = atoi(getComment(comment, MYTH_VORBISCOMMENT_TRACK).ascii());
    308309            year = atoi(getComment(comment, MYTH_VORBISCOMMENT_DATE).ascii());
     310
     311            QString album_artist_id = getComment(comment, MYTH_VORBISCOMMENT_MUSICBRAINZ_ALBUMARTISTID);
     312            QString album_type = getComment(comment, MYTH_VORBISCOMMENT_MUSICBRAINZ_ALBUMTYPE);
     313            compilation = (MYTH_MUSICBRAINZ_ALBUMARTIST_UUID == album_artist_id ||
     314                album_type.contains(QString("compilation")) || album_type.contains(QString("soundtrack")));
     315
     316
    309317           
    310             QString tmp = getComment(comment, MYTH_VORBISCOMMENT_MUSICBRAINZ_ALBUMARTISTID);
    311             compilation = (MYTH_MUSICBRAINZ_ALBUMARTIST_UUID == tmp);
    312 
    313318            length = getTrackLength(&vf);
    314319
    315320            // Do not call fclose as ov_clear takes care of things for us.
  • mythmusic/metaiovorbiscomment.h

     
    99#define MYTH_VORBISCOMMENT_GENRE                     "GENRE"
    1010#define MYTH_VORBISCOMMENT_DATE                      "DATE"
    1111#define MYTH_VORBISCOMMENT_TRACK                     "TRACKNUMBER"
    12 #define MYTH_VORBISCOMMENT_COMPILATIONARTIST         "COMPILATION_ARTIST"
     12#define MYTH_VORBISCOMMENT_COMPILATIONARTIST         "ALBUMARTIST"
    1313#define MYTH_VORBISCOMMENT_MUSICBRAINZ_ALBUMARTISTID "MUSICBRAINZ_ALBUMARTISTID"
     14#define MYTH_VORBISCOMMENT_MUSICBRAINZ_ALBUMTYPE     "RELEASETYPE"
    1415
    1516#endif