1 /* 2 * Strawberry Music Player 3 * Copyright 2018-2021, Jonas Kvinge <jonas@jkvinge.net> 4 * 5 * Strawberry is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * Strawberry is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with Strawberry. If not, see <http://www.gnu.org/licenses/>. 17 * 18 */ 19 20 #ifndef AUDDLYRICSPROVIDER_H 21 #define AUDDLYRICSPROVIDER_H 22 23 #include "config.h" 24 25 #include <QtGlobal> 26 #include <QObject> 27 #include <QList> 28 #include <QVariant> 29 #include <QString> 30 #include <QJsonArray> 31 32 #include "jsonlyricsprovider.h" 33 #include "lyricsfetcher.h" 34 35 class QNetworkReply; 36 class NetworkAccessManager; 37 38 class AuddLyricsProvider : public JsonLyricsProvider { 39 Q_OBJECT 40 41 public: 42 explicit AuddLyricsProvider(NetworkAccessManager *network, QObject *parent = nullptr); 43 ~AuddLyricsProvider() override; 44 45 bool StartSearch(const QString &artist, const QString &album, const QString &title, quint64 id) override; 46 void CancelSearch(const quint64 id) override; 47 48 private: 49 void Error(const QString &error, const QVariant &debug = QVariant()) override; 50 QJsonArray ExtractResult(QNetworkReply *reply, const QString &artist, const QString &title); 51 52 private slots: 53 void HandleSearchReply(QNetworkReply *reply, const quint64 id, const QString &artist, const QString &title); 54 55 private: 56 static const char *kUrlSearch; 57 static const char *kAPITokenB64; 58 static const int kMaxLength; 59 QList<QNetworkReply*> replies_; 60 61 }; 62 63 #endif // AUDDLYRICSPROVIDER_H 64