From 6ed5190276753e846c16b2afb87c6f836cecfe66 Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Sun, 25 Jun 2023 01:14:12 +0200 Subject: [PATCH] Remove AudD lyrics --- README.md | 2 +- debian/control.in | 2 +- ...rawberrymusicplayer.strawberry.appdata.xml | 2 +- dist/unix/strawberry.1 | 2 +- dist/unix/strawberry.spec.in | 2 +- src/CMakeLists.txt | 2 - src/core/application.cpp | 2 - src/lyrics/auddlyricsprovider.cpp | 178 ------------------ src/lyrics/auddlyricsprovider.h | 62 ------ 9 files changed, 5 insertions(+), 249 deletions(-) delete mode 100644 src/lyrics/auddlyricsprovider.cpp delete mode 100644 src/lyrics/auddlyricsprovider.h diff --git a/README.md b/README.md index cd8793a2..1d1a72bd 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Funding developers is a way to contribute to open source projects you appreciate * Edit tags on audio files * Fetch tags from MusicBrainz * Album cover art from [Last.fm](https://www.last.fm/), [Musicbrainz](https://musicbrainz.org/), [Discogs](https://www.discogs.com/), [Musixmatch](https://www.musixmatch.com/), [Deezer](https://www.deezer.com/), [Tidal](https://www.tidal.com/), [Qobuz](https://www.qobuz.com/) and [Spotify](https://www.spotify.com/) - * Song lyrics from [Lyrics.com](https://www.lyrics.com/), [AudD](https://audd.io/), [Genius](https://genius.com/), [Musixmatch](https://www.musixmatch.com/), [ChartLyrics](http://www.chartlyrics.com/), [lyrics.ovh](https://lyrics.ovh/) and [lololyrics.com](https://www.lololyrics.com/) + * Song lyrics from [Lyrics.com](https://www.lyrics.com/), [Genius](https://genius.com/), [Musixmatch](https://www.musixmatch.com/), [ChartLyrics](http://www.chartlyrics.com/), [lyrics.ovh](https://lyrics.ovh/) and [lololyrics.com](https://www.lololyrics.com/) * Support for multiple backends * Audio analyzer * Audio equalizer diff --git a/debian/control.in b/debian/control.in index b6999554..d33467c1 100644 --- a/debian/control.in +++ b/debian/control.in @@ -53,7 +53,7 @@ Description: music player and music collection organizer - Edit tags on audio files - Automatically retrieve tags from MusicBrainz - Album cover art from Last.fm, Musicbrainz, Discogs, Musixmatch, Deezer, Tidal, Qobuz and Spotify - - Song lyrics from Lyrics.com, AudD, Genius, Musixmatch, ChartLyrics, lyrics.ovh and lololyrics.com + - Song lyrics from Lyrics.com, Genius, Musixmatch, ChartLyrics, lyrics.ovh and lololyrics.com - Audio analyzer - Audio equalizer - Transfer music to mass-storage USB players, MTP compatible devices and iPod Nano/Classic diff --git a/dist/unix/org.strawberrymusicplayer.strawberry.appdata.xml b/dist/unix/org.strawberrymusicplayer.strawberry.appdata.xml index 103b0c85..082d48d8 100644 --- a/dist/unix/org.strawberrymusicplayer.strawberry.appdata.xml +++ b/dist/unix/org.strawberrymusicplayer.strawberry.appdata.xml @@ -29,7 +29,7 @@
  • Edit tags on audio files
  • Automatically retrieve tags from MusicBrainz
  • Album cover art from Last.fm, Musicbrainz, Discogs, Musixmatch, Deezer, Tidal, Qobuz and Spotify
  • -
  • Song lyrics from Lyrics.com, AudD, Genius, Musixmatch, ChartLyrics, lyrics.ovh and lololyrics.com
  • +
  • Song lyrics from Lyrics.com, Genius, Musixmatch, ChartLyrics, lyrics.ovh and lololyrics.com
  • Support for multiple backends
  • Audio analyzer and equalizer
  • Transfer music to mass-storage USB players, MTP compatible devices and iPod Nano/Classic
  • diff --git a/dist/unix/strawberry.1 b/dist/unix/strawberry.1 index 4072717b..c7cc71a5 100644 --- a/dist/unix/strawberry.1 +++ b/dist/unix/strawberry.1 @@ -29,7 +29,7 @@ Features: .br - Album cover art from Last.fm, Musicbrainz, Discogs, Musixmatch, Deezer, Tidal, Qobuz and Spotify .br -- Song lyrics from Lyrics.com, AudD, Genius, Musixmatch, ChartLyrics, lyrics.ovh and lololyrics.com +- Song lyrics from Lyrics.com, Genius, Musixmatch, ChartLyrics, lyrics.ovh and lololyrics.com .br - Support for multiple backends .br diff --git a/dist/unix/strawberry.spec.in b/dist/unix/strawberry.spec.in index d6b22e9a..e0c9003e 100644 --- a/dist/unix/strawberry.spec.in +++ b/dist/unix/strawberry.spec.in @@ -119,7 +119,7 @@ Features: - Edit tags on audio files - Automatically retrieve tags from MusicBrainz - Album cover art from Last.fm, Musicbrainz, Discogs, Musixmatch, Deezer, Tidal, Qobuz and Spotify - - Song lyrics from Lyrics.com, AudD, Genius, Musixmatch, ChartLyrics, lyrics.ovh and lololyrics.com + - Song lyrics from Lyrics.com, Genius, Musixmatch, ChartLyrics, lyrics.ovh and lololyrics.com - Support for multiple backends - Audio analyzer - Audio equalizer diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e5ac69e6..6edcee84 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -177,7 +177,6 @@ set(SOURCES lyrics/lyricsfetcher.cpp lyrics/lyricsfetchersearch.cpp lyrics/jsonlyricsprovider.cpp - lyrics/auddlyricsprovider.cpp lyrics/ovhlyricsprovider.cpp lyrics/lololyricsprovider.cpp lyrics/geniuslyricsprovider.cpp @@ -415,7 +414,6 @@ set(HEADERS lyrics/lyricsfetcher.h lyrics/lyricsfetchersearch.h lyrics/jsonlyricsprovider.h - lyrics/auddlyricsprovider.h lyrics/ovhlyricsprovider.h lyrics/lololyricsprovider.h lyrics/geniuslyricsprovider.h diff --git a/src/core/application.cpp b/src/core/application.cpp index 53c86488..9feb7d18 100644 --- a/src/core/application.cpp +++ b/src/core/application.cpp @@ -58,7 +58,6 @@ #include "covermanager/spotifycoverprovider.h" #include "lyrics/lyricsproviders.h" -#include "lyrics/auddlyricsprovider.h" #include "lyrics/geniuslyricsprovider.h" #include "lyrics/ovhlyricsprovider.h" #include "lyrics/lololyricsprovider.h" @@ -157,7 +156,6 @@ class ApplicationImpl { lyrics_providers_([app]() { LyricsProviders *lyrics_providers = new LyricsProviders(app); // Initialize the repository of lyrics providers. - lyrics_providers->AddProvider(new AuddLyricsProvider(app->network(), app)); lyrics_providers->AddProvider(new GeniusLyricsProvider(app->network(), app)); lyrics_providers->AddProvider(new OVHLyricsProvider(app->network(), app)); lyrics_providers->AddProvider(new LoloLyricsProvider(app->network(), app)); diff --git a/src/lyrics/auddlyricsprovider.cpp b/src/lyrics/auddlyricsprovider.cpp deleted file mode 100644 index fcec345d..00000000 --- a/src/lyrics/auddlyricsprovider.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Strawberry Music Player - * Copyright 2018-2023, 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 "core/logging.h" -#include "core/networkaccessmanager.h" -#include "utilities/strutils.h" -#include "lyricssearchrequest.h" -#include "lyricssearchresult.h" -#include "auddlyricsprovider.h" - -const char *AuddLyricsProvider::kUrlSearch = "https://api.audd.io/findLyrics/"; -const int AuddLyricsProvider::kMaxLength = 6000; - -AuddLyricsProvider::AuddLyricsProvider(NetworkAccessManager *network, QObject *parent) : JsonLyricsProvider("AudD", false, false, network, parent) {} - -AuddLyricsProvider::~AuddLyricsProvider() { - - while (!replies_.isEmpty()) { - QNetworkReply *reply = replies_.takeFirst(); - QObject::disconnect(reply, nullptr, this, nullptr); - reply->abort(); - reply->deleteLater(); - } - -} - -bool AuddLyricsProvider::StartSearch(const int id, const LyricsSearchRequest &request) { - - QUrl url(kUrlSearch); - QUrlQuery url_query; - url_query.addQueryItem("q", QUrl::toPercentEncoding(QString(request.artist + " " + request.title))); - url.setQuery(url_query); - QNetworkRequest req(url); - req.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy); - QNetworkReply *reply = network_->get(req); - replies_ << reply; - QObject::connect(reply, &QNetworkReply::finished, this, [this, reply, id, request]() { HandleSearchReply(reply, id, request); }); - - return true; - -} - -void AuddLyricsProvider::CancelSearch(const int id) { Q_UNUSED(id); } - -void AuddLyricsProvider::HandleSearchReply(QNetworkReply *reply, const int id, const LyricsSearchRequest &request) { - - if (!replies_.contains(reply)) return; - replies_.removeAll(reply); - QObject::disconnect(reply, nullptr, this, nullptr); - reply->deleteLater(); - - const QByteArray data = ExtractData(reply); - if (data.isEmpty()) { - emit SearchFinished(id); - return; - } - - QJsonArray json_result = ExtractResult(data); - if (json_result.isEmpty()) { - qLog(Debug) << "AudDLyrics: No lyrics for" << request.artist << request.title; - emit SearchFinished(id); - return; - } - - LyricsSearchResults results; - for (const QJsonValueRef value : json_result) { - if (!value.isObject()) { - qLog(Error) << "AudDLyrics: Invalid Json reply, result is not an object."; - qLog(Debug) << value; - continue; - } - QJsonObject json_obj = value.toObject(); - if ( - !json_obj.contains("song_id") || - !json_obj.contains("artist_id") || - !json_obj.contains("title") || - !json_obj.contains("artist") || - !json_obj.contains("lyrics") - ) { - qLog(Error) << "AudDLyrics: Invalid Json reply, result is missing data."; - qLog(Debug) << value; - continue; - } - LyricsSearchResult result; - result.artist = json_obj["artist"].toString(); - result.title = json_obj["title"].toString(); - if (result.artist.compare(request.albumartist, Qt::CaseInsensitive) != 0 && - result.artist.compare(request.artist, Qt::CaseInsensitive) != 0 && - result.title.compare(request.title, Qt::CaseInsensitive) != 0) { - continue; - } - result.lyrics = json_obj["lyrics"].toString(); - if (result.lyrics.isEmpty() || result.lyrics.length() > kMaxLength || result.lyrics == "error") continue; - result.lyrics = Utilities::DecodeHtmlEntities(result.lyrics); - results << result; - } - - if (results.isEmpty()) { - qLog(Debug) << "AudDLyrics: No lyrics for" << request.artist << request.title; - } - else { - qLog(Debug) << "AudDLyrics: Got lyrics for" << request.artist << request.title; - } - - emit SearchFinished(id, results); - -} - -QJsonArray AuddLyricsProvider::ExtractResult(const QByteArray &data) { - - QJsonObject json_obj = ExtractJsonObj(data); - if (json_obj.isEmpty()) return QJsonArray(); - - if (!json_obj.contains("status")) { - Error("Json reply is missing status.", json_obj); - return QJsonArray(); - } - - if (json_obj["status"].toString() == "error") { - if (!json_obj.contains("error")) { - Error("Json reply is missing error status.", json_obj); - return QJsonArray(); - } - QJsonObject json_error = json_obj["error"].toObject(); - if (!json_error.contains("error_code") || !json_error.contains("error_message")) { - Error("Json reply is missing error code or message.", json_error); - return QJsonArray(); - } - QString error_message = json_error["error_message"].toString(); - Error(error_message); - return QJsonArray(); - } - - if (!json_obj.contains("result") || !json_obj["result"].isArray()) { - Error("Json reply is missing result array.", json_obj); - return QJsonArray(); - } - - return json_obj["result"].toArray(); - -} - -void AuddLyricsProvider::Error(const QString &error, const QVariant &debug) { - - qLog(Error) << "AudDLyrics:" << error; - if (debug.isValid()) qLog(Debug) << debug; - -} diff --git a/src/lyrics/auddlyricsprovider.h b/src/lyrics/auddlyricsprovider.h deleted file mode 100644 index 8162a8a0..00000000 --- a/src/lyrics/auddlyricsprovider.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Strawberry Music Player - * Copyright 2018-2023, 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 AUDDLYRICSPROVIDER_H -#define AUDDLYRICSPROVIDER_H - -#include "config.h" - -#include -#include -#include -#include -#include -#include - -#include "jsonlyricsprovider.h" -#include "lyricsfetcher.h" - -class QNetworkReply; -class NetworkAccessManager; - -class AuddLyricsProvider : public JsonLyricsProvider { - Q_OBJECT - - public: - explicit AuddLyricsProvider(NetworkAccessManager *network, QObject *parent = nullptr); - ~AuddLyricsProvider() override; - - bool StartSearch(const int id, const LyricsSearchRequest &request) override; - void CancelSearch(const int id) override; - - private: - void Error(const QString &error, const QVariant &debug = QVariant()) override; - QJsonArray ExtractResult(const QByteArray &data); - - private slots: - void HandleSearchReply(QNetworkReply *reply, const int id, const LyricsSearchRequest &request); - - private: - static const char *kUrlSearch; - static const int kMaxLength; - QList replies_; - -}; - -#endif // AUDDLYRICSPROVIDER_H