Merge pull request #1481 from owntone/libspotify_remove

This commit is contained in:
ejurgensen 2022-05-25 23:50:41 -07:00 committed by GitHub
commit efd149f2c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 17 additions and 1946 deletions

View File

@ -1,4 +1,4 @@
if COND_LIBRESPOTC
if COND_SPOTIFY
LIBRESPOTC_SUBDIR=src/inputs/librespot-c
endif
@ -65,9 +65,6 @@ if COND_INSTALL_USER
( ! $(GETENT) group pulse-access &> /dev/null || $(USERMOD) --append --groups pulse-access $(OWNTONE_USER) )
$(CHOWN) $(OWNTONE_USER).$(OWNTONE_GROUP) "$(DESTDIR)$(localstatedir)/cache/$(PACKAGE)"
endif
if COND_LIBSPOTIFY
$(MKDIR_P) "$(DESTDIR)$(localstatedir)/cache/$(PACKAGE)/libspotify"
endif
# we do this manually instead of using sysconf_DATA because it overwrites existing config
if COND_INSTALL_CONF_FILE
$(MKDIR_P) "$(DESTDIR)$(sysconfdir)"

View File

@ -282,25 +282,7 @@ OWNTONE_ARG_DISABLE([Spotify support], [spotify], [SPOTIFY_LIBRESPOTC],
AC_DEFINE([SPOTIFY], 1,
[Define to 1 to enable Spotify])
])
AM_CONDITIONAL([COND_LIBRESPOTC], [[test "x$enable_spotify" = "xyes"]])
dnl Spotify with dynamic linking to libspotify (legacy)
OWNTONE_ARG_ENABLE([legacy libspotify support], [libspotify], [SPOTIFY_LIBSPOTIFY],
[AS_IF([[test "x$with_libevent_pthreads" = "xno"]],
[AC_MSG_ERROR([[libspotify support requires libevent_pthreads]])])
OWNTONE_MODULES_CHECK([SPOTIFY_LIBSPOTIFY], [LIBSPOTIFY], [libspotify],
[], [libspotify/api.h])
dnl Don't link with libspotify, use dynamic linking
AC_SEARCH_LIBS([dlopen], [dl], [],
[AC_MSG_ERROR([[libspotify support requires dlopen]])])
OWNTONE_VAR_PREPEND([OWNTONE_OPTS_CPPFLAGS], [$SPOTIFY_LIBSPOTIFY_CPPFLAGS])
OWNTONE_VAR_PREPEND([OWNTONE_OPTS_LIBS], [-rdynamic])
AC_DEFINE([SPOTIFY], 1,
[Define to 1 to enable Spotify])
])
AM_CONDITIONAL([COND_LIBSPOTIFY], [[test "x$enable_libspotify" = "xyes"]])
AM_CONDITIONAL([COND_SPOTIFY], [[test "x$enable_spotify" = "xyes" -o "x$enable_libspotify" = "xyes"]])
AM_CONDITIONAL([COND_SPOTIFY], [[test "x$enable_spotify" = "xyes"]])
dnl LastFM support
OWNTONE_ARG_DISABLE([LastFM support], [lastfm], [LASTFM])

View File

