From c992768efe560477b92ee739a4d722818405ff52 Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Sat, 3 Aug 2019 13:08:14 +0200 Subject: [PATCH] Remove ChartLyrics (service is down) --- Changelog | 1 + README.md | 2 +- debian/control | 2 +- dist/man/strawberry.1 | 2 +- dist/rpm/strawberry.spec.in | 2 +- src/CMakeLists.txt | 2 - src/core/application.cpp | 2 - src/lyrics/chartlyricsprovider.cpp | 135 ----------------------------- src/lyrics/chartlyricsprovider.h | 56 ------------ 9 files changed, 5 insertions(+), 199 deletions(-) delete mode 100644 src/lyrics/chartlyricsprovider.cpp delete mode 100644 src/lyrics/chartlyricsprovider.h diff --git a/Changelog b/Changelog index 1f87b6150..4ced20740 100644 --- a/Changelog +++ b/Changelog @@ -46,6 +46,7 @@ Unreleased: * Replaced FTS3 and custom tokenizer with FTS5 with unicode61. * Fixed certain cases where track slider popup was stuck. * Fixed certain cases where the playing widget gets stuck when switching fast between context and other widgets. + * Removed ChartLyrics provider (service have been down for a long time). Version 0.5.5: diff --git a/README.md b/README.md index d62bd19c4..c7cde7064 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Strawberry is a music player and music collection organizer. It is a fork of Cle * Edit tags on music files * Fetch tags from MusicBrainz * Album cover art from Last.fm, Musicbrainz, Discogs, Deezer and Tidal - * Song lyrics from AudD and ChartLyrics + * Song lyrics from AudD * Support for multiple backends * Audio analyzer * Audio equalizer diff --git a/debian/control b/debian/control index 796400e14..2ebd30e76 100644 --- a/debian/control +++ b/debian/control @@ -58,7 +58,7 @@ Description: Audio player and music collection organizer - Edit tags on music files - Fetch tags from MusicBrainz - Album cover art from Lastfm, Musicbrainz, Discogs, Deezer and Tidal - - Song lyrics from AudD and ChartLyrics + - Song lyrics from AudD - Support for multiple backends - Audio analyzer - Audio equalizer diff --git a/dist/man/strawberry.1 b/dist/man/strawberry.1 index 0010b01e8..c16ca924b 100644 --- a/dist/man/strawberry.1 +++ b/dist/man/strawberry.1 @@ -27,7 +27,7 @@ Features: .br - Album cover art from Lastfm, Musicbrainz, Discogs, Deezer and Tidal .br -- Song lyrics from AudD and ChartLyrics +- Song lyrics from AudD .br - Support for multiple backends .br diff --git a/dist/rpm/strawberry.spec.in b/dist/rpm/strawberry.spec.in index 697246385..7250df01d 100644 --- a/dist/rpm/strawberry.spec.in +++ b/dist/rpm/strawberry.spec.in @@ -101,7 +101,7 @@ Features: - Edit tags on music files - Fetch tags from MusicBrainz - Album cover art from Last.fm, Musicbrainz, Discogs, Deezer and Tidal - - Song lyrics from AudD and ChartLyrics + - Song lyrics from AudD - Support for multiple backends - Audio analyzer - Audio equalizer diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 54f443e23..5a3bff843 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -208,7 +208,6 @@ set(SOURCES lyrics/lyricsfetcher.cpp lyrics/lyricsfetchersearch.cpp lyrics/auddlyricsprovider.cpp - lyrics/chartlyricsprovider.cpp settings/settingsdialog.cpp settings/settingspage.cpp @@ -390,7 +389,6 @@ set(HEADERS lyrics/lyricsfetcher.h lyrics/lyricsfetchersearch.h lyrics/auddlyricsprovider.h - lyrics/chartlyricsprovider.h settings/settingsdialog.h settings/settingspage.h diff --git a/src/core/application.cpp b/src/core/application.cpp index 19c9f4d96..09969009e 100644 --- a/src/core/application.cpp +++ b/src/core/application.cpp @@ -59,7 +59,6 @@ #include "lyrics/lyricsproviders.h" #include "lyrics/lyricsprovider.h" #include "lyrics/auddlyricsprovider.h" -#include "lyrics/chartlyricsprovider.h" #include "scrobbler/audioscrobbler.h" @@ -136,7 +135,6 @@ class ApplicationImpl { lyrics_providers_([=]() { LyricsProviders *lyrics_providers = new LyricsProviders(app); lyrics_providers->AddProvider(new AuddLyricsProvider(app)); - lyrics_providers->AddProvider(new ChartLyricsProvider(app)); return lyrics_providers; }), internet_services_([=]() { diff --git a/src/lyrics/chartlyricsprovider.cpp b/src/lyrics/chartlyricsprovider.cpp deleted file mode 100644 index 684b22469..000000000 --- a/src/lyrics/chartlyricsprovider.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Strawberry Music Player - * Copyright 2018, Jonas Kvinge - * - * 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 . - * - */ - -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#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 &album, 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 id) { -} - -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.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()); -} diff --git a/src/lyrics/chartlyricsprovider.h b/src/lyrics/chartlyricsprovider.h deleted file mode 100644 index 65a4c0436..000000000 --- a/src/lyrics/chartlyricsprovider.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Strawberry Music Player - * Copyright 2018, Jonas Kvinge - * - * 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 . - * - */ - -#ifndef CHARTLYRICSPROVIDER_H -#define CHARTLYRICSPROVIDER_H - -#include "config.h" - -#include - -#include -#include -#include -#include -#include - -#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