Skip to content

Commit

Permalink
Add support for reading PUIDs from tags
Browse files Browse the repository at this point in the history
  • Loading branch information
lalinsky committed Jun 29, 2011
1 parent 3fb812b commit 656e751
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions analyzefiletask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ void AnalyzeFileTask::run()
result->artist = tags.artist();
result->album = tags.album();
result->albumArtist = tags.albumArtist();
result->puid = tags.puid();
result->trackNo = tags.trackNo();
result->discNo = tags.discNo();
result->year = tags.year();
Expand Down
1 change: 1 addition & 0 deletions analyzefiletask.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ struct AnalyzeResult
QString artist;
QString album;
QString albumArtist;
QString puid;
int trackNo;
int discNo;
int year;
Expand Down
3 changes: 3 additions & 0 deletions fingerprinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ bool Fingerprinter::maybeSubmit(bool force)
url.addQueryItem(QString("mbid.%1").arg(i), result->mbid);
}
else {
if (!result->puid.isEmpty()) {
url.addQueryItem(QString("puid.%1").arg(i), result->puid);
}
if (!result->track.isEmpty()) {
url.addQueryItem(QString("track.%1").arg(i), result->track);
}
Expand Down
16 changes: 16 additions & 0 deletions tagreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ void extractMetaFromXiphComment(TagReader *tr, TagLib::Ogg::XiphComment *tag)
if (tag->fieldListMap().contains(key)) {
tr->m_discNo = tag->fieldListMap()[key].front().toInt();
}
key = "MUSICIP_PUID";
if (tag->fieldListMap().contains(key)) {
tr->m_puid = TAGLIB_STRING_TO_QSTRING(tag->fieldListMap()[key].front());
}
}

void extractMetaFromAPETag(TagReader *tr, TagLib::APE::Tag *tag)
Expand All @@ -75,6 +79,10 @@ void extractMetaFromAPETag(TagReader *tr, TagLib::APE::Tag *tag)
if (tag->itemListMap().contains(key)) {
tr->m_discNo = tag->itemListMap()[key].toString().toInt();
}
key = "MUSICIP_PUID";
if (tag->itemListMap().contains(key)) {
tr->m_puid = TAGLIB_STRING_TO_QSTRING(tag->itemListMap()[key].toString());
}
}

void extractMetaFromFile(TagReader *tr, TagLib::Ogg::Vorbis::File *file)
Expand Down Expand Up @@ -123,6 +131,10 @@ void extractMetaFromFile(TagReader *tr, TagLib::ASF::File *file)
if (tag->attributeListMap().contains(key)) {
tr->m_discNo = tag->attributeListMap()[key].front().toString().toInt();
}
key = "MusicIP/PUID";
if (tag->attributeListMap().contains(key)) {
tr->m_puid = TAGLIB_STRING_TO_QSTRING(tag->attributeListMap()[key].front().toString());
}
}
#endif

Expand All @@ -142,6 +154,10 @@ void extractMetaFromFile(TagReader *tr, TagLib::MP4::File *file)
if (tag->itemListMap().contains(key)) {
tr->m_discNo = tag->itemListMap()[key].toIntPair().first;
}
key = "----:com.apple.iTunes:MusicIP PUID";
if (tag->itemListMap().contains(key)) {
tr->m_puid = TAGLIB_STRING_TO_QSTRING(tag->itemListMap()[key].toStringList().toString());
}
}
#endif

Expand Down
2 changes: 2 additions & 0 deletions tagreader.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class TagReader
QString artist() const { return m_artist; }
QString album() const { return m_album; }
QString albumArtist() const { return m_albumArtist; }
QString puid() const { return m_puid; }
int trackNo() const { return m_trackNo; }
int discNo() const { return m_discNo; }
int year() const { return m_year; }
Expand All @@ -62,6 +63,7 @@ class TagReader
QString m_album;
QString m_albumArtist;
QString m_mbid;
QString m_puid;
int m_trackNo;
int m_discNo;
int m_year;
Expand Down

0 comments on commit 656e751

Please sign in to comment.