@ -38,7 +38,6 @@ argument when you run ./configure:
Feature | Configure argument | Packages
---------------------|--------------------------|-------------------------------------
Chromecast | `--enable-chromecast` | libgnutls*-dev
Legacy libspotify | `--enable-libspotify` | libspotify-dev
Pulseaudio | `--with-pulseaudio` | libpulse-dev
These features can be disabled saving you package dependencies:
@ -258,8 +257,6 @@ Libraries:
often already installed as part of your distro
- libpulse (optional - Pulseaudio local audio)
from <https://www.freedesktop.org/wiki/Software/PulseAudio/Download/>
- libspotify (optional - Spotify support)
(deprecated by Spotify)
- libgnutls (optional - Chromecast support)
from <http://www.gnutls.org/>
- libwebsockets 2.0.2+ (optional - websocket support)
@ -282,15 +279,6 @@ generate the configure script and `Makefile.in`.
To display the configure options `run ./configure --help`.
Support for Spotify is optional. Use `--disable-spotify` to disable this feature.
OwnTone supports two ways of integrating with Spotify: Using its own, built-in
integration layer (which is the default), or to use Spotify's deprecated
libspotify. To enable the latter, you must configure with `--enable-libspotify`
and also make sure libspotify's `libspotify/api.h` is installed at compile time.
At runtime, libspotify must be installed, and `use_libspotify` must be enabled
in owntone.conf. OwnTone uses runtime dynamic linking to the libspotify library,
so even though you compiled with `--enable-libspotify`, the executable will
still be able to run on systems without libspotify. If you only want libspotify
integration, you can use `--disable-spotify` and `--enable-libspotify`.
Support for LastFM scrobbling is optional. Use `--enable-lastfm` to enable this
feature.

View File

