mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-17 03:45:56 +01:00
Add beginnings of support for requesting events calendar for an artist
from songkick (waiting on API key).
This commit is contained in:
parent
38f1b71761
commit
21419765d3
3
3rdparty/libechonest/Artist.cpp
vendored
3
3rdparty/libechonest/Artist.cpp
vendored
@ -581,6 +581,8 @@ QByteArray Echonest::Artist::searchParamToString(Echonest::Artist::SearchParam p
|
||||
return "sort";
|
||||
case Mood:
|
||||
return "mood";
|
||||
case IdSpace:
|
||||
return "bucket";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
@ -622,4 +624,3 @@ QDebug Echonest::operator<<(QDebug d, const Echonest::Artist& artist)
|
||||
{
|
||||
return d.maybeSpace() << QString::fromLatin1( "Artist(%1, %2)" ).arg( artist.name() ).arg( QString::fromLatin1(artist.id()) );
|
||||
}
|
||||
|
||||
|
@ -276,6 +276,7 @@ set(SOURCES
|
||||
songinfo/songinfosettingspage.cpp
|
||||
songinfo/songinfotextview.cpp
|
||||
songinfo/songinfoview.cpp
|
||||
songinfo/songkickconcerts.cpp
|
||||
songinfo/songplaystats.cpp
|
||||
songinfo/ultimatelyricsprovider.cpp
|
||||
songinfo/ultimatelyricsreader.cpp
|
||||
@ -528,6 +529,7 @@ set(HEADERS
|
||||
songinfo/songinfosettingspage.h
|
||||
songinfo/songinfotextview.h
|
||||
songinfo/songinfoview.h
|
||||
songinfo/songkickconcerts.h
|
||||
songinfo/songplaystats.h
|
||||
songinfo/ultimatelyricsprovider.h
|
||||
songinfo/ultimatelyricsreader.h
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "echonestbiographies.h"
|
||||
#include "echonestimages.h"
|
||||
#include "songinfofetcher.h"
|
||||
#include "songkickconcerts.h"
|
||||
#include "widgets/prettyimageview.h"
|
||||
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
@ -31,6 +32,7 @@ ArtistInfoView::ArtistInfoView(QWidget *parent)
|
||||
{
|
||||
fetcher_->AddProvider(new EchoNestBiographies);
|
||||
fetcher_->AddProvider(new EchoNestImages);
|
||||
fetcher_->AddProvider(new SongkickConcerts);
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
fetcher_->AddProvider(new EchoNestSimilarArtists);
|
||||
fetcher_->AddProvider(new EchoNestTags);
|
||||
|
61
src/songinfo/songkickconcerts.cpp
Normal file
61
src/songinfo/songkickconcerts.cpp
Normal file
@ -0,0 +1,61 @@
|
||||
#include "songkickconcerts.h"
|
||||
|
||||
#include <echonest/Artist.h>
|
||||
#include "core/closure.h"
|
||||
|
||||
const char* SongkickConcerts::kSongkickArtistBucket = "id:songkick";
|
||||
const char* SongkickConcerts::kSongkickArtistCalendarUrl =
|
||||
"http://api.songkick.com/api/3.0/artists/%1/calendar.json?apikey=";
|
||||
|
||||
SongkickConcerts::SongkickConcerts() {
|
||||
|
||||
}
|
||||
|
||||
void SongkickConcerts::FetchInfo(int id, const Song& metadata) {
|
||||
Echonest::Artist::SearchParams params;
|
||||
params.push_back(qMakePair(Echonest::Artist::Name, QVariant(metadata.artist())));
|
||||
params.push_back(qMakePair(Echonest::Artist::IdSpace, QVariant(kSongkickArtistBucket)));
|
||||
qLog(Debug) << "Params:" << params;
|
||||
QNetworkReply* reply = Echonest::Artist::search(params);
|
||||
qLog(Debug) << reply->request().url();
|
||||
NewClosure(reply, SIGNAL(finished()), this, SLOT(ArtistSearchFinished(QNetworkReply*, int)), reply, id);
|
||||
}
|
||||
|
||||
void SongkickConcerts::ArtistSearchFinished(QNetworkReply* reply, int id) {
|
||||
reply->deleteLater();
|
||||
try {
|
||||
Echonest::Artists artists = Echonest::Artist::parseSearch(reply);
|
||||
if (artists.isEmpty()) {
|
||||
qLog(Debug) << "Failed to find artist in echonest";
|
||||
return;
|
||||
}
|
||||
|
||||
const Echonest::Artist& artist = artists[0];
|
||||
const Echonest::ForeignIds& foreign_ids = artist.foreignIds();
|
||||
QString songkick_id;
|
||||
foreach (const Echonest::ForeignId& id, foreign_ids) {
|
||||
if (id.catalog == "songkick") {
|
||||
songkick_id = id.foreign_id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (songkick_id.isEmpty()) {
|
||||
qLog(Debug) << "Failed to fetch songkick foreign id for artist";
|
||||
return;
|
||||
}
|
||||
|
||||
FetchSongkickCalendar(songkick_id, id);
|
||||
} catch (Echonest::ParseError& e) {
|
||||
qLog(Error) << "Error parsing echonest reply:" << e.errorType() << e.what();
|
||||
}
|
||||
}
|
||||
|
||||
void SongkickConcerts::FetchSongkickCalendar(const QString& artist_id, int id) {
|
||||
QUrl url(QString(kSongkickArtistCalendarUrl).arg(artist_id));
|
||||
qLog(Debug) << "Would send request to:" << url;
|
||||
}
|
||||
|
||||
void SongkickConcerts::CalendarRequestFinished() {
|
||||
|
||||
}
|
26
src/songinfo/songkickconcerts.h
Normal file
26
src/songinfo/songkickconcerts.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef SONGKICKCONCERTS_H
|
||||
#define SONGKICKCONCERTS_H
|
||||
|
||||
#include "songinfoprovider.h"
|
||||
|
||||
class QNetworkReply;
|
||||
|
||||
class SongkickConcerts : public SongInfoProvider {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SongkickConcerts();
|
||||
void FetchInfo(int id, const Song& metadata);
|
||||
|
||||
private slots:
|
||||
void ArtistSearchFinished(QNetworkReply* reply, int id);
|
||||
void CalendarRequestFinished();
|
||||
|
||||
private:
|
||||
void FetchSongkickCalendar(const QString& artist_id, int id);
|
||||
|
||||
static const char* kSongkickArtistBucket;
|
||||
static const char* kSongkickArtistCalendarUrl;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user