Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to be compatible with latest version of libspotify #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
key.h
Makefile.local.mk
*.o
**/polspot
user_agent.h
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Requirements:

1. libspotify 0.9.x (available from the Spotify developer site)

2. libevent 2.0.x (available from http://libevent.org)

3. A developer API key from the Spotify developer site

4. A premium account with Spotify

To build using libspotify:

1. Update your Makefile.local.mk to uncomment the line LIBSPOTIFY = 1

2. Copy your key.h file to the base of this repo

3. $ make

2 changes: 1 addition & 1 deletion src/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define POLSPOT_AUDIO_H

#include <pthread.h>
#include <spotify/api.h>
#include <libspotify/api.h>

typedef struct audio {
pthread_t thread;
Expand Down
25 changes: 5 additions & 20 deletions src/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void sess_init(struct event_base *evbase)
.userdata = &g_session
};

sp_error err = sp_session_init(&config, &g_session.spotify);
sp_error err = sp_session_create(&config, &g_session.spotify);

if (err != SP_ERROR_OK)
panic("sp_session_init() failed: %s", sp_error_message(err));
Expand Down Expand Up @@ -196,10 +196,7 @@ void sess_connect()
sess_disconnect();

// Login with credentials set by sess_username/sess_password.
sp_error err = sp_session_login(g_session.spotify, g_session.username, g_session.password);

if (err != SP_ERROR_OK)
panic("sp_session_login() failed: %s", sp_error_message(err));
sp_session_login(g_session.spotify, g_session.username, g_session.password, 0);

log_append("Connecting...");

Expand All @@ -214,10 +211,7 @@ void sess_disconnect()
if (g_session.state == SESS_ONLINE) {
sess_stop();

sp_error err = sp_session_logout(g_session.spotify);

if (err != SP_ERROR_OK)
panic("sp_session_logout() failed: %s", sp_error_message(err));
sp_session_logout(g_session.spotify);

log_append("Disconnecting...");
g_session.state = SESS_DISCONNECTING;
Expand Down Expand Up @@ -283,11 +277,6 @@ void sess_play(sp_track *t)
return;
}

if (!t || !sp_track_is_available(t) || !sp_track_is_loaded(t)) {
log_append("Track not available");
return;
}

sess_stop();

g_session.current_track = t;
Expand All @@ -298,9 +287,7 @@ void sess_play(sp_track *t)
if (err != SP_ERROR_OK)
panic("sp_session_player_load() failed: %s", sp_error_message(err));

err = sp_session_player_play(g_session.spotify, true);
if (err != SP_ERROR_OK)
panic("sp_session_player_play() failed: %s", sp_error_message(err));
sp_session_player_play(g_session.spotify, true);

g_session.playing = true;

Expand Down Expand Up @@ -347,9 +334,7 @@ void sess_pause()
return;

g_session.paused = !g_session.paused;
sp_error err = sp_session_player_play(g_session.spotify, !g_session.paused);
if (err != SP_ERROR_OK)
panic("sp_session_player_play() failed: %s", sp_error_message(err));
sp_session_player_play(g_session.spotify, !g_session.paused);


if (g_session.paused) {
Expand Down
2 changes: 1 addition & 1 deletion src/session.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define POLSPOT_SESSION_H

#include <event2/event.h>
#include <spotify/api.h>
#include <libspotify/api.h>

typedef enum sess_state {
SESS_OFFLINE,
Expand Down
2 changes: 1 addition & 1 deletion src/ui_tracklist.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void tracklist_draw(ui_t *ui)
if (i + line == g_pos)
mvwchgat(ui->win, line + 1, 0, -1,
(ui->flags & UI_FLAG_FOCUS ? A_REVERSE : A_BOLD),
(sp_track_is_available(t) ? UI_STYLE_NORMAL : UI_STYLE_NA), NULL);
(true ? UI_STYLE_NORMAL : UI_STYLE_NA), NULL);

++line;
}
Expand Down