mirror of
https://github.com/clangen/musikcube.git
synced 2025-02-06 12:39:54 +00:00
Fixed taglib bug when id3v2 frames exists but are empty and id3v1 should be read.
Track and TrackMeta do not allow empty strings (unnecessary data).
This commit is contained in:
parent
86593f5d1e
commit
27071b015b
@ -104,8 +104,11 @@ bool TagReaderTaglib::ReadTag(musik::core::Track *track){
|
||||
boost::algorithm::to_lower(ext); // Convert to lower case
|
||||
|
||||
if(ext==UTF("mp3"))
|
||||
if(this->GetID3v2Tag(track))
|
||||
if(this->GetID3v2Tag(track)){
|
||||
// Get the generic tag as well, just in case there is only a id3v1 tag.
|
||||
this->GetGenericTag(track);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(ext==UTF("ogg"))
|
||||
if(this->GetOGGTag(track))
|
||||
@ -149,9 +152,13 @@ bool TagReaderTaglib::GetGenericTag(musik::core::Track *track){
|
||||
// COMMENT
|
||||
this->SetTagValue("comment",tag->comment(),track);
|
||||
// TRACK
|
||||
if(tag->track()){
|
||||
this->SetTagValue("track",tag->track(),track);
|
||||
}
|
||||
// TRACK
|
||||
if(tag->year()){
|
||||
this->SetTagValue("year",tag->year(),track);
|
||||
}
|
||||
|
||||
this->SetAudioProperties(oAudioProperties,track);
|
||||
|
||||
@ -184,8 +191,6 @@ bool TagReaderTaglib::GetID3v2Tag(musik::core::Track *track){
|
||||
|
||||
if(!oTagv2->title().isEmpty()){
|
||||
this->SetTagValue("title",oTagv2->title(),track);
|
||||
}else{
|
||||
this->SetTagValue("title",track->GetValue("filename"),track);
|
||||
}
|
||||
this->SetTagValue("album",oTagv2->album(),track);
|
||||
|
||||
|
@ -322,14 +322,20 @@ bool Track::Save(db::Connection &dbConnection,utfstring libraryDirectory,DBINT f
|
||||
DBINT albumId(0);
|
||||
{
|
||||
db::CachedStatement stmt("SELECT id FROM albums WHERE name=?",dbConnection);
|
||||
stmt.BindTextUTF(0,this->GetValue("album"));
|
||||
const utfchar *album=this->GetValue("album");
|
||||
if(album==NULL){
|
||||
album=UTF("");
|
||||
}
|
||||
|
||||
stmt.BindTextUTF(0,album);
|
||||
|
||||
if(stmt.Step()==db::ReturnCode::Row){
|
||||
albumId = stmt.ColumnInt(0);
|
||||
}else{
|
||||
// INSERT a new album
|
||||
db::Statement insertAlbum("INSERT INTO albums (name) VALUES (?)",dbConnection);
|
||||
insertAlbum.BindTextUTF(0,this->GetValue("album"));
|
||||
insertAlbum.BindTextUTF(0,album);
|
||||
|
||||
if(insertAlbum.Step()==db::ReturnCode::Done){
|
||||
albumId = dbConnection.LastInsertedId();
|
||||
}
|
||||
|
@ -121,6 +121,7 @@ TrackMeta::TagMapIteratorPair TrackMeta::GetValues(const char* metakey) const{
|
||||
}
|
||||
|
||||
void TrackMeta::SetValue(const TrackMeta::Key &key,const TrackMeta::Value &value){
|
||||
if(!value.empty()){
|
||||
if(this->library){
|
||||
// Threadsafe
|
||||
boost::mutex::scoped_lock lock(library->libraryMutex);
|
||||
@ -130,6 +131,7 @@ void TrackMeta::SetValue(const TrackMeta::Key &key,const TrackMeta::Value &value
|
||||
|
||||
// Non threadsafe
|
||||
this->tags.insert( TrackMeta::TagMapPair(key,value) );
|
||||
}
|
||||
}
|
||||
|
||||
const TrackMeta::Value& TrackMeta::_GetValue(const TrackMeta::Key &key) const{
|
||||
|
Loading…
x
Reference in New Issue
Block a user