@ -52,10 +52,3 @@ pipe = "/srv/music/spotify"
# Output metadata in Shairport Sync format (https://github.com/mikebrady/shairport-sync-metadata-reader)
metadataPipe = "/srv/music/spotify.metadata"
```
## Via libspotify
This method is being deprecated, but is still available if the server was built
with it, libspotify is installed and `use_libspotify` is enabled in the config
file. Please consult [previous README versions](#references) for details on
using libspotify.

View File

@ -352,18 +352,6 @@ audio {
# Spotify settings (only have effect if Spotify enabled - see README/INSTALL)
spotify {
# The server can stream from Spotify using either its own implementation
# or using Spotify's libspotify (which was deprecated many years ago)
# use_libspotify = false
# Directory where user settings should be stored (credentials)
# (only has effect with libspotify)
# settings_dir = "@localstatedir@/cache/@PACKAGE@/libspotify"
# Cache directory
# (only has effect with libspotify)
# cache_dir = "/tmp"
# Set preferred bitrate for music streaming
# 0: No preference (default), 1: 96kbps, 2: 160kbps, 3: 320kbps
# bitrate = 0

View File

@ -3,16 +3,8 @@ sbin_PROGRAMS = owntone
if COND_SPOTIFY
SPOTIFY_SRC = \
library/spotify_webapi.c library/spotify_webapi.h inputs/spotify.c inputs/spotify.h
endif
if COND_LIBRESPOTC
LIBRESPOTC_SRC = \
inputs/spotify_librespotc.c
endif
if COND_LIBSPOTIFY
LIBSPOTIFY_SRC = \
inputs/spotify_libspotify.c \
inputs/libspotify/libspotify.c inputs/libspotify/libspotify.h
library/spotify_webapi.c library/spotify_webapi.h \
inputs/spotify.c inputs/spotify.h inputs/spotify_librespotc.c
endif
if COND_LASTFM
@ -128,7 +120,7 @@ owntone_SOURCES = main.c \
outputs/streaming.c outputs/dummy.c outputs/fifo.c outputs/rcp.c \
$(ALSA_SRC) $(PULSEAUDIO_SRC) $(CHROMECAST_SRC) \
evrtsp/rtsp.c evrtsp/evrtsp.h evrtsp/rtsp-internal.h evrtsp/log.h \
$(SPOTIFY_SRC) $(LIBRESPOTC_SRC) $(LIBSPOTIFY_SRC) \
$(SPOTIFY_SRC) \
$(LASTFM_SRC) \
$(MPD_SRC) \
listener.c listener.h \

View File

@ -198,9 +198,9 @@ static cfg_opt_t sec_rcp[] =
/* Spotify section structure */
static cfg_opt_t sec_spotify[] =
{
CFG_BOOL("use_libspotify", cfg_false, CFGF_NONE),
CFG_STR("settings_dir", STATEDIR "/cache/" PACKAGE "/libspotify", CFGF_NONE),
CFG_STR("cache_dir", "/tmp", CFGF_NONE),
CFG_BOOL("use_libspotify", cfg_false, CFGF_DEPRECATED),
CFG_STR("settings_dir", STATEDIR "/cache/" PACKAGE "/libspotify", CFGF_DEPRECATED),
CFG_STR("cache_dir", "/tmp", CFGF_DEPRECATED),
CFG_INT("bitrate", 0, CFGF_NONE),
CFG_BOOL("base_playlist_disable", cfg_false, CFGF_NONE),
CFG_BOOL("artist_override", cfg_false, CFGF_NONE),

View File

@ -867,8 +867,8 @@ jsonapi_reply_config(struct httpd_request *hreq)
json_object_object_add(jreply, "allow_modifying_stored_playlists", json_object_new_boolean(allow_modifying_stored_playlists));
safe_json_add_string(jreply, "default_playlist_directory", default_playlist_directory);
// Wether libspotify should be used instead of librespot
json_object_object_add(jreply, "use_libspotify", json_object_new_boolean(cfg_getbool(cfg_getsec(cfg, "spotify"), "use_libspotify")));
// libspotify is sunset, so always return false. TODO: remove this parameter.
json_object_object_add(jreply, "use_libspotify", json_object_new_boolean(false));
CHECK_ERRNO(L_WEB, evbuffer_add_printf(hreq->reply, "%s", json_object_to_json_string(jreply)));

File diff suppressed because it is too large Load Diff

View File

@ -1,65 +0,0 @@
#ifndef __LIBSPOTIFY_H__
#define __LIBSPOTIFY_H__
#include <event2/event.h>
#include <event2/buffer.h>
#include <event2/http.h>
#include <stdbool.h>
struct spotify_status_info
{
bool libspotify_installed;
bool libspotify_logged_in;
char libspotify_user[100];
};
#define LIBSPOTIFY_SETUP_ERROR_IS_LOADING -2
int
libspotify_playback_setup(const char *path);
int
libspotify_playback_play(void);
int
libspotify_playback_pause(void);
//void
//spotify_playback_pause_nonblock(void);
int
libspotify_playback_stop(void);
//void
//spotify_playback_stop_nonblock(void);
int
libspotify_playback_seek(int ms);
//int
//spotify_artwork_get(struct evbuffer *evbuf, char *path, int max_w, int max_h);
int
libspotify_relogin(void);
int
libspotify_login(const char *user, const char *password, const char **errmsg);
void
libspotify_logout(void);
void
libspotify_status_info_get(struct spotify_status_info *info);
void
libspotify_uri_register(const char *uri);
int
libspotify_init(void);
void
libspotify_deinit(void);
#endif /* !__LIBSPOTIFY_H__ */

View File

@ -25,26 +25,21 @@
#include <string.h>
#include "logger.h"
#include "conffile.h"
#include "spotify.h"
// With just one backend the abstraction implemented here is a bit overkill, but
// it was added back when there was also libspotify. Keep it around for a while
// and then consider removing.
#ifdef SPOTIFY_LIBRESPOTC
extern struct spotify_backend spotify_librespotc;
#endif
#ifdef SPOTIFY_LIBSPOTIFY
extern struct spotify_backend spotify_libspotify;
#endif
static struct spotify_backend *
backend_set(void)
{
#ifdef SPOTIFY_LIBRESPOTC
if (!cfg_getbool(cfg_getsec(cfg, "spotify"), "use_libspotify"))
return &spotify_librespotc;
#endif
#ifdef SPOTIFY_LIBSPOTIFY
if (cfg_getbool(cfg_getsec(cfg, "spotify"), "use_libspotify"))
return &spotify_libspotify;
return &spotify_librespotc;
#endif
DPRINTF(E_LOG, L_SPOTIFY, "Invalid Spotify configuration (not built with the configured backend)\n");
return NULL;

View File

@ -286,7 +286,7 @@ hexdump_cb(const char *msg, uint8_t *data, size_t data_len)
}
/* ----------------------- libresport-c initialization ---------------------- */
/* ------------------------ librespot-c initialization ---------------------- */
struct sp_callbacks callbacks = {
.https_get = https_get_cb,
@ -310,9 +310,6 @@ initialize(struct global_ctx *ctx)
spotify_cfg = cfg_getsec(cfg, "spotify");
if (cfg_getbool(spotify_cfg, "use_libspotify"))
return -1;
if (ctx->is_initialized)
return 0;

View File

@ -1,134 +0,0 @@
/*
* Copyright (C) 2017 Espen Jurgensen
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdint.h>
#include "input.h"
#include "conffile.h"
#include "logger.h"
#include "spotify.h"
#include "libspotify/libspotify.h"
// How many retries to start playback if resource is still loading
#define LIBSPOTIFY_SETUP_RETRIES 5
// How long to wait between retries in microseconds (500000 = 0.5 seconds)
#define LIBSPOTIFY_SETUP_RETRY_WAIT 500000
static int
init(void)
{
return cfg_getbool(cfg_getsec(cfg, "spotify"), "use_libspotify") ? 0 : -1;
}
static int
setup(struct input_source *source)
{
int i = 0;
int ret;
while((ret = libspotify_playback_setup(source->path)) == LIBSPOTIFY_SETUP_ERROR_IS_LOADING)
{
if (i >= LIBSPOTIFY_SETUP_RETRIES)
break;
DPRINTF(E_DBG, L_SPOTIFY, "Resource still loading (%d)\n", i);
usleep(LIBSPOTIFY_SETUP_RETRY_WAIT);
i++;
}
if (ret < 0)
return -1;
ret = libspotify_playback_play();
if (ret < 0)
return -1;
return 0;
}
static int
stop(struct input_source *source)
{
int ret;
ret = libspotify_playback_stop();
if (ret < 0)
return -1;
return 0;
}
static int
seek(struct input_source *source, int seek_ms)
{
int ret;
ret = libspotify_playback_seek(seek_ms);
if (ret < 0)
return -1;
return ret;
}
struct input_definition input_libspotify =
{
.name = "libspotify",
.type = INPUT_TYPE_LIBSPOTIFY,
.disabled = 0,
.init = init,
.setup = setup,
.stop = stop,
.seek = seek,
};
// No-op for libspotify since it doesn't support logging in with the web api token
static int
login_token(const char *username, const char *token, const char **errmsg)
{
return 0;
}
static void
status_get(struct spotify_status *status)
{
struct spotify_status_info info = { 0 };
libspotify_status_info_get(&info);
status->installed = info.libspotify_installed;
status->logged_in = info.libspotify_logged_in;
status->has_podcast_support = false;
snprintf(status->username, sizeof(status->username), "%s", info.libspotify_user);
}
struct spotify_backend spotify_libspotify =
{
.init = libspotify_init,
.deinit = libspotify_deinit,
.login = libspotify_login,
.login_token = login_token,
.logout = libspotify_logout,
.relogin = libspotify_relogin,
.uri_register = libspotify_uri_register,
.status_get = status_get,
};

View File

@ -1621,9 +1621,6 @@ track_add(struct spotify_track *track, struct spotify_album *album, const char *
free_mfi(&mfi, 1);
}
// This is only required for the libspotify backend
spotify_uri_register(track->uri);
if (album && album->uri)
cache_artwork_ping(track->uri, album->mtime, 0);
else
@ -2053,9 +2050,7 @@ initscan(void)
/*
* Check that the playback Spotify backend can log in, so we don't add tracks
* to the library that can't be played. Also, libspotify needs to be logged in
* before before scanning tracks from the web since scanned tracks need to be
* registered for playback.
* to the library that can't be played.
*/
ret = spotify_relogin();
if (ret < 0)

View File

@ -76,9 +76,6 @@ static char *buildopts[] =
#ifdef SPOTIFY_LIBRESPOTC
"librespot-c",
#endif
#ifdef SPOTIFY_LIBSPOTIFY
"libspotify",
#endif
#ifdef LASTFM
"LastFM",
#else