Add Spotify support

This commit is contained in:
Jonas Kvinge
2022-06-04 15:51:35 +02:00
parent f33b30fe79
commit 5f540a4c08
44 changed files with 4486 additions and 346 deletions

View File

@@ -56,7 +56,6 @@
#include "covermanager/musicbrainzcoverprovider.h"
#include "covermanager/deezercoverprovider.h"
#include "covermanager/musixmatchcoverprovider.h"
#include "covermanager/spotifycoverprovider.h"
#include "covermanager/opentidalcoverprovider.h"
#include "lyrics/lyricsproviders.h"
@@ -90,6 +89,11 @@
# include "covermanager/tidalcoverprovider.h"
#endif
#ifdef HAVE_SPOTIFY
# include "spotify/spotifyservice.h"
# include "covermanager/spotifycoverprovider.h"
#endif
#ifdef HAVE_QOBUZ
# include "qobuz/qobuzservice.h"
# include "covermanager/qobuzcoverprovider.h"
@@ -143,11 +147,13 @@ class ApplicationImpl {
cover_providers->AddProvider(new DiscogsCoverProvider(app, app->network()));
cover_providers->AddProvider(new DeezerCoverProvider(app, app->network()));
cover_providers->AddProvider(new MusixmatchCoverProvider(app, app->network()));
cover_providers->AddProvider(new SpotifyCoverProvider(app, app->network()));
cover_providers->AddProvider(new OpenTidalCoverProvider(app, app->network()));
#ifdef HAVE_TIDAL
cover_providers->AddProvider(new TidalCoverProvider(app, app->network()));
#endif
#ifdef HAVE_SPOTIFY
cover_providers->AddProvider(new SpotifyCoverProvider(app, app->network()));
#endif
#ifdef HAVE_QOBUZ
cover_providers->AddProvider(new QobuzCoverProvider(app, app->network()));
#endif
@@ -183,6 +189,9 @@ class ApplicationImpl {
#ifdef HAVE_TIDAL
streaming_services->AddService(make_shared<TidalService>(app));
#endif
#ifdef HAVE_SPOTIFY
streaming_services->AddService(make_shared<SpotifyService>(app));
#endif
#ifdef HAVE_QOBUZ
streaming_services->AddService(make_shared<QobuzService>(app));
#endif

View File

@@ -49,7 +49,7 @@
#include "sqlquery.h"
#include "scopedtransaction.h"
const int Database::kSchemaVersion = 19;
const int Database::kSchemaVersion = 20;
namespace {
constexpr char kDatabaseFilename[] = "strawberry.db";

View File

@@ -178,6 +178,9 @@
# include "tidal/tidalservice.h"
# include "settings/tidalsettingspage.h"
#endif
#ifdef HAVE_SPOTIFY
# include "settings/spotifysettingspage.h"
#endif
#ifdef HAVE_QOBUZ
# include "settings/qobuzsettingspage.h"
#endif
@@ -308,6 +311,9 @@ MainWindow::MainWindow(Application *app, SharedPtr<SystemTrayIcon> tray_icon, OS
#ifdef HAVE_TIDAL
tidal_view_(new StreamingTabsView(app_, app->streaming_services()->ServiceBySource(Song::Source::Tidal), QLatin1String(TidalSettingsPage::kSettingsGroup), SettingsDialog::Page::Tidal, this)),
#endif
#ifdef HAVE_SPOTIFY
spotify_view_(new StreamingTabsView(app_, app->streaming_services()->ServiceBySource(Song::Source::Spotify), QLatin1String(SpotifySettingsPage::kSettingsGroup), SettingsDialog::Page::Spotify, this)),
#endif
#ifdef HAVE_QOBUZ
qobuz_view_(new StreamingTabsView(app_, app->streaming_services()->ServiceBySource(Song::Source::Qobuz), QLatin1String(QobuzSettingsPage::kSettingsGroup), SettingsDialog::Page::Qobuz, this)),
#endif
@@ -392,6 +398,9 @@ MainWindow::MainWindow(Application *app, SharedPtr<SystemTrayIcon> tray_icon, OS
#ifdef HAVE_TIDAL
ui_->tabs->AddTab(tidal_view_, QStringLiteral("tidal"), IconLoader::Load(QStringLiteral("tidal"), true, 0, 32), tr("Tidal"));
#endif
#ifdef HAVE_SPOTIFY
ui_->tabs->AddTab(spotify_view_, QLatin1String("spotify"), IconLoader::Load(QStringLiteral("spotify"), true, 0, 32), tr("Spotify"));
#endif
#ifdef HAVE_QOBUZ
ui_->tabs->AddTab(qobuz_view_, QStringLiteral("qobuz"), IconLoader::Load(QStringLiteral("qobuz"), true, 0, 32), tr("Qobuz"));
#endif
@@ -714,6 +723,13 @@ MainWindow::MainWindow(Application *app, SharedPtr<SystemTrayIcon> tray_icon, OS
QObject::connect(qobuz_view_->search_view(), &StreamingSearchView::AddToPlaylist, this, &MainWindow::AddToPlaylist);
#endif
#ifdef HAVE_SPOTIFY
QObject::connect(spotify_view_->artists_collection_view(), &StreamingCollectionView::AddToPlaylistSignal, this, &MainWindow::AddToPlaylist);
QObject::connect(spotify_view_->albums_collection_view(), &StreamingCollectionView::AddToPlaylistSignal, this, &MainWindow::AddToPlaylist);
QObject::connect(spotify_view_->songs_collection_view(), &StreamingCollectionView::AddToPlaylistSignal, this, &MainWindow::AddToPlaylist);
QObject::connect(spotify_view_->search_view(), &StreamingSearchView::AddToPlaylist, this, &MainWindow::AddToPlaylist);
#endif
QObject::connect(radio_view_, &RadioViewContainer::Refresh, &*app_->radio_services(), &RadioServices::RefreshChannels);
QObject::connect(radio_view_->view(), &RadioView::GetChannels, &*app_->radio_services(), &RadioServices::GetChannels);
QObject::connect(radio_view_->view(), &RadioView::AddToPlaylistSignal, this, &MainWindow::AddToPlaylist);
@@ -1178,6 +1194,18 @@ void MainWindow::ReloadSettings() {
}
#endif
#ifdef HAVE_SPOTIFY
s.beginGroup(SpotifySettingsPage::kSettingsGroup);
bool enable_spotify = s.value("enabled", false).toBool();
s.endGroup();
if (enable_spotify) {
ui_->tabs->EnableTab(spotify_view_);
}
else {
ui_->tabs->DisableTab(spotify_view_);
}
#endif
#ifdef HAVE_QOBUZ
s.beginGroup(QobuzSettingsPage::kSettingsGroup);
bool enable_qobuz = s.value("enabled", false).toBool();
@@ -1226,6 +1254,9 @@ void MainWindow::ReloadAllSettings() {
#ifdef HAVE_TIDAL
tidal_view_->ReloadSettings();
#endif
#ifdef HAVE_SPOTIFY
spotify_view_->ReloadSettings();
#endif
#ifdef HAVE_QOBUZ
qobuz_view_->ReloadSettings();
#endif
@@ -3284,6 +3315,11 @@ void MainWindow::FocusSearchField() {
tidal_view_->FocusSearchField();
}
#endif
#ifdef HAVE_SPOTIFY
else if (ui_->tabs->currentIndex() == ui_->tabs->IndexOfTab(spotify_view_) && !spotify_view_->SearchFieldHasFocus()) {
spotify_view_->FocusSearchField();
}
#endif
#ifdef HAVE_QOBUZ
else if (ui_->tabs->currentIndex() == ui_->tabs->IndexOfTab(qobuz_view_) && !qobuz_view_->SearchFieldHasFocus()) {
qobuz_view_->FocusSearchField();

View File

@@ -341,9 +341,18 @@ class MainWindow : public QMainWindow, public PlatformInterface {
SmartPlaylistsViewContainer *smartplaylists_view_;
#ifdef HAVE_SUBSONIC
StreamingSongsView *subsonic_view_;
#endif
#ifdef HAVE_TIDAL
StreamingTabsView *tidal_view_;
#endif
#ifdef HAVE_SPOTIFY
StreamingTabsView *spotify_view_;
#endif
#ifdef HAVE_QOBUZ
StreamingTabsView *qobuz_view_;
#endif
RadioViewContainer *radio_view_;

View File

@@ -565,11 +565,11 @@ const QString &Song::playlist_albumartist_sortable() const { return is_compilati
bool Song::is_metadata_good() const { return !d->url_.isEmpty() && !d->artist_.isEmpty() && !d->title_.isEmpty(); }
bool Song::is_collection_song() const { return d->source_ == Source::Collection; }
bool Song::is_stream() const { return is_radio() || d->source_ == Source::Tidal || d->source_ == Source::Subsonic || d->source_ == Source::Qobuz; }
bool Song::is_stream() const { return is_radio() || d->source_ == Source::Tidal || d->source_ == Source::Subsonic || d->source_ == Source::Qobuz || d->source_ == Source::Spotify; }
bool Song::is_radio() const { return d->source_ == Source::Stream || d->source_ == Source::SomaFM || d->source_ == Source::RadioParadise; }
bool Song::is_cdda() const { return d->source_ == Source::CDDA; }
bool Song::is_compilation() const { return (d->compilation_ || d->compilation_detected_ || d->compilation_on_) && !d->compilation_off_; }
bool Song::stream_url_can_expire() const { return d->source_ == Source::Tidal || d->source_ == Source::Qobuz; }
bool Song::stream_url_can_expire() const { return d->source_ == Source::Tidal || d->source_ == Source::Qobuz || d->source_ == Source::Spotify; }
bool Song::is_module_music() const { return d->filetype_ == FileType::MOD || d->filetype_ == FileType::S3M || d->filetype_ == FileType::XM || d->filetype_ == FileType::IT; }
bool Song::has_cue() const { return !d->cue_path_.isEmpty(); }
@@ -938,11 +938,13 @@ Song::Source Song::SourceFromURL(const QUrl &url) {
if (url.isLocalFile()) return Source::LocalFile;
if (url.scheme() == QStringLiteral("cdda")) return Source::CDDA;
if (url.scheme() == QStringLiteral("tidal")) return Source::Tidal;
if (url.scheme() == QStringLiteral("subsonic")) return Source::Subsonic;
if (url.scheme() == QStringLiteral("tidal")) return Source::Tidal;
if (url.scheme() == QStringLiteral("spotify")) return Source::Spotify;
if (url.scheme() == QStringLiteral("qobuz")) return Source::Qobuz;
if (url.scheme() == QStringLiteral("http") || url.scheme() == QStringLiteral("https") || url.scheme() == QStringLiteral("rtsp")) {
if (url.host().endsWith(QLatin1String("tidal.com"), Qt::CaseInsensitive)) { return Source::Tidal; }
if (url.host().endsWith(QLatin1String("spotify.com"), Qt::CaseInsensitive)) { return Source::Spotify; }
if (url.host().endsWith(QLatin1String("qobuz.com"), Qt::CaseInsensitive)) { return Source::Qobuz; }
if (url.host().endsWith(QLatin1String("somafm.com"), Qt::CaseInsensitive)) { return Source::SomaFM; }
if (url.host().endsWith(QLatin1String("radioparadise.com"), Qt::CaseInsensitive)) { return Source::RadioParadise; }
@@ -960,8 +962,9 @@ QString Song::TextForSource(const Source source) {
case Source::CDDA: return QStringLiteral("cd");
case Source::Device: return QStringLiteral("device");
case Source::Stream: return QStringLiteral("stream");
case Source::Tidal: return QStringLiteral("tidal");
case Source::Subsonic: return QStringLiteral("subsonic");
case Source::Tidal: return QStringLiteral("tidal");
case Source::Spotify: return QStringLiteral("spotify");
case Source::Qobuz: return QStringLiteral("qobuz");
case Source::SomaFM: return QStringLiteral("somafm");
case Source::RadioParadise: return QStringLiteral("radioparadise");
@@ -979,8 +982,9 @@ QString Song::DescriptionForSource(const Source source) {
case Source::CDDA: return QStringLiteral("CD");
case Source::Device: return QStringLiteral("Device");
case Source::Stream: return QStringLiteral("Stream");
case Source::Tidal: return QStringLiteral("Tidal");
case Source::Subsonic: return QStringLiteral("Subsonic");
case Source::Tidal: return QStringLiteral("Tidal");
case Source::Spotify: return QStringLiteral("Spotify");
case Source::Qobuz: return QStringLiteral("Qobuz");
case Source::SomaFM: return QStringLiteral("SomaFM");
case Source::RadioParadise: return QStringLiteral("Radio Paradise");
@@ -997,8 +1001,9 @@ Song::Source Song::SourceFromText(const QString &source) {
if (source.compare(QLatin1String("cd"), Qt::CaseInsensitive) == 0) return Source::CDDA;
if (source.compare(QLatin1String("device"), Qt::CaseInsensitive) == 0) return Source::Device;
if (source.compare(QLatin1String("stream"), Qt::CaseInsensitive) == 0) return Source::Stream;
if (source.compare(QLatin1String("tidal"), Qt::CaseInsensitive) == 0) return Source::Tidal;
if (source.compare(QLatin1String("subsonic"), Qt::CaseInsensitive) == 0) return Source::Subsonic;
if (source.compare(QLatin1String("tidal"), Qt::CaseInsensitive) == 0) return Source::Tidal;
if (source.compare(QLatin1String("spotify"), Qt::CaseInsensitive) == 0) return Source::Spotify;
if (source.compare(QLatin1String("qobuz"), Qt::CaseInsensitive) == 0) return Source::Qobuz;
if (source.compare(QLatin1String("somafm"), Qt::CaseInsensitive) == 0) return Source::SomaFM;
if (source.compare(QLatin1String("radioparadise"), Qt::CaseInsensitive) == 0) return Source::RadioParadise;
@@ -1015,8 +1020,9 @@ QIcon Song::IconForSource(const Source source) {
case Source::CDDA: return IconLoader::Load(QStringLiteral("media-optical"));
case Source::Device: return IconLoader::Load(QStringLiteral("device"));
case Source::Stream: return IconLoader::Load(QStringLiteral("applications-internet"));
case Source::Tidal: return IconLoader::Load(QStringLiteral("tidal"));
case Source::Subsonic: return IconLoader::Load(QStringLiteral("subsonic"));
case Source::Tidal: return IconLoader::Load(QStringLiteral("tidal"));
case Source::Spotify: return IconLoader::Load(QStringLiteral("spotify"));
case Source::Qobuz: return IconLoader::Load(QStringLiteral("qobuz"));
case Source::SomaFM: return IconLoader::Load(QStringLiteral("somafm"));
case Source::RadioParadise: return IconLoader::Load(QStringLiteral("radioparadise"));
@@ -1237,6 +1243,8 @@ QString Song::ImageCacheDir(const Source source) {
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + QStringLiteral("/subsonicalbumcovers");
case Source::Tidal:
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + QStringLiteral("/tidalalbumcovers");
case Source::Spotify:
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + QStringLiteral("/spotifyalbumcovers");
case Source::Qobuz:
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + QStringLiteral("/qobuzalbumcovers");
case Source::Device:

View File

@@ -77,7 +77,8 @@ class Song {
Subsonic = 7,
Qobuz = 8,
SomaFM = 9,
RadioParadise = 10
RadioParadise = 10,
Spotify = 11
};
// Don't change these values - they're stored in the database, and defined in the tag reader protobuf.