Ticket #8725: id3v1_fallback.patch

File id3v1_fallback.patch, 1.2 KB (added by mythtv@…, 14 years ago)

Fallback to ID3v1 tag

  • metaioid3.cpp

     
    134134        delete mpegfile;
    135135        return NULL;
    136136    }
     137
     138    // if there is no ID3v2 tag, try to read the ID3v1 tag and copy it to the ID3v2 tag structure
     139    if (tag->isEmpty())
     140    {
     141        TagLib::ID3v1::Tag *tag_v1 = mpegfile->ID3v1Tag();
     142
     143        if (!tag_v1)
     144        {
     145            delete mpegfile;
     146            return NULL;
     147        }
     148
     149        if (!tag_v1->isEmpty())
     150        {
     151            tag->setTitle(tag_v1->title());
     152            tag->setArtist(tag_v1->artist());
     153            tag->setAlbum(tag_v1->album());
     154            tag->setTrack(tag_v1->track());
     155            tag->setYear(tag_v1->year());
     156            tag->setGenre(tag_v1->genre());
     157        }
     158    }
    137159   
    138160    Metadata *metadata = new Metadata(filename);
    139161   
  • metaioid3.h

     
    66#include "metadata.h"
    77
    88// Taglib
     9#include <id3v1tag.h>
    910#include <id3v2tag.h>
    1011#include <textidentificationframe.h>
    1112#include <attachedpictureframe.h>