Skip to content

Various fixes #77

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

Open
wants to merge 3 commits into
base: main
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
13 changes: 12 additions & 1 deletion src/SpotifyArduino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,14 @@ int SpotifyArduino::makeRequestWithBody(const char *type, const char *command, c

client->println();

client->print(body);
if (strlen(body) == 0)
{
client->println();
}
else
{
client->print(body);
}

if (client->println() == 0)
{
Expand Down Expand Up @@ -615,6 +622,10 @@ int SpotifyArduino::getCurrentlyPlaying(processCurrentlyPlaying currentlyPlaying
{
current.currentlyPlayingType = episode;
}
else if (strcmp(currently_playing_type, "ad") == 0)
{
current.currentlyPlayingType = ad;
}
else
{
current.currentlyPlayingType = other;
Expand Down
7 changes: 4 additions & 3 deletions src/SpotifyArduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ enum SpotifyPlayingType
{
track,
episode,
ad,
other
};

Expand Down Expand Up @@ -226,9 +227,9 @@ class SpotifyArduino

private:
char _bearerToken[SPOTIFY_ACCESS_TOKEN_LENGTH + 10]; //10 extra is for "bearer " at the start
char *_refreshToken;
const char *_clientId;
const char *_clientSecret;
char *_refreshToken = nullptr;
const char *_clientId = nullptr;
const char *_clientSecret = nullptr;
unsigned int timeTokenRefreshed;
unsigned int tokenTimeToLiveMs;
int commonGetImage(char *imageUrl);
Expand Down