Port Musicbrainz track lookups to API v2.
(cherry picked from commit d6bada074a0344f2eafe132d9ceba0e401de39bd)
This commit is contained in:
parent
7eb4ab8453
commit
d0eec3f384
@ -24,7 +24,7 @@
|
|||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
const char* MusicBrainzClient::kTrackUrl = "http://musicbrainz.org/ws/1/track/";
|
const char* MusicBrainzClient::kTrackUrl = "http://musicbrainz.org/ws/2/recording/";
|
||||||
const char* MusicBrainzClient::kDiscUrl = "http://musicbrainz.org/ws/1/release/";
|
const char* MusicBrainzClient::kDiscUrl = "http://musicbrainz.org/ws/1/release/";
|
||||||
const int MusicBrainzClient::kDefaultTimeout = 5000; // msec
|
const int MusicBrainzClient::kDefaultTimeout = 5000; // msec
|
||||||
|
|
||||||
@ -39,8 +39,7 @@ void MusicBrainzClient::Start(int id, const QString& mbid) {
|
|||||||
typedef QPair<QString, QString> Param;
|
typedef QPair<QString, QString> Param;
|
||||||
|
|
||||||
QList<Param> parameters;
|
QList<Param> parameters;
|
||||||
parameters << Param("type", "xml")
|
parameters << Param("inc", "artists+releases+media");
|
||||||
<< Param("inc", "artist+releases");
|
|
||||||
|
|
||||||
QUrl url(kTrackUrl + mbid);
|
QUrl url(kTrackUrl + mbid);
|
||||||
url.setQueryItems(parameters);
|
url.setQueryItems(parameters);
|
||||||
@ -151,7 +150,7 @@ void MusicBrainzClient::RequestFinished() {
|
|||||||
|
|
||||||
QXmlStreamReader reader(reply);
|
QXmlStreamReader reader(reply);
|
||||||
while (!reader.atEnd()) {
|
while (!reader.atEnd()) {
|
||||||
if (reader.readNext() == QXmlStreamReader::StartElement && reader.name() == "track") {
|
if (reader.readNext() == QXmlStreamReader::StartElement && reader.name() == "recording") {
|
||||||
Result track = ParseTrack(&reader);
|
Result track = ParseTrack(&reader);
|
||||||
if (!track.title_.isEmpty()) {
|
if (!track.title_.isEmpty()) {
|
||||||
ret << track;
|
ret << track;
|
||||||
@ -173,7 +172,7 @@ MusicBrainzClient::Result MusicBrainzClient::ParseTrack(QXmlStreamReader* reader
|
|||||||
|
|
||||||
if (name == "title") {
|
if (name == "title") {
|
||||||
ret.title_ = reader->readElementText();
|
ret.title_ = reader->readElementText();
|
||||||
} else if (name == "duration") {
|
} else if (name == "length") {
|
||||||
ret.duration_msec_ = reader->readElementText().toInt();
|
ret.duration_msec_ = reader->readElementText().toInt();
|
||||||
} else if (name == "artist") {
|
} else if (name == "artist") {
|
||||||
ParseArtist(reader, &ret.artist_);
|
ParseArtist(reader, &ret.artist_);
|
||||||
@ -182,7 +181,7 @@ MusicBrainzClient::Result MusicBrainzClient::ParseTrack(QXmlStreamReader* reader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == QXmlStreamReader::EndElement && reader->name() == "track") {
|
if (type == QXmlStreamReader::EndElement && reader->name() == "recording") {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user