Remove chartlyrics
This commit is contained in:
parent
814bb3006c
commit
ab7b65a30b
|
@ -20,7 +20,7 @@ Strawberry is a music player and music collection organizer. It is a fork of Cle
|
||||||
* Edit tags on music files
|
* Edit tags on music files
|
||||||
* Fetch tags from MusicBrainz
|
* Fetch tags from MusicBrainz
|
||||||
* Album cover art from [Last.fm](https://www.last.fm/), [Musicbrainz](https://musicbrainz.org/), [Discogs](https://www.discogs.com/), [Deezer](https://www.deezer.com/) and [Tidal](https://tidal.com/)
|
* Album cover art from [Last.fm](https://www.last.fm/), [Musicbrainz](https://musicbrainz.org/), [Discogs](https://www.discogs.com/), [Deezer](https://www.deezer.com/) and [Tidal](https://tidal.com/)
|
||||||
* Song lyrics from [AudD](https://audd.io/), [ChartLyrics](http://www.chartlyrics.com/), [lyrics.ovh](https://lyrics.ovh/) and [lololyrics.com](https://www.lololyrics.com/)
|
* Song lyrics from [AudD](https://audd.io/), [lyrics.ovh](https://lyrics.ovh/) and [lololyrics.com](https://www.lololyrics.com/)
|
||||||
* Support for multiple backends
|
* Support for multiple backends
|
||||||
* Audio analyzer
|
* Audio analyzer
|
||||||
* Audio equalizer
|
* Audio equalizer
|
||||||
|
|
|
@ -56,7 +56,7 @@ Description: Audio player and music collection organizer
|
||||||
- Edit tags on music files
|
- Edit tags on music files
|
||||||
- Fetch tags from MusicBrainz
|
- Fetch tags from MusicBrainz
|
||||||
- Album cover art from Lastfm, Musicbrainz, Discogs, Deezer and Tidal
|
- Album cover art from Lastfm, Musicbrainz, Discogs, Deezer and Tidal
|
||||||
- Song lyrics from AudD, ChartLyrics, lyrics.ovh and lololyrics.com
|
- Song lyrics from AudD, lyrics.ovh and lololyrics.com
|
||||||
- Support for multiple backends
|
- Support for multiple backends
|
||||||
- Audio analyzer
|
- Audio analyzer
|
||||||
- Audio equalizer
|
- Audio equalizer
|
||||||
|
|
|
@ -27,7 +27,7 @@ Features:
|
||||||
.br
|
.br
|
||||||
- Album cover art from Lastfm, Musicbrainz, Discogs, Deezer and Tidal
|
- Album cover art from Lastfm, Musicbrainz, Discogs, Deezer and Tidal
|
||||||
.br
|
.br
|
||||||
- Song lyrics from AudD, ChartLyrics, lyrics.ovh and lololyrics.com
|
- Song lyrics from AudD, lyrics.ovh and lololyrics.com
|
||||||
.br
|
.br
|
||||||
- Support for multiple backends
|
- Support for multiple backends
|
||||||
.br
|
.br
|
||||||
|
|
|
@ -105,7 +105,7 @@ Features:
|
||||||
- Edit tags on music files
|
- Edit tags on music files
|
||||||
- Fetch tags from MusicBrainz
|
- Fetch tags from MusicBrainz
|
||||||
- Album cover art from Last.fm, Musicbrainz, Discogs, Deezer and Tidal
|
- Album cover art from Last.fm, Musicbrainz, Discogs, Deezer and Tidal
|
||||||
- Song lyrics from AudD, ChartLyrics, lyrics.ovh and lololyrics.com
|
- Song lyrics from AudD, lyrics.ovh and lololyrics.com
|
||||||
- Support for multiple backends
|
- Support for multiple backends
|
||||||
- Audio analyzer
|
- Audio analyzer
|
||||||
- Audio equalizer
|
- Audio equalizer
|
||||||
|
|
|
@ -235,7 +235,6 @@ set(SOURCES
|
||||||
lyrics/auddlyricsprovider.cpp
|
lyrics/auddlyricsprovider.cpp
|
||||||
lyrics/ovhlyricsprovider.cpp
|
lyrics/ovhlyricsprovider.cpp
|
||||||
lyrics/lololyricsprovider.cpp
|
lyrics/lololyricsprovider.cpp
|
||||||
lyrics/chartlyricsprovider.cpp
|
|
||||||
|
|
||||||
settings/settingsdialog.cpp
|
settings/settingsdialog.cpp
|
||||||
settings/settingspage.cpp
|
settings/settingspage.cpp
|
||||||
|
@ -421,7 +420,6 @@ set(HEADERS
|
||||||
lyrics/auddlyricsprovider.h
|
lyrics/auddlyricsprovider.h
|
||||||
lyrics/ovhlyricsprovider.h
|
lyrics/ovhlyricsprovider.h
|
||||||
lyrics/lololyricsprovider.h
|
lyrics/lololyricsprovider.h
|
||||||
lyrics/chartlyricsprovider.h
|
|
||||||
|
|
||||||
settings/settingsdialog.h
|
settings/settingsdialog.h
|
||||||
settings/settingspage.h
|
settings/settingspage.h
|
||||||
|
|
|
@ -61,7 +61,6 @@
|
||||||
#include "lyrics/auddlyricsprovider.h"
|
#include "lyrics/auddlyricsprovider.h"
|
||||||
#include "lyrics/ovhlyricsprovider.h"
|
#include "lyrics/ovhlyricsprovider.h"
|
||||||
#include "lyrics/lololyricsprovider.h"
|
#include "lyrics/lololyricsprovider.h"
|
||||||
#include "lyrics/chartlyricsprovider.h"
|
|
||||||
|
|
||||||
#include "scrobbler/audioscrobbler.h"
|
#include "scrobbler/audioscrobbler.h"
|
||||||
|
|
||||||
|
@ -138,7 +137,6 @@ class ApplicationImpl {
|
||||||
lyrics_providers->AddProvider(new AuddLyricsProvider(app));
|
lyrics_providers->AddProvider(new AuddLyricsProvider(app));
|
||||||
lyrics_providers->AddProvider(new OVHLyricsProvider(app));
|
lyrics_providers->AddProvider(new OVHLyricsProvider(app));
|
||||||
lyrics_providers->AddProvider(new LoloLyricsProvider(app));
|
lyrics_providers->AddProvider(new LoloLyricsProvider(app));
|
||||||
lyrics_providers->AddProvider(new ChartLyricsProvider(app));
|
|
||||||
return lyrics_providers;
|
return lyrics_providers;
|
||||||
}),
|
}),
|
||||||
internet_services_([=]() {
|
internet_services_([=]() {
|
||||||
|
|
|
@ -1,136 +0,0 @@
|
||||||
/*
|
|
||||||
* Strawberry Music Player
|
|
||||||
* Copyright 2018, Jonas Kvinge <jonas@jkvinge.net>
|
|
||||||
*
|
|
||||||
* Strawberry is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Strawberry is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QByteArray>
|
|
||||||
#include <QList>
|
|
||||||
#include <QPair>
|
|
||||||
#include <QVariant>
|
|
||||||
#include <QString>
|
|
||||||
#include <QUrl>
|
|
||||||
#include <QUrlQuery>
|
|
||||||
#include <QNetworkAccessManager>
|
|
||||||
#include <QNetworkRequest>
|
|
||||||
#include <QNetworkReply>
|
|
||||||
#include <QXmlStreamReader>
|
|
||||||
|
|
||||||
#include "core/closure.h"
|
|
||||||
#include "core/logging.h"
|
|
||||||
#include "core/network.h"
|
|
||||||
#include "core/utilities.h"
|
|
||||||
#include "lyricsprovider.h"
|
|
||||||
#include "lyricsfetcher.h"
|
|
||||||
#include "chartlyricsprovider.h"
|
|
||||||
|
|
||||||
const char *ChartLyricsProvider::kUrlSearch = "http://api.chartlyrics.com/apiv1.asmx/SearchLyricDirect";
|
|
||||||
const int ChartLyricsProvider::kMaxLength = 6000;
|
|
||||||
|
|
||||||
ChartLyricsProvider::ChartLyricsProvider(QObject *parent) : LyricsProvider("ChartLyrics", parent), network_(new NetworkAccessManager(this)) {}
|
|
||||||
|
|
||||||
bool ChartLyricsProvider::StartSearch(const QString &artist, const QString&, const QString &title, const quint64 id) {
|
|
||||||
|
|
||||||
const ParamList params = ParamList() << Param("artist", artist)
|
|
||||||
<< Param("song", title);
|
|
||||||
|
|
||||||
QUrlQuery url_query;
|
|
||||||
for (const Param ¶m : params) {
|
|
||||||
url_query.addQueryItem(QUrl::toPercentEncoding(param.first), QUrl::toPercentEncoding(param.second));
|
|
||||||
}
|
|
||||||
|
|
||||||
QUrl url(kUrlSearch);
|
|
||||||
url.setQuery(url_query);
|
|
||||||
QNetworkReply *reply = network_->get(QNetworkRequest(url));
|
|
||||||
NewClosure(reply, SIGNAL(finished()), this, SLOT(HandleSearchReply(QNetworkReply*, const quint64, const QString&, const QString&)), reply, id, artist, title);
|
|
||||||
|
|
||||||
//qLog(Debug) << "ChartLyrics: Sending request for" << url;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChartLyricsProvider::CancelSearch(const quint64) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChartLyricsProvider::HandleSearchReply(QNetworkReply *reply, const quint64 id, const QString &artist, const QString &title) {
|
|
||||||
|
|
||||||
reply->deleteLater();
|
|
||||||
|
|
||||||
if (reply->error() != QNetworkReply::NoError) {
|
|
||||||
QString failure_reason = QString("%1 (%2)").arg(reply->errorString()).arg(reply->error());
|
|
||||||
Error(id, failure_reason);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() != 200) {
|
|
||||||
QString failure_reason = QString("Received HTTP code %1").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt());
|
|
||||||
Error(id, failure_reason);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QXmlStreamReader reader(reply);
|
|
||||||
LyricsSearchResults results;
|
|
||||||
LyricsSearchResult result;
|
|
||||||
|
|
||||||
while (!reader.atEnd()) {
|
|
||||||
QXmlStreamReader::TokenType type = reader.readNext();
|
|
||||||
QStringRef name = reader.name();
|
|
||||||
if (type == QXmlStreamReader::StartElement) {
|
|
||||||
if (name == "GetLyricResult") {
|
|
||||||
result = LyricsSearchResult();
|
|
||||||
}
|
|
||||||
if (name == "LyricArtist") {
|
|
||||||
result.artist = reader.readElementText();
|
|
||||||
}
|
|
||||||
else if (name == "LyricSong") {
|
|
||||||
result.title = reader.readElementText();
|
|
||||||
}
|
|
||||||
else if (name == "Lyric") {
|
|
||||||
result.lyrics = reader.readElementText();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (type == QXmlStreamReader::EndElement) {
|
|
||||||
if (name == "GetLyricResult") {
|
|
||||||
if (!result.artist.isEmpty() && !result.title.isEmpty() && !result.lyrics.isEmpty()) {
|
|
||||||
result.score = 0.0;
|
|
||||||
if (result.artist.toLower() == artist.toLower()) result.score += 1.0;
|
|
||||||
if (result.title.toLower() == title.toLower()) result.score += 1.0;
|
|
||||||
if (result.lyrics.length() > LyricsFetcher::kGoodLyricsLength) result.score += 1.0;
|
|
||||||
if (result.artist.toLower() == artist.toLower() || result.title.toLower() == title.toLower()) {
|
|
||||||
results << result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result = LyricsSearchResult();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (results.isEmpty()) qLog(Debug) << "ChartLyrics: No lyrics for" << artist << title;
|
|
||||||
else qLog(Debug) << "ChartLyrics: Got lyrics for" << artist << title;
|
|
||||||
|
|
||||||
emit SearchFinished(id, results);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChartLyricsProvider::Error(const quint64 id, const QString &error, QVariant debug) {
|
|
||||||
qLog(Error) << "ChartLyrics:" << error;
|
|
||||||
if (debug.isValid()) qLog(Debug) << debug;
|
|
||||||
emit SearchFinished(id, LyricsSearchResults());
|
|
||||||
}
|
|
|
@ -1,55 +0,0 @@
|
||||||
/*
|
|
||||||
* Strawberry Music Player
|
|
||||||
* Copyright 2018, Jonas Kvinge <jonas@jkvinge.net>
|
|
||||||
*
|
|
||||||
* Strawberry is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Strawberry is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef CHARTLYRICSPROVIDER_H
|
|
||||||
#define CHARTLYRICSPROVIDER_H
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QVariant>
|
|
||||||
#include <QString>
|
|
||||||
#include <QNetworkAccessManager>
|
|
||||||
#include <QNetworkReply>
|
|
||||||
|
|
||||||
#include "lyricsprovider.h"
|
|
||||||
#include "lyricsfetcher.h"
|
|
||||||
|
|
||||||
class ChartLyricsProvider : public LyricsProvider {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit ChartLyricsProvider(QObject *parent = nullptr);
|
|
||||||
|
|
||||||
bool StartSearch(const QString &artist, const QString &album, const QString &title, const quint64 id);
|
|
||||||
void CancelSearch(quint64 id);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void HandleSearchReply(QNetworkReply *reply, const quint64 id, const QString &artist, const QString &title);
|
|
||||||
|
|
||||||
private:
|
|
||||||
static const char *kUrlSearch;
|
|
||||||
static const int kMaxLength;
|
|
||||||
QNetworkAccessManager *network_;
|
|
||||||
void Error(const quint64 id, const QString &error, QVariant debug = QVariant());
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CHARTLYRICSPROVIDER_H
|
|
Loading…
Reference in New Issue