From 67d01f48a35b4c5ca653d4cb8940ae27f12ea399 Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Thu, 28 Mar 2019 02:24:05 +0100 Subject: [PATCH] Remove api seeds lyrics (requires payment) --- README.md | 4 +- dist/debian/control | 4 +- dist/fedora/strawberry.spec.in | 6 +- dist/man/strawberry.1 | 6 +- dist/opensuse/strawberry.spec.in | 6 +- dist/unix/org.strawbs.strawberry.appdata.xml | 6 +- snap/snapcraft.yaml | 2 +- src/CMakeLists.txt | 2 - src/core/application.cpp | 2 - src/dialogs/about.cpp | 2 +- src/lyrics/apiseedslyricsprovider.cpp | 213 ------------------- src/lyrics/apiseedslyricsprovider.h | 62 ------ 12 files changed, 18 insertions(+), 297 deletions(-) delete mode 100644 src/lyrics/apiseedslyricsprovider.cpp delete mode 100644 src/lyrics/apiseedslyricsprovider.h diff --git a/README.md b/README.md index 599dbf8e3..1166b87c1 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FRJUYV5QP6HW8) ======================= -Strawberry is a audio player and music collection organizer. It is a fork of Clementine released in 2018 aimed at music collectors, audio enthusiasts and audiophiles. The name is inspired by the band Strawbs. It's based on a heavily modified version of Clementine created in 2012-2013. It's written in C++ and Qt 5. +Strawberry is a music player and music collection organizer. It is a fork of Clementine released in 2018 aimed at music collectors, audio enthusiasts and audiophiles. The name is inspired by the band Strawbs. It's based on a heavily modified version of Clementine created in 2012-2013. It's written in C++ and Qt 5. * Website: https://www.strawbs.org/ * Github: https://github.com/jonaski/strawberry @@ -20,7 +20,7 @@ Strawberry is a audio 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 and Discogs - * Song lyrics from AudD and API Seeds + * Song lyrics from AudD * Support for multiple backends * Audio analyzer * Audio equalizer diff --git a/dist/debian/control b/dist/debian/control index 4e2cdd66f..7ba53c6ef 100644 --- a/dist/debian/control +++ b/dist/debian/control @@ -47,7 +47,7 @@ Depends: ${shlibs:Depends}, gstreamer1.0-pulseaudio Homepage: http://www.strawbs.org/ Description: Audio player and music collection organizer - Strawberry is a audio player aimed at music collectors, audio enthusiasts and audiophiles. + Strawberry is a music player aimed at music collectors, audio enthusiasts and audiophiles. . Features: - Play and organize music @@ -59,7 +59,7 @@ Description: Audio player and music collection organizer - Edit tags on music files - Fetch tags from MusicBrainz - Album cover art from Lastfm, Musicbrainz and Discogs - - Song lyrics from AudD and API Seeds + - Song lyrics from AudD - Support for multiple backends - Audio analyzer - Audio equalizer diff --git a/dist/fedora/strawberry.spec.in b/dist/fedora/strawberry.spec.in index 65be437f6..f74678e73 100644 --- a/dist/fedora/strawberry.spec.in +++ b/dist/fedora/strawberry.spec.in @@ -1,7 +1,7 @@ Name: strawberry Version: @STRAWBERRY_VERSION_RPM_V@ Release: @STRAWBERRY_VERSION_RPM_R@.@RPM_DISTRO@ -Summary: A audio player and music collection organiser +Summary: A music player and collection organiser Group: Applications/Multimedia License: GPLv3+ URL: http://www.strawbs.org/ @@ -49,7 +49,7 @@ BuildRequires: pkgconfig(libnotify) BuildRequires: pkgconfig(libudf) %description -Strawberry is a audio player and music collection organizer. +Strawberry is a music player and collection organizer. It is a fork of Clementine. The name is inspired by the band Strawbs. Features: @@ -62,7 +62,7 @@ Features: * Edit tags on music files * Fetch tags from MusicBrainz * Album cover art from Last.fm, Musicbrainz and Discogs - * Song lyrics from AudD and API Seeds + * 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 616e21765..a91960a82 100644 --- a/dist/man/strawberry.1 +++ b/dist/man/strawberry.1 @@ -1,11 +1,11 @@ .TH STRAWBERRY "1" "User Commands" .SH NAME -Strawberry \- audio player and music collection organizer +Strawberry \- music player and music collection organizer .SH SYNOPSIS .B strawberry [\fI\,options\/\fR] [\fI\,URL(s)\/\fR] .SH DESCRIPTION -Strawberry is a audio player especially aimed at audiophiles. +Strawberry is a music player especially aimed at audiophiles. .TP Features: .br @@ -27,7 +27,7 @@ Features: .br - Album cover art from Lastfm, Musicbrainz and Discogs .br -- Song lyrics from AudD and API Seeds +- Song lyrics from AudD .br - Support for multiple backends .br diff --git a/dist/opensuse/strawberry.spec.in b/dist/opensuse/strawberry.spec.in index a5e0b15df..c7d7d6c97 100644 --- a/dist/opensuse/strawberry.spec.in +++ b/dist/opensuse/strawberry.spec.in @@ -1,7 +1,7 @@ Name: strawberry Version: @STRAWBERRY_VERSION_RPM_V@ Release: @STRAWBERRY_VERSION_RPM_R@.@RPM_DISTRO@ -Summary: A audio player and music collection organiser +Summary: A music player and collection organiser Group: Applications/Multimedia License: GPL-3.0+ URL: http://www.strawbs.org/ @@ -59,7 +59,7 @@ BuildRequires: pkgconfig(libvlc) Requires: libQt5Sql5-sqlite %description -Strawberry is a audio player and music collection organizer. +Strawberry is a music player and collection organizer. It is a fork of Clementine. The name is inspired by the band Strawbs. Features: @@ -72,7 +72,7 @@ Features: * Edit tags on music files * Fetch tags from MusicBrainz * Album cover art from Last.fm, Musicbrainz and Discogs - * Song lyrics from AudD and API Seeds + * Song lyrics from AudD * Support for multiple backends * Audio analyzer * Audio equalizer diff --git a/dist/unix/org.strawbs.strawberry.appdata.xml b/dist/unix/org.strawbs.strawberry.appdata.xml index 92eb17c1e..d67ab7cf3 100644 --- a/dist/unix/org.strawbs.strawberry.appdata.xml +++ b/dist/unix/org.strawbs.strawberry.appdata.xml @@ -9,13 +9,13 @@ strawberry-tagreader Strawberry Music Player - An audio player and music collection organizer + A music player and collection organizer https://www.strawbs.org/ https://github.com/jonaski/strawberry/strawberry

