mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-06 07:19:51 +01:00
libclementine-tagreader: Discontinue use of deprecated taglib methods.
Direct use of MP4::itemListMap() was deprecated in favor of using item() and setItem(). XiphComment::removeField was replaced by removeFields.
This commit is contained in:
parent
99ee1394a5
commit
163ebe71d8
@ -454,72 +454,74 @@ void TagReader::ReadFile(const QString& filename,
|
|||||||
dynamic_cast<TagLib::MP4::File*>(fileref->file())) {
|
dynamic_cast<TagLib::MP4::File*>(fileref->file())) {
|
||||||
if (file->tag()) {
|
if (file->tag()) {
|
||||||
TagLib::MP4::Tag* mp4_tag = file->tag();
|
TagLib::MP4::Tag* mp4_tag = file->tag();
|
||||||
const TagLib::MP4::ItemListMap& items = mp4_tag->itemListMap();
|
TagLib::MP4::Item item;
|
||||||
|
|
||||||
// Find album artists
|
// Find album artists
|
||||||
TagLib::MP4::ItemListMap::ConstIterator it = items.find("aART");
|
item = mp4_tag->item("aART");
|
||||||
if (it != items.end()) {
|
if (item.isValid()) {
|
||||||
TagLib::StringList album_artists = it->second.toStringList();
|
TagLib::StringList album_artists = item.toStringList();
|
||||||
if (!album_artists.isEmpty()) {
|
if (!album_artists.isEmpty()) {
|
||||||
Decode(album_artists.front(), nullptr, song->mutable_albumartist());
|
Decode(album_artists.front(), nullptr, song->mutable_albumartist());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find album cover art
|
// Find album cover art
|
||||||
if (items.find("covr") != items.end()) {
|
item = mp4_tag->item("covr");
|
||||||
|
if (item.isValid()) {
|
||||||
song->set_art_automatic(kEmbeddedCover);
|
song->set_art_automatic(kEmbeddedCover);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (items.contains("disk")) {
|
item = mp4_tag->item("disk");
|
||||||
disc = TStringToQString(
|
if (item.isValid()) {
|
||||||
TagLib::String::number(items["disk"].toIntPair().first));
|
disc = TStringToQString(TagLib::String::number(item.toIntPair().first));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (items.contains(kMP4_FMPS_Rating_ID)) {
|
item = mp4_tag->item(kMP4_FMPS_Rating_ID);
|
||||||
|
if (item.isValid()) {
|
||||||
float rating =
|
float rating =
|
||||||
TStringToQString(
|
TStringToQString(item.toStringList().toString('\n')).toFloat();
|
||||||
items[kMP4_FMPS_Rating_ID].toStringList().toString('\n'))
|
|
||||||
.toFloat();
|
|
||||||
if (song->rating() <= 0 && rating > 0) {
|
if (song->rating() <= 0 && rating > 0) {
|
||||||
song->set_rating(rating);
|
song->set_rating(rating);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (items.contains(kMP4_FMPS_Playcount_ID)) {
|
item = mp4_tag->item(kMP4_FMPS_Playcount_ID);
|
||||||
|
if (item.isValid()) {
|
||||||
int playcount =
|
int playcount =
|
||||||
TStringToQString(
|
TStringToQString(item.toStringList().toString('\n')).toFloat();
|
||||||
items[kMP4_FMPS_Playcount_ID].toStringList().toString('\n'))
|
|
||||||
.toFloat();
|
|
||||||
if (song->playcount() <= 0 && playcount > 0) {
|
if (song->playcount() <= 0 && playcount > 0) {
|
||||||
song->set_playcount(playcount);
|
song->set_playcount(playcount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (items.contains(kMP4_FMPS_Playcount_ID)) {
|
item = mp4_tag->item(kMP4_FMPS_Score_ID);
|
||||||
int score = TStringToQString(
|
if (item.isValid()) {
|
||||||
items[kMP4_FMPS_Score_ID].toStringList().toString('\n'))
|
int score =
|
||||||
.toFloat() *
|
TStringToQString(item.toStringList().toString('\n')).toFloat() *
|
||||||
100;
|
100;
|
||||||
if (song->score() <= 0 && score > 0) {
|
if (song->score() <= 0 && score > 0) {
|
||||||
song->set_score(score);
|
song->set_score(score);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (items.contains("\251wrt")) {
|
item = mp4_tag->item("\251wrt");
|
||||||
Decode(items["\251wrt"].toStringList().toString(", "), nullptr,
|
if (item.isValid()) {
|
||||||
|
Decode(item.toStringList().toString(", "), nullptr,
|
||||||
song->mutable_composer());
|
song->mutable_composer());
|
||||||
}
|
}
|
||||||
if (items.contains("\251grp")) {
|
item = mp4_tag->item("\251grp");
|
||||||
Decode(items["\251grp"].toStringList().toString(" "), nullptr,
|
if (item.isValid()) {
|
||||||
|
Decode(item.toStringList().toString(" "), nullptr,
|
||||||
song->mutable_grouping());
|
song->mutable_grouping());
|
||||||
}
|
}
|
||||||
if (items.contains("\251lyr")) {
|
item = mp4_tag->item("\251lyr");
|
||||||
Decode(items["\251lyr"].toStringList().toString(" "), nullptr,
|
if (item.isValid()) {
|
||||||
|
Decode(item.toStringList().toString(" "), nullptr,
|
||||||
song->mutable_lyrics());
|
song->mutable_lyrics());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (items.contains(kMP4_OriginalYear_ID)) {
|
item = mp4_tag->item(kMP4_OriginalYear_ID);
|
||||||
|
if (item.isValid()) {
|
||||||
song->set_originalyear(
|
song->set_originalyear(
|
||||||
TStringToQString(
|
TStringToQString(item.toStringList().toString('\n'))
|
||||||
items[kMP4_OriginalYear_ID].toStringList().toString('\n'))
|
|
||||||
.left(4)
|
.left(4)
|
||||||
.toInt());
|
.toInt());
|
||||||
}
|
}
|
||||||
@ -801,11 +803,11 @@ void TagReader::SetVorbisComments(
|
|||||||
|
|
||||||
vorbis_comments->addField("ALBUMARTIST",
|
vorbis_comments->addField("ALBUMARTIST",
|
||||||
StdStringToTaglibString(song.albumartist()), true);
|
StdStringToTaglibString(song.albumartist()), true);
|
||||||
vorbis_comments->removeField("ALBUM ARTIST");
|
vorbis_comments->removeFields("ALBUM ARTIST");
|
||||||
|
|
||||||
vorbis_comments->addField("LYRICS", StdStringToTaglibString(song.lyrics()),
|
vorbis_comments->addField("LYRICS", StdStringToTaglibString(song.lyrics()),
|
||||||
true);
|
true);
|
||||||
vorbis_comments->removeField("UNSYNCEDLYRICS");
|
vorbis_comments->removeFields("UNSYNCEDLYRICS");
|
||||||
}
|
}
|
||||||
|
|
||||||
void TagReader::SetFMPSStatisticsVorbisComments(
|
void TagReader::SetFMPSStatisticsVorbisComments(
|
||||||
@ -943,16 +945,17 @@ bool TagReader::SaveFile(const QString& filename,
|
|||||||
} else if (TagLib::MP4::File* file =
|
} else if (TagLib::MP4::File* file =
|
||||||
dynamic_cast<TagLib::MP4::File*>(fileref->file())) {
|
dynamic_cast<TagLib::MP4::File*>(fileref->file())) {
|
||||||
TagLib::MP4::Tag* tag = file->tag();
|
TagLib::MP4::Tag* tag = file->tag();
|
||||||
tag->itemListMap()["disk"] =
|
tag->setItem("disk",
|
||||||
TagLib::MP4::Item(song.disc() <= 0 - 1 ? 0 : song.disc(), 0);
|
TagLib::MP4::Item(song.disc() <= 0 - 1 ? 0 : song.disc(), 0));
|
||||||
tag->itemListMap()["tmpo"] = TagLib::StringList(
|
tag->setItem("tmpo",
|
||||||
song.bpm() <= 0 - 1 ? "0" : TagLib::String::number(song.bpm()));
|
TagLib::StringList(song.bpm() <= 0 - 1
|
||||||
tag->itemListMap()["\251wrt"] = TagLib::StringList(song.composer().c_str());
|
? "0"
|
||||||
tag->itemListMap()["\251grp"] = TagLib::StringList(song.grouping().c_str());
|
: TagLib::String::number(song.bpm())));
|
||||||
tag->itemListMap()["\251lyr"] = TagLib::StringList(song.lyrics().c_str());
|
tag->setItem("\251wrt", TagLib::StringList(song.composer().c_str()));
|
||||||
tag->itemListMap()["aART"] = TagLib::StringList(song.albumartist().c_str());
|
tag->setItem("\251grp", TagLib::StringList(song.grouping().c_str()));
|
||||||
tag->itemListMap()["cpil"] =
|
tag->setItem("\251lyr", TagLib::StringList(song.lyrics().c_str()));
|
||||||
TagLib::StringList(song.compilation() ? "1" : "0");
|
tag->setItem("aART", TagLib::StringList(song.albumartist().c_str()));
|
||||||
|
tag->setItem("cpil", TagLib::StringList(song.compilation() ? "1" : "0"));
|
||||||
} else if (TagLib::APE::File* file =
|
} else if (TagLib::APE::File* file =
|
||||||
dynamic_cast<TagLib::APE::File*>(fileref->file())) {
|
dynamic_cast<TagLib::APE::File*>(fileref->file())) {
|
||||||
saveApeTag(file->APETag(true));
|
saveApeTag(file->APETag(true));
|
||||||
@ -1052,11 +1055,12 @@ bool TagReader::SaveSongStatisticsToFile(
|
|||||||
dynamic_cast<TagLib::MP4::File*>(fileref->file())) {
|
dynamic_cast<TagLib::MP4::File*>(fileref->file())) {
|
||||||
TagLib::MP4::Tag* tag = file->tag();
|
TagLib::MP4::Tag* tag = file->tag();
|
||||||
if (song.score())
|
if (song.score())
|
||||||
tag->itemListMap()[kMP4_FMPS_Score_ID] = TagLib::MP4::Item(
|
tag->setItem(kMP4_FMPS_Score_ID,
|
||||||
QStringToTaglibString(QString::number(song.score() / 100.0)));
|
TagLib::MP4::Item(QStringToTaglibString(
|
||||||
|
QString::number(song.score() / 100.0))));
|
||||||
if (song.playcount())
|
if (song.playcount())
|
||||||
tag->itemListMap()[kMP4_FMPS_Playcount_ID] =
|
tag->setItem(kMP4_FMPS_Playcount_ID,
|
||||||
TagLib::MP4::Item(TagLib::String::number(song.playcount()));
|
TagLib::MP4::Item(TagLib::String::number(song.playcount())));
|
||||||
} else if (TagLib::APE::File* file =
|
} else if (TagLib::APE::File* file =
|
||||||
dynamic_cast<TagLib::APE::File*>(fileref->file())) {
|
dynamic_cast<TagLib::APE::File*>(fileref->file())) {
|
||||||
saveApeSongStats(file->APETag(true));
|
saveApeSongStats(file->APETag(true));
|
||||||
@ -1138,8 +1142,8 @@ bool TagReader::SaveSongRatingToFile(
|
|||||||
else if (TagLib::MP4::File* file =
|
else if (TagLib::MP4::File* file =
|
||||||
dynamic_cast<TagLib::MP4::File*>(fileref->file())) {
|
dynamic_cast<TagLib::MP4::File*>(fileref->file())) {
|
||||||
TagLib::MP4::Tag* tag = file->tag();
|
TagLib::MP4::Tag* tag = file->tag();
|
||||||
tag->itemListMap()[kMP4_FMPS_Rating_ID] = TagLib::StringList(
|
tag->setItem(kMP4_FMPS_Rating_ID, TagLib::StringList(QStringToTaglibString(
|
||||||
QStringToTaglibString(QString::number(song.rating())));
|
QString::number(song.rating()))));
|
||||||
} else if (TagLib::APE::File* file =
|
} else if (TagLib::APE::File* file =
|
||||||
dynamic_cast<TagLib::APE::File*>(fileref->file())) {
|
dynamic_cast<TagLib::APE::File*>(fileref->file())) {
|
||||||
saveApeSongRating(file->APETag(true));
|
saveApeSongRating(file->APETag(true));
|
||||||
@ -1373,10 +1377,9 @@ QByteArray TagReader::LoadEmbeddedArt(const QString& filename) const {
|
|||||||
TagLib::MP4::File* aac_file = dynamic_cast<TagLib::MP4::File*>(ref.file());
|
TagLib::MP4::File* aac_file = dynamic_cast<TagLib::MP4::File*>(ref.file());
|
||||||
if (aac_file) {
|
if (aac_file) {
|
||||||
TagLib::MP4::Tag* tag = aac_file->tag();
|
TagLib::MP4::Tag* tag = aac_file->tag();
|
||||||
const TagLib::MP4::ItemListMap& items = tag->itemListMap();
|
TagLib::MP4::Item item = tag->item("covr");
|
||||||
TagLib::MP4::ItemListMap::ConstIterator it = items.find("covr");
|
if (item.isValid()) {
|
||||||
if (it != items.end()) {
|
const TagLib::MP4::CoverArtList& art_list = item.toCoverArtList();
|
||||||
const TagLib::MP4::CoverArtList& art_list = it->second.toCoverArtList();
|
|
||||||
|
|
||||||
if (!art_list.isEmpty()) {
|
if (!art_list.isEmpty()) {
|
||||||
// Just take the first one for now
|
// Just take the first one for now
|
||||||
|
Loading…
Reference in New Issue
Block a user