TagReaderTagLib: Handle multiple mbids for MP4

Fixes #1531
This commit is contained in:
Jonas Kvinge 2024-09-02 23:48:25 +02:00
parent c77c7a247a
commit cc6e5a6c69
2 changed files with 20 additions and 4 deletions

View File

@ -798,13 +798,13 @@ void TagReaderTagLib::ParseMP4Tags(TagLib::MP4::Tag *tag, QString *disc, QString
} }
if (tag->contains(kMP4_MusicBrainz_AlbumArtistId)) { if (tag->contains(kMP4_MusicBrainz_AlbumArtistId)) {
AssignTagLibStringToStdString(tag->item(kMP4_MusicBrainz_AlbumArtistId).toStringList().toString(), song->mutable_musicbrainz_album_artist_id()); AssignTagLibStringToStdString(TagLibStringListToSlashSeparatedString(tag->item(kMP4_MusicBrainz_AlbumArtistId).toStringList()), song->mutable_musicbrainz_album_artist_id());
} }
if (tag->contains(kMP4_MusicBrainz_ArtistId)) { if (tag->contains(kMP4_MusicBrainz_ArtistId)) {
AssignTagLibStringToStdString(tag->item(kMP4_MusicBrainz_ArtistId).toStringList().toString(), song->mutable_musicbrainz_artist_id()); AssignTagLibStringToStdString(TagLibStringListToSlashSeparatedString(tag->item(kMP4_MusicBrainz_ArtistId).toStringList()), song->mutable_musicbrainz_artist_id());
} }
if (tag->contains(kMP4_MusicBrainz_OriginalArtistId)) { if (tag->contains(kMP4_MusicBrainz_OriginalArtistId)) {
AssignTagLibStringToStdString(tag->item(kMP4_MusicBrainz_OriginalArtistId).toStringList().toString(), song->mutable_musicbrainz_original_artist_id()); AssignTagLibStringToStdString(TagLibStringListToSlashSeparatedString(tag->item(kMP4_MusicBrainz_OriginalArtistId).toStringList()), song->mutable_musicbrainz_original_artist_id());
} }
if (tag->contains(kMP4_MusicBrainz_AlbumId)) { if (tag->contains(kMP4_MusicBrainz_AlbumId)) {
AssignTagLibStringToStdString(tag->item(kMP4_MusicBrainz_AlbumId).toStringList().toString(), song->mutable_musicbrainz_album_id()); AssignTagLibStringToStdString(tag->item(kMP4_MusicBrainz_AlbumId).toStringList().toString(), song->mutable_musicbrainz_album_id());
@ -825,7 +825,7 @@ void TagReaderTagLib::ParseMP4Tags(TagLib::MP4::Tag *tag, QString *disc, QString
AssignTagLibStringToStdString(tag->item(kMP4_MusicBrainz_ReleaseGroupId).toStringList().toString(), song->mutable_musicbrainz_release_group_id()); AssignTagLibStringToStdString(tag->item(kMP4_MusicBrainz_ReleaseGroupId).toStringList().toString(), song->mutable_musicbrainz_release_group_id());
} }
if (tag->contains(kMP4_MusicBrainz_WorkId)) { if (tag->contains(kMP4_MusicBrainz_WorkId)) {
AssignTagLibStringToStdString(tag->item(kMP4_MusicBrainz_WorkId).toStringList().toString(), song->mutable_musicbrainz_work_id()); AssignTagLibStringToStdString(TagLibStringListToSlashSeparatedString(tag->item(kMP4_MusicBrainz_WorkId).toStringList()), song->mutable_musicbrainz_work_id());
} }
} }
@ -1870,3 +1870,17 @@ TagReaderBase::Result TagReaderTagLib::SaveSongRatingToFile(const QString &filen
return success ? Result::ErrorCode::Success : Result::ErrorCode::FileSaveError; return success ? Result::ErrorCode::Success : Result::ErrorCode::FileSaveError;
} }
TagLib::String TagReaderTagLib::TagLibStringListToSlashSeparatedString(const TagLib::StringList &taglib_string_list) {
TagLib::String result_string;
for (const TagLib::String &taglib_string : taglib_string_list) {
if (!result_string.isEmpty()) {
result_string += '/';
}
result_string += taglib_string;
}
return result_string;
}

View File

@ -136,6 +136,8 @@ class TagReaderTagLib : public TagReaderBase {
void SetEmbeddedArt(TagLib::ID3v2::Tag *tag, const QByteArray &data, const QString &mime_type) const; void SetEmbeddedArt(TagLib::ID3v2::Tag *tag, const QByteArray &data, const QString &mime_type) const;
void SetEmbeddedArt(TagLib::MP4::File *aac_file, TagLib::MP4::Tag *tag, const QByteArray &data, const QString &mime_type) const; void SetEmbeddedArt(TagLib::MP4::File *aac_file, TagLib::MP4::Tag *tag, const QByteArray &data, const QString &mime_type) const;
static TagLib::String TagLibStringListToSlashSeparatedString(const TagLib::StringList &taglib_string_list);
private: private:
FileRefFactory *factory_; FileRefFactory *factory_;