- Strawberry is a audio player and music collection organizer. + Strawberry is a music player and music collection organizer. It is a fork of Clementine. The name is inspired by the band Strawbs.

Features:

@@ -29,7 +29,7 @@
  • Edit tags on music files
  • Fetch tags from MusicBrainz
  • Album cover art from Last.fm, Musicbrainz and Discogs
  • -
  • Song lyrics from AudD and API Seeds
  • +
  • Song lyrics from AudD
  • Support for multiple backends
  • Audio analyzer
  • Audio equalizer
  • diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 2582a9823..36a333ba0 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -2,7 +2,7 @@ name: strawberry version: '0.5.2+git' summary: music player and collection organizer description: | - Strawberry is a audio player and music collection organizer. + Strawberry is a music player and collection organizer. It is a fork of Clementine released in 2018 aimed at music collectors, audio enthusiasts and audiophiles diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a05a838c3..680aeb0c8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -204,7 +204,6 @@ set(SOURCES lyrics/lyricsfetcher.cpp lyrics/lyricsfetchersearch.cpp lyrics/auddlyricsprovider.cpp - lyrics/apiseedslyricsprovider.cpp settings/settingsdialog.cpp settings/settingspage.cpp @@ -380,7 +379,6 @@ set(HEADERS lyrics/lyricsfetcher.h lyrics/lyricsfetchersearch.h lyrics/auddlyricsprovider.h - lyrics/apiseedslyricsprovider.h settings/settingsdialog.h settings/settingspage.h diff --git a/src/core/application.cpp b/src/core/application.cpp index eae7f405e..56338345a 100644 --- a/src/core/application.cpp +++ b/src/core/application.cpp @@ -58,7 +58,6 @@ #include "lyrics/lyricsproviders.h" #include "lyrics/lyricsprovider.h" #include "lyrics/auddlyricsprovider.h" -#include "lyrics/apiseedslyricsprovider.h" #include "internet/internetservices.h" #include "internet/internetsearch.h" @@ -117,7 +116,6 @@ class ApplicationImpl { lyrics_providers_([=]() { LyricsProviders *lyrics_providers = new LyricsProviders(app); lyrics_providers->AddProvider(new AuddLyricsProvider(app)); - lyrics_providers->AddProvider(new APISeedsLyricsProvider(app)); return lyrics_providers; }), internet_services_([=]() { diff --git a/src/dialogs/about.cpp b/src/dialogs/about.cpp index 24ee98722..6cf49f8dc 100644 --- a/src/dialogs/about.cpp +++ b/src/dialogs/about.cpp @@ -102,7 +102,7 @@ QString About::MainHtml() const { ret = tr("

    Version %1

    ").arg(QCoreApplication::applicationVersion()); ret += "

    "; - ret += tr("Strawberry is a audio player and music collection organizer.
    "); + ret += tr("Strawberry is a music player and music collection organizer.
    "); ret += tr("It is a fork of Clementine released in 2018 aimed at music collectors, audio enthusiasts and audiophiles.
    "); ret += tr("The name is inspired by the band Strawbs. It's based on a heavily modified version of Clementine created in 2012-2013. It's written in C++ and Qt 5."); ret += "

    "; diff --git a/src/lyrics/apiseedslyricsprovider.cpp b/src/lyrics/apiseedslyricsprovider.cpp deleted file mode 100644 index b2c4925f5..000000000 --- a/src/lyrics/apiseedslyricsprovider.cpp +++ /dev/null @@ -1,213 +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 -#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 "apiseedslyricsprovider.h" - -const char *APISeedsLyricsProvider::kUrlSearch = "https://orion.apiseeds.com/api/music/lyric"; -const char *APISeedsLyricsProvider::kAPIKeyB64 = "REdWenJhR245Qm03cnE5NlhoS1pTd0V5UVNCNjBtTWVEZlp0ZEttVXhKZTRRdnZSbTRYcmlaUVlaMlM3c0JQUw=="; - -APISeedsLyricsProvider::APISeedsLyricsProvider(QObject *parent) : LyricsProvider("APISeeds", parent), network_(new NetworkAccessManager(this)) {} - -bool APISeedsLyricsProvider::StartSearch(const QString &artist, const QString &album, const QString &title, quint64 id) { - - typedef QPair Arg; - typedef QList ArgList; - typedef QPair EncodedArg; - - ArgList args = ArgList(); - args.append(Arg("apikey", QByteArray::fromBase64(kAPIKeyB64))); - - QUrlQuery url_query; - for (const Arg &arg : args) { - EncodedArg encoded_arg(QUrl::toPercentEncoding(arg.first), QUrl::toPercentEncoding(arg.second)); - url_query.addQueryItem(encoded_arg.first, encoded_arg.second); - } - - QUrl url(QString("%1/%2/%3").arg(kUrlSearch).arg(QString::fromLatin1(QUrl::toPercentEncoding(artist))).arg(QString::fromLatin1(QUrl::toPercentEncoding(title)))); - url.setQuery(url_query); - QNetworkReply *reply = network_->get(QNetworkRequest(url)); - NewClosure(reply, SIGNAL(finished()), this, SLOT(HandleSearchReply(QNetworkReply*, quint64, QString, QString)), reply, id, artist, title); - - //qLog(Debug) << "APISeeds Lyrics: Sending request for" << url; - - return true; - -} - -void APISeedsLyricsProvider::CancelSearch(quint64 id) { -} - -void APISeedsLyricsProvider::HandleSearchReply(QNetworkReply *reply, quint64 id, const QString artist, const QString title) { - - reply->deleteLater(); - - QJsonObject json_obj = ExtractResult(reply, id); - if (json_obj.isEmpty()) return; - - if (!json_obj.contains("artist") || !json_obj.contains("track")) { - Error(id, "APISeeds Lyrics: Invalid Json reply, result is missing artist or track.", json_obj); - return; - } - QJsonObject json_artist(json_obj["artist"].toObject()); - QJsonObject json_track(json_obj["track"].toObject()); - if (!json_track.contains("text")) { - Error(id, "APISeeds Lyrics: Invalid Json reply, track is missing text.", json_obj); - return; - } - - LyricsSearchResults results; - LyricsSearchResult result; - result.artist = json_artist["name"].toString(); - result.title = json_track["name"].toString(); - result.lyrics = json_track["text"].toString(); - result.score = 0.0; - if (result.artist.toLower() == artist.toLower()) result.score += 1.0; - if (result.title.toLower() == title.toLower()) result.score += 1.0; - - //qLog(Debug) << "APISeeds Lyrics:" << result.artist << result.title << result.lyrics; - - results << result; - - emit SearchFinished(id, results); - -} - -QJsonObject APISeedsLyricsProvider::ExtractJsonObj(QNetworkReply *reply, quint64 id) { - - QByteArray data; - - if (reply->error() == QNetworkReply::NoError) { - data = reply->readAll(); - } - else { - QString failure_reason; - if (reply->error() < 200) { - QString failure_reason = QString("%1 (%2)").arg(reply->errorString()).arg(reply->error()); - } - else { - // See if there is JSON data containing "error" - then use that instead. - data = reply->readAll(); - QJsonParseError error; - QJsonDocument json_doc = QJsonDocument::fromJson(data, &error); - if (error.error == QJsonParseError::NoError && !json_doc.isNull() && !json_doc.isEmpty() && json_doc.isObject()) { - QJsonObject json_obj = json_doc.object(); - if (!json_obj.isEmpty() && json_obj.contains("error")) { - failure_reason = json_obj["error"].toString(); - // Don't bother showing error when there was no match. - if (failure_reason == "Lyric no found, try again later.") failure_reason.clear(); - } - else { - failure_reason = QString("%1 (%2)").arg(reply->errorString()).arg(reply->error()); - } - } - else { - failure_reason = QString("%1 (%2)").arg(reply->errorString()).arg(reply->error()); - } - } - Error(id, failure_reason); - return QJsonObject(); - } - - QJsonParseError error; - QJsonDocument json_doc = QJsonDocument::fromJson(data, &error); - - if (error.error != QJsonParseError::NoError) { - Error(id, "Reply from server missing Json data."); - return QJsonObject(); - } - - if (json_doc.isNull() || json_doc.isEmpty()) { - Error(id, "Received empty Json document."); - return QJsonObject(); - } - - if (!json_doc.isObject()) { - Error(id, "Json document is not an object."); - return QJsonObject(); - } - - QJsonObject json_obj = json_doc.object(); - if (json_obj.isEmpty()) { - Error(id, "Received empty Json object."); - return QJsonObject(); - } - - return json_obj; - -} - -QJsonObject APISeedsLyricsProvider::ExtractResult(QNetworkReply *reply, quint64 id) { - - QJsonObject json_obj = ExtractJsonObj(reply, id); - if (json_obj.isEmpty()) return QJsonObject(); - - if (json_obj.contains("error")) { - Error(id, json_obj["error"].toString(), json_obj); - return QJsonObject(); - } - - if (!json_obj.contains("result")) { - Error(id, "Json reply is missing result.", json_obj); - return QJsonObject(); - } - - QJsonObject json_result = json_obj["result"].toObject(); - if (json_result.isEmpty()) { - Error(id, "Json result object is empty."); - return QJsonObject(); - } - return json_result; - -} - -void APISeedsLyricsProvider::Error(quint64 id, QString error, QVariant debug) { - LyricsSearchResults results; - if (!error.isEmpty()) qLog(Error) << "APISeeds Lyrics:" << error; - if (debug.isValid()) qLog(Debug) << debug; - emit SearchFinished(id, results); -} diff --git a/src/lyrics/apiseedslyricsprovider.h b/src/lyrics/apiseedslyricsprovider.h deleted file mode 100644 index bdbdcae6c..000000000 --- a/src/lyrics/apiseedslyricsprovider.h +++ /dev/null @@ -1,62 +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 APISEEDSLYRICSPROVIDER_H -#define APISEEDSLYRICSPROVIDER_H - -#include "config.h" - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "lyricsprovider.h" -#include "lyricsfetcher.h" - -class APISeedsLyricsProvider : public LyricsProvider { - Q_OBJECT - - public: - explicit APISeedsLyricsProvider(QObject *parent = nullptr); - - bool StartSearch(const QString &artist, const QString &album, const QString &title, quint64 id); - void CancelSearch(quint64 id); - - private slots: - void HandleSearchReply(QNetworkReply *reply, quint64 id, const QString artist, const QString title); - - private: - static const char *kUrlSearch; - static const char *kAPIKeyB64; - QNetworkAccessManager *network_; - void Error(quint64 id, QString error, QVariant debug = QVariant()); - - QJsonObject ExtractJsonObj(QNetworkReply *reply, quint64 id); - QJsonObject ExtractResult(QNetworkReply *reply, quint64 id); - -}; - -#endif // APISEEDSLYRICSPROVIDER_H -