Define some original year tag keys as constants and enclose some if bodies with {}.
This commit is contained in:
parent
8dd4506697
commit
ef1992570b
|
@ -107,6 +107,14 @@ const char* TagReader::kMP4_FMPS_Playcount_ID =
|
||||||
const char* TagReader::kMP4_FMPS_Score_ID =
|
const char* TagReader::kMP4_FMPS_Score_ID =
|
||||||
"----:com.apple.iTunes:FMPS_Rating_Amarok_Score";
|
"----:com.apple.iTunes:FMPS_Rating_Amarok_Score";
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
// Tags containing the year the album was originally released (in contrast to
|
||||||
|
// other tags that contain the release year of the current edition)
|
||||||
|
const char* kMP4_OriginalYear_ID = "----:com.apple.iTunes:ORIGINAL YEAR";
|
||||||
|
const char* kASF_OriginalDate_ID = "WM/OriginalReleaseTime";
|
||||||
|
const char* kASF_OriginalYear_ID = "WM/OriginalReleaseYear";
|
||||||
|
}
|
||||||
|
|
||||||
TagReader::TagReader()
|
TagReader::TagReader()
|
||||||
: factory_(new TagLibFileRefFactory),
|
: factory_(new TagLibFileRefFactory),
|
||||||
network_(new QNetworkAccessManager),
|
network_(new QNetworkAccessManager),
|
||||||
|
@ -190,12 +198,13 @@ void TagReader::ReadFile(const QString& filename,
|
||||||
compilation =
|
compilation =
|
||||||
TStringToQString(map["TCMP"].front()->toString()).trimmed();
|
TStringToQString(map["TCMP"].front()->toString()).trimmed();
|
||||||
|
|
||||||
if (!map["TDOR"].isEmpty())
|
if (!map["TDOR"].isEmpty()) {
|
||||||
song->set_originalyear(
|
song->set_originalyear(
|
||||||
map["TDOR"].front()->toString().substr(0, 4).toInt());
|
map["TDOR"].front()->toString().substr(0, 4).toInt());
|
||||||
else if (!map["TORY"].isEmpty())
|
} else if (!map["TORY"].isEmpty()) {
|
||||||
song->set_originalyear(
|
song->set_originalyear(
|
||||||
map["TORY"].front()->toString().substr(0, 4).toInt());
|
map["TORY"].front()->toString().substr(0, 4).toInt());
|
||||||
|
}
|
||||||
|
|
||||||
if (!map["USLT"].isEmpty()) {
|
if (!map["USLT"].isEmpty()) {
|
||||||
Decode(map["USLT"].front()->toString(), nullptr,
|
Decode(map["USLT"].front()->toString(), nullptr,
|
||||||
|
@ -321,10 +330,13 @@ void TagReader::ReadFile(const QString& filename,
|
||||||
song->mutable_grouping());
|
song->mutable_grouping());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (items.contains("----:com.apple.iTunes:ORIGINAL YEAR"))
|
if (items.contains(kMP4_OriginalYear_ID)) {
|
||||||
song->set_originalyear(
|
song->set_originalyear(
|
||||||
TStringToQString(items["----:com.apple.iTunes:ORIGINAL YEAR"]
|
TStringToQString(
|
||||||
.toStringList().toString('\n')).left(4).toInt());
|
items[kMP4_OriginalYear_ID].toStringList().toString('\n'))
|
||||||
|
.left(4)
|
||||||
|
.toInt());
|
||||||
|
}
|
||||||
|
|
||||||
Decode(mp4_tag->comment(), nullptr, song->mutable_comment());
|
Decode(mp4_tag->comment(), nullptr, song->mutable_comment());
|
||||||
}
|
}
|
||||||
|
@ -367,18 +379,20 @@ void TagReader::ReadFile(const QString& filename,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attributes_map.contains("WM/OriginalReleaseTime")) {
|
if (attributes_map.contains(kASF_OriginalDate_ID)) {
|
||||||
const TagLib::ASF::AttributeList& attributes =
|
const TagLib::ASF::AttributeList& attributes =
|
||||||
attributes_map["WM/OriginalReleaseTime"];
|
attributes_map[kASF_OriginalDate_ID];
|
||||||
if (!attributes.isEmpty())
|
if (!attributes.isEmpty()) {
|
||||||
song->set_originalyear(
|
song->set_originalyear(
|
||||||
TStringToQString(attributes.front().toString()).left(4).toInt());
|
TStringToQString(attributes.front().toString()).left(4).toInt());
|
||||||
} else if (attributes_map.contains("WM/OriginalReleaseYear")) {
|
}
|
||||||
|
} else if (attributes_map.contains(kASF_OriginalYear_ID)) {
|
||||||
const TagLib::ASF::AttributeList& attributes =
|
const TagLib::ASF::AttributeList& attributes =
|
||||||
attributes_map["WM/OriginalReleaseYear"];
|
attributes_map[kASF_OriginalYear_ID];
|
||||||
if (!attributes.isEmpty())
|
if (!attributes.isEmpty()) {
|
||||||
song->set_originalyear(
|
song->set_originalyear(
|
||||||
TStringToQString(attributes.front().toString()).left(4).toInt());
|
TStringToQString(attributes.front().toString()).left(4).toInt());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue