diff --git a/src/songinfo/songkickconcerts.cpp b/src/songinfo/songkickconcerts.cpp index 9c4b1b326..c4f25dda4 100644 --- a/src/songinfo/songkickconcerts.cpp +++ b/src/songinfo/songkickconcerts.cpp @@ -22,7 +22,9 @@ const char* SongkickConcerts::kSongkickArtistBucket = "id:songkick"; const char* SongkickConcerts::kSongkickArtistCalendarUrl = - "http://api.songkick.com/api/3.0/artists/%1/calendar.json?apikey="; + "http://api.songkick.com/api/3.0/artists/%1/calendar.json?" + "per_page=5&" + "apikey=8rgKfy1WU6IlJFfN"; SongkickConcerts::SongkickConcerts() { @@ -62,7 +64,13 @@ void SongkickConcerts::ArtistSearchFinished(QNetworkReply* reply, int id) { return; } - FetchSongkickCalendar(songkick_id, id); + QStringList split = songkick_id.split(':'); + if (split.count() != 3) { + qLog(Error) << "Weird songkick id"; + return; + } + + FetchSongkickCalendar(split[2], id); } catch (Echonest::ParseError& e) { qLog(Error) << "Error parsing echonest reply:" << e.errorType() << e.what(); } @@ -70,9 +78,11 @@ void SongkickConcerts::ArtistSearchFinished(QNetworkReply* reply, int id) { void SongkickConcerts::FetchSongkickCalendar(const QString& artist_id, int id) { QUrl url(QString(kSongkickArtistCalendarUrl).arg(artist_id)); - qLog(Debug) << "Would send request to:" << url; + qLog(Debug) << url; + QNetworkReply* reply = network_.get(QNetworkRequest(url)); + NewClosure(reply, SIGNAL(finished()), this, SLOT(CalendarRequestFinished(QNetworkReply*, int)), reply, id); } -void SongkickConcerts::CalendarRequestFinished() { - +void SongkickConcerts::CalendarRequestFinished(QNetworkReply* reply, int id) { + qLog(Debug) << reply->readAll(); } diff --git a/src/songinfo/songkickconcerts.h b/src/songinfo/songkickconcerts.h index e7fc341ec..6eb98d469 100644 --- a/src/songinfo/songkickconcerts.h +++ b/src/songinfo/songkickconcerts.h @@ -20,6 +20,8 @@ #include "songinfoprovider.h" +#include "core/network.h" + class QNetworkReply; class SongkickConcerts : public SongInfoProvider { @@ -31,11 +33,13 @@ class SongkickConcerts : public SongInfoProvider { private slots: void ArtistSearchFinished(QNetworkReply* reply, int id); - void CalendarRequestFinished(); + void CalendarRequestFinished(QNetworkReply* reply, int id); private: void FetchSongkickCalendar(const QString& artist_id, int id); + NetworkAccessManager network_; + static const char* kSongkickArtistBucket; static const char* kSongkickArtistCalendarUrl; };