Remove api seeds lyrics (requires payment)

This commit is contained in:
Jonas Kvinge 2019-03-28 02:24:05 +01:00
parent 9fd5c5fc1c
commit 67d01f48a3
12 changed files with 18 additions and 297 deletions

View File

@ -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

4
dist/debian/control vendored
View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -9,13 +9,13 @@
<binary>strawberry-tagreader</binary>
</provides>
<name>Strawberry Music Player</name>
<summary>An audio player and music collection organizer</summary>
<summary>A music player and collection organizer</summary>
<url type="homepage">https://www.strawbs.org/</url>
<url type="bugtracker">https://github.com/jonaski/strawberry/</url>
<translation type="qt">strawberry</translation>
<description>
<p>
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.
</p>
<p>Features:</p>
@ -29,7 +29,7 @@
<li>Edit tags on music files</li>
<li>Fetch tags from MusicBrainz</li>
<li>Album cover art from Last.fm, Musicbrainz and Discogs</li>
<li>Song lyrics from AudD and API Seeds</li>
<li>Song lyrics from AudD</li>
<li>Support for multiple backends</li>
<li>Audio analyzer</li>
<li>Audio equalizer</li>

View File

@ -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

View File

@ -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

View File

@ -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_([=]() {

View File

@ -102,7 +102,7 @@ QString About::MainHtml() const {
ret = tr("<p>Version %1</p>").arg(QCoreApplication::applicationVersion());
ret += "<p>";
ret += tr("Strawberry is a audio player and music collection organizer.<br />");
ret += tr("Strawberry is a music player and music collection organizer.<br />");
ret += tr("It is a fork of Clementine released in 2018 aimed at music collectors, audio enthusiasts and audiophiles.<br />");
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 += "</p>";

View File

@ -1,213 +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 <QtGlobal>
#include <QObject>
#include <QByteArray>
#include <QList>
#include <QPair>
#include <QMap>
#include <QSet>
#include <QVariant>
#include <QString>
#include <QStringBuilder>
#include <QStringList>
#include <QUrl>
#include <QUrlQuery>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QJsonValue>
#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<QString, QString> Arg;
typedef QList<Arg> ArgList;
typedef QPair<QByteArray, QByteArray> 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);
}

View File

@ -1,62 +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 APISEEDSLYRICSPROVIDER_H
#define APISEEDSLYRICSPROVIDER_H
#include "config.h"
#include <stdbool.h>
#include <QtGlobal>
#include <QObject>
#include <QHash>
#include <QMetaType>
#include <QString>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#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