Add ChartLyrics provider
This commit is contained in:
@@ -343,7 +343,7 @@ optional_component(TRANSLATIONS ON "Translations"
|
|||||||
DEPENDS "Qt5LinguistTools" Qt5LinguistTools_FOUND
|
DEPENDS "Qt5LinguistTools" Qt5LinguistTools_FOUND
|
||||||
)
|
)
|
||||||
|
|
||||||
optional_component(STREAM_TIDAL ON "Streaming: Tidal support")
|
optional_component(TIDAL ON "Tidal support")
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
option(USE_BUNDLE "Bundle macOS dependencies" OFF)
|
option(USE_BUNDLE "Bundle macOS dependencies" OFF)
|
||||||
|
|||||||
@@ -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, Musicbrainz, Discogs, Deezer and Tidal
|
* Album cover art from Last.fm, Musicbrainz, Discogs, Deezer and Tidal
|
||||||
* Song lyrics from AudD
|
* Song lyrics from AudD and ChartLyrics
|
||||||
* Support for multiple backends
|
* Support for multiple backends
|
||||||
* Audio analyzer
|
* Audio analyzer
|
||||||
* Audio equalizer
|
* Audio equalizer
|
||||||
|
|||||||
2
dist/debian/control
vendored
2
dist/debian/control
vendored
@@ -59,7 +59,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
|
- Song lyrics from AudD and ChartLyrics
|
||||||
- Support for multiple backends
|
- Support for multiple backends
|
||||||
- Audio analyzer
|
- Audio analyzer
|
||||||
- Audio equalizer
|
- Audio equalizer
|
||||||
|
|||||||
2
dist/man/strawberry.1
vendored
2
dist/man/strawberry.1
vendored
@@ -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
|
- Song lyrics from AudD and ChartLyrics
|
||||||
.br
|
.br
|
||||||
- Support for multiple backends
|
- Support for multiple backends
|
||||||
.br
|
.br
|
||||||
|
|||||||
2
dist/rpm/strawberry.spec.in
vendored
2
dist/rpm/strawberry.spec.in
vendored
@@ -97,7 +97,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
|
- Song lyrics from AudD and ChartLyrics
|
||||||
- Support for multiple backends
|
- Support for multiple backends
|
||||||
- Audio analyzer
|
- Audio analyzer
|
||||||
- Audio equalizer
|
- Audio equalizer
|
||||||
|
|||||||
@@ -199,13 +199,13 @@ set(SOURCES
|
|||||||
covermanager/musicbrainzcoverprovider.cpp
|
covermanager/musicbrainzcoverprovider.cpp
|
||||||
covermanager/discogscoverprovider.cpp
|
covermanager/discogscoverprovider.cpp
|
||||||
covermanager/deezercoverprovider.cpp
|
covermanager/deezercoverprovider.cpp
|
||||||
covermanager/tidalcoverprovider.cpp
|
|
||||||
|
|
||||||
lyrics/lyricsproviders.cpp
|
lyrics/lyricsproviders.cpp
|
||||||
lyrics/lyricsprovider.cpp
|
lyrics/lyricsprovider.cpp
|
||||||
lyrics/lyricsfetcher.cpp
|
lyrics/lyricsfetcher.cpp
|
||||||
lyrics/lyricsfetchersearch.cpp
|
lyrics/lyricsfetchersearch.cpp
|
||||||
lyrics/auddlyricsprovider.cpp
|
lyrics/auddlyricsprovider.cpp
|
||||||
|
lyrics/chartlyricsprovider.cpp
|
||||||
|
|
||||||
settings/settingsdialog.cpp
|
settings/settingsdialog.cpp
|
||||||
settings/settingspage.cpp
|
settings/settingspage.cpp
|
||||||
@@ -376,13 +376,13 @@ set(HEADERS
|
|||||||
covermanager/musicbrainzcoverprovider.h
|
covermanager/musicbrainzcoverprovider.h
|
||||||
covermanager/discogscoverprovider.h
|
covermanager/discogscoverprovider.h
|
||||||
covermanager/deezercoverprovider.h
|
covermanager/deezercoverprovider.h
|
||||||
covermanager/tidalcoverprovider.h
|
|
||||||
|
|
||||||
lyrics/lyricsproviders.h
|
lyrics/lyricsproviders.h
|
||||||
lyrics/lyricsprovider.h
|
lyrics/lyricsprovider.h
|
||||||
lyrics/lyricsfetcher.h
|
lyrics/lyricsfetcher.h
|
||||||
lyrics/lyricsfetchersearch.h
|
lyrics/lyricsfetchersearch.h
|
||||||
lyrics/auddlyricsprovider.h
|
lyrics/auddlyricsprovider.h
|
||||||
|
lyrics/chartlyricsprovider.h
|
||||||
|
|
||||||
settings/settingsdialog.h
|
settings/settingsdialog.h
|
||||||
settings/settingspage.h
|
settings/settingspage.h
|
||||||
@@ -863,15 +863,17 @@ optional_source(WIN32
|
|||||||
widgets/osd_win.cpp
|
widgets/osd_win.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
optional_source(HAVE_STREAM_TIDAL
|
optional_source(HAVE_TIDAL
|
||||||
SOURCES
|
SOURCES
|
||||||
tidal/tidalservice.cpp
|
tidal/tidalservice.cpp
|
||||||
tidal/tidalurlhandler.cpp
|
tidal/tidalurlhandler.cpp
|
||||||
settings/tidalsettingspage.cpp
|
settings/tidalsettingspage.cpp
|
||||||
|
covermanager/tidalcoverprovider.cpp
|
||||||
HEADERS
|
HEADERS
|
||||||
tidal/tidalservice.h
|
tidal/tidalservice.h
|
||||||
tidal/tidalurlhandler.h
|
tidal/tidalurlhandler.h
|
||||||
settings/tidalsettingspage.h
|
settings/tidalsettingspage.h
|
||||||
|
covermanager/tidalcoverprovider.h
|
||||||
UI
|
UI
|
||||||
settings/tidalsettingspage.ui
|
settings/tidalsettingspage.ui
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
#cmakedefine HAVE_XINE
|
#cmakedefine HAVE_XINE
|
||||||
#cmakedefine HAVE_PHONON
|
#cmakedefine HAVE_PHONON
|
||||||
|
|
||||||
#cmakedefine HAVE_STREAM_TIDAL
|
#cmakedefine HAVE_TIDAL
|
||||||
|
|
||||||
#cmakedefine HAVE_KEYSYMDEF_H
|
#cmakedefine HAVE_KEYSYMDEF_H
|
||||||
#cmakedefine HAVE_XF86KEYSYM_H
|
#cmakedefine HAVE_XF86KEYSYM_H
|
||||||
|
|||||||
@@ -55,17 +55,18 @@
|
|||||||
#include "covermanager/discogscoverprovider.h"
|
#include "covermanager/discogscoverprovider.h"
|
||||||
#include "covermanager/musicbrainzcoverprovider.h"
|
#include "covermanager/musicbrainzcoverprovider.h"
|
||||||
#include "covermanager/deezercoverprovider.h"
|
#include "covermanager/deezercoverprovider.h"
|
||||||
#include "covermanager/tidalcoverprovider.h"
|
|
||||||
|
|
||||||
#include "lyrics/lyricsproviders.h"
|
#include "lyrics/lyricsproviders.h"
|
||||||
#include "lyrics/lyricsprovider.h"
|
#include "lyrics/lyricsprovider.h"
|
||||||
#include "lyrics/auddlyricsprovider.h"
|
#include "lyrics/auddlyricsprovider.h"
|
||||||
|
#include "lyrics/chartlyricsprovider.h"
|
||||||
|
|
||||||
#include "internet/internetservices.h"
|
#include "internet/internetservices.h"
|
||||||
#include "internet/internetsearch.h"
|
#include "internet/internetsearch.h"
|
||||||
|
|
||||||
#ifdef HAVE_STREAM_TIDAL
|
#ifdef HAVE_TIDAL
|
||||||
# include "tidal/tidalservice.h"
|
# include "tidal/tidalservice.h"
|
||||||
|
# include "covermanager/tidalcoverprovider.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "scrobbler/audioscrobbler.h"
|
#include "scrobbler/audioscrobbler.h"
|
||||||
@@ -108,7 +109,9 @@ class ApplicationImpl {
|
|||||||
cover_providers->AddProvider(new DiscogsCoverProvider(app, app));
|
cover_providers->AddProvider(new DiscogsCoverProvider(app, app));
|
||||||
cover_providers->AddProvider(new MusicbrainzCoverProvider(app, app));
|
cover_providers->AddProvider(new MusicbrainzCoverProvider(app, app));
|
||||||
cover_providers->AddProvider(new DeezerCoverProvider(app, app));
|
cover_providers->AddProvider(new DeezerCoverProvider(app, app));
|
||||||
|
#ifdef HAVE_TIDAL
|
||||||
cover_providers->AddProvider(new TidalCoverProvider(app, app));
|
cover_providers->AddProvider(new TidalCoverProvider(app, app));
|
||||||
|
#endif
|
||||||
return cover_providers;
|
return cover_providers;
|
||||||
}),
|
}),
|
||||||
album_cover_loader_([=]() {
|
album_cover_loader_([=]() {
|
||||||
@@ -120,16 +123,17 @@ class ApplicationImpl {
|
|||||||
lyrics_providers_([=]() {
|
lyrics_providers_([=]() {
|
||||||
LyricsProviders *lyrics_providers = new LyricsProviders(app);
|
LyricsProviders *lyrics_providers = new LyricsProviders(app);
|
||||||
lyrics_providers->AddProvider(new AuddLyricsProvider(app));
|
lyrics_providers->AddProvider(new AuddLyricsProvider(app));
|
||||||
|
lyrics_providers->AddProvider(new ChartLyricsProvider(app));
|
||||||
return lyrics_providers;
|
return lyrics_providers;
|
||||||
}),
|
}),
|
||||||
internet_services_([=]() {
|
internet_services_([=]() {
|
||||||
InternetServices *internet_services = new InternetServices(app);
|
InternetServices *internet_services = new InternetServices(app);
|
||||||
#ifdef HAVE_STREAM_TIDAL
|
#ifdef HAVE_TIDAL
|
||||||
internet_services->AddService(new TidalService(app, internet_services));
|
internet_services->AddService(new TidalService(app, internet_services));
|
||||||
#endif
|
#endif
|
||||||
return internet_services;
|
return internet_services;
|
||||||
}),
|
}),
|
||||||
#ifdef HAVE_STREAM_TIDAL
|
#ifdef HAVE_TIDAL
|
||||||
tidal_search_([=]() { return new InternetSearch(app, Song::Source_Tidal, app); }),
|
tidal_search_([=]() { return new InternetSearch(app, Song::Source_Tidal, app); }),
|
||||||
#endif
|
#endif
|
||||||
scrobbler_([=]() { return new AudioScrobbler(app, app); })
|
scrobbler_([=]() { return new AudioScrobbler(app, app); })
|
||||||
@@ -152,7 +156,7 @@ class ApplicationImpl {
|
|||||||
Lazy<CurrentArtLoader> current_art_loader_;
|
Lazy<CurrentArtLoader> current_art_loader_;
|
||||||
Lazy<LyricsProviders> lyrics_providers_;
|
Lazy<LyricsProviders> lyrics_providers_;
|
||||||
Lazy<InternetServices> internet_services_;
|
Lazy<InternetServices> internet_services_;
|
||||||
#ifdef HAVE_STREAM_TIDAL
|
#ifdef HAVE_TIDAL
|
||||||
Lazy<InternetSearch> tidal_search_;
|
Lazy<InternetSearch> tidal_search_;
|
||||||
#endif
|
#endif
|
||||||
Lazy<AudioScrobbler> scrobbler_;
|
Lazy<AudioScrobbler> scrobbler_;
|
||||||
@@ -223,7 +227,7 @@ LyricsProviders *Application::lyrics_providers() const { return p_->lyrics_provi
|
|||||||
PlaylistBackend *Application::playlist_backend() const { return p_->playlist_backend_.get(); }
|
PlaylistBackend *Application::playlist_backend() const { return p_->playlist_backend_.get(); }
|
||||||
PlaylistManager *Application::playlist_manager() const { return p_->playlist_manager_.get(); }
|
PlaylistManager *Application::playlist_manager() const { return p_->playlist_manager_.get(); }
|
||||||
InternetServices *Application::internet_services() const { return p_->internet_services_.get(); }
|
InternetServices *Application::internet_services() const { return p_->internet_services_.get(); }
|
||||||
#ifdef HAVE_STREAM_TIDAL
|
#ifdef HAVE_TIDAL
|
||||||
InternetSearch *Application::tidal_search() const { return p_->tidal_search_.get(); }
|
InternetSearch *Application::tidal_search() const { return p_->tidal_search_.get(); }
|
||||||
#endif
|
#endif
|
||||||
AudioScrobbler *Application::scrobbler() const { return p_->scrobbler_.get(); }
|
AudioScrobbler *Application::scrobbler() const { return p_->scrobbler_.get(); }
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ class Application : public QObject {
|
|||||||
LyricsProviders *lyrics_providers() const;
|
LyricsProviders *lyrics_providers() const;
|
||||||
|
|
||||||
InternetServices *internet_services() const;
|
InternetServices *internet_services() const;
|
||||||
#ifdef HAVE_STREAM_TIDAL
|
#ifdef HAVE_TIDAL
|
||||||
InternetSearch *tidal_search() const;
|
InternetSearch *tidal_search() const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -133,7 +133,7 @@
|
|||||||
#include "settings/behavioursettingspage.h"
|
#include "settings/behavioursettingspage.h"
|
||||||
#include "settings/backendsettingspage.h"
|
#include "settings/backendsettingspage.h"
|
||||||
#include "settings/playlistsettingspage.h"
|
#include "settings/playlistsettingspage.h"
|
||||||
#ifdef HAVE_STREAM_TIDAL
|
#ifdef HAVE_TIDAL
|
||||||
# include "settings/tidalsettingspage.h"
|
# include "settings/tidalsettingspage.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -201,7 +201,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
|
|||||||
dialog->SetDestinationModel(app->collection()->model()->directory_model());
|
dialog->SetDestinationModel(app->collection()->model()->directory_model());
|
||||||
return dialog;
|
return dialog;
|
||||||
}),
|
}),
|
||||||
#ifdef HAVE_STREAM_TIDAL
|
#ifdef HAVE_TIDAL
|
||||||
tidal_search_view_(new InternetSearchView(app_, app_->tidal_search(), TidalSettingsPage::kSettingsGroup, SettingsDialog::Page_Tidal, this)),
|
tidal_search_view_(new InternetSearchView(app_, app_->tidal_search(), TidalSettingsPage::kSettingsGroup, SettingsDialog::Page_Tidal, this)),
|
||||||
#endif
|
#endif
|
||||||
playlist_menu_(new QMenu(this)),
|
playlist_menu_(new QMenu(this)),
|
||||||
@@ -257,7 +257,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
|
|||||||
#ifndef Q_OS_WIN
|
#ifndef Q_OS_WIN
|
||||||
ui_->tabs->addTab(device_view_, IconLoader::Load("device"), tr("Devices"));
|
ui_->tabs->addTab(device_view_, IconLoader::Load("device"), tr("Devices"));
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_STREAM_TIDAL
|
#ifdef HAVE_TIDAL
|
||||||
ui_->tabs->addTab(tidal_search_view_, IconLoader::Load("tidal"), tr("Tidal"));
|
ui_->tabs->addTab(tidal_search_view_, IconLoader::Load("tidal"), tr("Tidal"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -535,7 +535,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
|
|||||||
collection_view_->filter()->AddMenuAction(separator);
|
collection_view_->filter()->AddMenuAction(separator);
|
||||||
collection_view_->filter()->AddMenuAction(collection_config_action);
|
collection_view_->filter()->AddMenuAction(collection_config_action);
|
||||||
|
|
||||||
#ifdef HAVE_STREAM_TIDAL
|
#ifdef HAVE_TIDAL
|
||||||
connect(tidal_search_view_, SIGNAL(AddToPlaylist(QMimeData*)), SLOT(AddToPlaylist(QMimeData*)));
|
connect(tidal_search_view_, SIGNAL(AddToPlaylist(QMimeData*)), SLOT(AddToPlaylist(QMimeData*)));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -837,7 +837,7 @@ void MainWindow::ReloadSettings() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_STREAM_TIDAL
|
#ifdef HAVE_TIDAL
|
||||||
settings.beginGroup(TidalSettingsPage::kSettingsGroup);
|
settings.beginGroup(TidalSettingsPage::kSettingsGroup);
|
||||||
bool enable_tidal = settings.value("enabled", false).toBool();
|
bool enable_tidal = settings.value("enabled", false).toBool();
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
@@ -862,7 +862,7 @@ void MainWindow::ReloadAllSettings() {
|
|||||||
ui_->playlist->view()->ReloadSettings();
|
ui_->playlist->view()->ReloadSettings();
|
||||||
album_cover_choice_controller_->ReloadSettings();
|
album_cover_choice_controller_->ReloadSettings();
|
||||||
if (cover_manager_.get()) cover_manager_->ReloadSettings();
|
if (cover_manager_.get()) cover_manager_->ReloadSettings();
|
||||||
#ifdef HAVE_STREAM_TIDAL
|
#ifdef HAVE_TIDAL
|
||||||
tidal_search_view_->ReloadSettings();
|
tidal_search_view_->ReloadSettings();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -35,17 +35,15 @@
|
|||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
|
|
||||||
#include "coverprovider.h"
|
#include "coverprovider.h"
|
||||||
#include "tidal/tidalservice.h"
|
|
||||||
|
|
||||||
class Application;
|
class Application;
|
||||||
|
class TidalService;
|
||||||
|
|
||||||
class TidalCoverProvider : public CoverProvider {
|
class TidalCoverProvider : public CoverProvider {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TidalCoverProvider(Application *app, QObject *parent = nullptr);
|
explicit TidalCoverProvider(Application *app, QObject *parent = nullptr);
|
||||||
void SetService(TidalService *service);
|
|
||||||
void ReloadSettings();
|
|
||||||
bool StartSearch(const QString &artist, const QString &album, int id);
|
bool StartSearch(const QString &artist, const QString &album, int id);
|
||||||
void CancelSearch(int id);
|
void CancelSearch(int id);
|
||||||
|
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ void AuddLyricsProvider::HandleSearchReply(QNetworkReply *reply, quint64 id, con
|
|||||||
|
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
|
|
||||||
QJsonArray json_result = ExtractResult(reply, id);
|
QJsonArray json_result = ExtractResult(reply, id, artist, title);
|
||||||
if (json_result.isEmpty()) {
|
if (json_result.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -131,6 +131,9 @@ void AuddLyricsProvider::HandleSearchReply(QNetworkReply *reply, quint64 id, con
|
|||||||
results << result;
|
results << result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (results.isEmpty()) qLog(Debug) << "AudDLyrics: No lyrics for" << artist << title;
|
||||||
|
else qLog(Debug) << "AudDLyrics: Got lyrics for" << artist << title;
|
||||||
|
|
||||||
emit SearchFinished(id, results);
|
emit SearchFinished(id, results);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -173,7 +176,7 @@ QJsonObject AuddLyricsProvider::ExtractJsonObj(QNetworkReply *reply, quint64 id)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonArray AuddLyricsProvider::ExtractResult(QNetworkReply *reply, quint64 id) {
|
QJsonArray AuddLyricsProvider::ExtractResult(QNetworkReply *reply, const quint64 id, const QString &artist, const QString &title) {
|
||||||
|
|
||||||
QJsonObject json_obj = ExtractJsonObj(reply, id);
|
QJsonObject json_obj = ExtractJsonObj(reply, id);
|
||||||
if (json_obj.isEmpty()) return QJsonArray();
|
if (json_obj.isEmpty()) return QJsonArray();
|
||||||
@@ -206,7 +209,7 @@ QJsonArray AuddLyricsProvider::ExtractResult(QNetworkReply *reply, quint64 id) {
|
|||||||
|
|
||||||
QJsonArray json_result = json_obj["result"].toArray();
|
QJsonArray json_result = json_obj["result"].toArray();
|
||||||
if (json_result.isEmpty()) {
|
if (json_result.isEmpty()) {
|
||||||
Error(id, "No match.");
|
Error(id, QString("No lyrics for %1 %2").arg(artist).arg(title));
|
||||||
return QJsonArray();
|
return QJsonArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class AuddLyricsProvider : public LyricsProvider {
|
|||||||
void Error(quint64 id, QString error, QVariant debug = QVariant());
|
void Error(quint64 id, QString error, QVariant debug = QVariant());
|
||||||
|
|
||||||
QJsonObject ExtractJsonObj(QNetworkReply *reply, quint64 id);
|
QJsonObject ExtractJsonObj(QNetworkReply *reply, quint64 id);
|
||||||
QJsonArray ExtractResult(QNetworkReply *reply, quint64 id);
|
QJsonArray ExtractResult(QNetworkReply *reply, const quint64 id, const QString &artist, const QString &title);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
138
src/lyrics/chartlyricsprovider.cpp
Normal file
138
src/lyrics/chartlyricsprovider.cpp
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
/*
|
||||||
|
* 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 <QMap>
|
||||||
|
#include <QSet>
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QString>
|
||||||
|
#include <QStringBuilder>
|
||||||
|
#include <QStringList>
|
||||||
|
#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 &album, const QString &title, quint64 id) {
|
||||||
|
|
||||||
|
typedef QPair<QString, QString> Param;
|
||||||
|
typedef QList<Param> ParamList;
|
||||||
|
|
||||||
|
typedef QPair<QByteArray, QByteArray> EncodedParam;
|
||||||
|
typedef QList<EncodedParam> EncodedParamList;
|
||||||
|
|
||||||
|
ParamList params = ParamList() << Param("artist", artist)
|
||||||
|
<< Param("song", title);
|
||||||
|
|
||||||
|
QUrlQuery url_query;
|
||||||
|
QUrl url(kUrlSearch);
|
||||||
|
|
||||||
|
for (const Param ¶m : params) {
|
||||||
|
EncodedParam encoded_param(QUrl::toPercentEncoding(param.first), QUrl::toPercentEncoding(param.second));
|
||||||
|
url_query.addQueryItem(encoded_param.first, encoded_param.second);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChartLyricsProvider::CancelSearch(quint64 id) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChartLyricsProvider::HandleSearchReply(QNetworkReply *reply, 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
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(quint64 id, QString error, QVariant debug) {
|
||||||
|
qLog(Error) << "ChartLyrics:" << error;
|
||||||
|
if (debug.isValid()) qLog(Debug) << debug;
|
||||||
|
LyricsSearchResults results;
|
||||||
|
emit SearchFinished(id, results);
|
||||||
|
}
|
||||||
58
src/lyrics/chartlyricsprovider.h
Normal file
58
src/lyrics/chartlyricsprovider.h
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* 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 <stdbool.h>
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QHash>
|
||||||
|
#include <QMetaType>
|
||||||
|
#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, 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 int kMaxLength;
|
||||||
|
QNetworkAccessManager *network_;
|
||||||
|
void Error(quint64 id, QString error, QVariant debug = QVariant());
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // AUDDLYRICSPROVIDER_H
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@
|
|||||||
#include "transcodersettingspage.h"
|
#include "transcodersettingspage.h"
|
||||||
#include "networkproxysettingspage.h"
|
#include "networkproxysettingspage.h"
|
||||||
#include "scrobblersettingspage.h"
|
#include "scrobblersettingspage.h"
|
||||||
#ifdef HAVE_STREAM_TIDAL
|
#ifdef HAVE_TIDAL
|
||||||
# include "tidalsettingspage.h"
|
# include "tidalsettingspage.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -133,10 +133,10 @@ SettingsDialog::SettingsDialog(Application *app, QWidget *parent)
|
|||||||
AddPage(Page_GlobalShortcuts, new GlobalShortcutsSettingsPage(this), iface);
|
AddPage(Page_GlobalShortcuts, new GlobalShortcutsSettingsPage(this), iface);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_STREAM_TIDAL)
|
#if defined(HAVE_TIDAL)
|
||||||
QTreeWidgetItem *streaming = AddCategory(tr("Streaming"));
|
QTreeWidgetItem *streaming = AddCategory(tr("Streaming"));
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_STREAM_TIDAL
|
#ifdef HAVE_TIDAL
|
||||||
AddPage(Page_Tidal, new TidalSettingsPage(this), streaming);
|
AddPage(Page_Tidal, new TidalSettingsPage(this), streaming);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user