From 6bd1fc943ee48209b78f6ca1fcb718b32e2b9b50 Mon Sep 17 00:00:00 2001 From: Goldenkrew3000 Date: Thu, 25 Sep 2025 11:24:14 +1000 Subject: [PATCH] Adding mini changes --- src/build.sh | 4 ++-- src/libopensubsonic/scrobble_lastFm.c | 23 ++++++++++++----------- src/libopensubsonic/scrobble_lastFm.h | 2 +- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/build.sh b/src/build.sh index aabca67..a71c71e 100755 --- a/src/build.sh +++ b/src/build.sh @@ -1,4 +1,4 @@ -egcc main.c \ +gcc main.c \ configHandler.c \ libopensubsonic/httpclient.c \ external/cJSON.c \ @@ -17,4 +17,4 @@ egcc main.c \ libopensubsonic/endpoint_getAlbumList.c \ libopensubsonic/endpoint_getStarred.c \ libopensubsonic/endpoint_scrobble.c \ - -o main -I/usr/local/include -L/usr/local/lib -lcurl + -o main -lcurl diff --git a/src/libopensubsonic/scrobble_lastFm.c b/src/libopensubsonic/scrobble_lastFm.c index 8214ff7..c838a23 100644 --- a/src/libopensubsonic/scrobble_lastFm.c +++ b/src/libopensubsonic/scrobble_lastFm.c @@ -180,8 +180,9 @@ char* opensubsonic_authenticate_lastFm(void) { * Sends a scrobble to LastFM * If 'finalize' is true, it sends to the track.scrobble endpoint * If 'finalize' is false, it sends to the track.updateNowPlaying endpoint + * Returns 1 if error, else 0 */ -void opensubsonic_scrobble_lastFm(bool finalize, opensubsonic_getSong_struct* songStruct) { +int opensubsonic_scrobble_lastFm(bool finalize, opensubsonic_getSong_struct* songStruct) { if (finalize) { logger_log_general(__func__, "Performing final scrobble to LastFM."); } else { @@ -194,8 +195,8 @@ void opensubsonic_scrobble_lastFm(bool finalize, opensubsonic_getSong_struct* so currentTime = time(NULL); rc = asprintf(¤tTime_string, "%ld", currentTime); if (rc == -1) { - logger_log_error(__func__, "asprintf() failed."); - return; // TODO return error + logger_log_error(__func__, "asprintf() failed (Could not make char* of UNIX timestamp)."); + return 1; } // Assemble the signature @@ -210,8 +211,8 @@ void opensubsonic_scrobble_lastFm(bool finalize, opensubsonic_getSong_struct* so configObj->lastfm_api_session_key, currentTime_string, songStruct->title, configObj->lastfm_api_secret); } if (rc == -1) { - logger_log_error(__func__, "asprintf() failed."); - return; // TODO handle error + logger_log_error(__func__, "asprintf() failed (Could not assemble plaintext signature)."); + return 1; } uint8_t sig_md5_bytes[16]; @@ -224,8 +225,8 @@ void opensubsonic_scrobble_lastFm(bool finalize, opensubsonic_getSong_struct* so sig_md5_bytes[8], sig_md5_bytes[9], sig_md5_bytes[10], sig_md5_bytes[11], sig_md5_bytes[12], sig_md5_bytes[13], sig_md5_bytes[14], sig_md5_bytes[15]); if (rc == -1) { - logger_log_error(__func__, "asprintf() failed."); - return; // TODO handle error + logger_log_error(__func__, "asprintf() failed (Could not assemble md5 signature)."); + return 1; } // URI encode strings @@ -233,13 +234,13 @@ void opensubsonic_scrobble_lastFm(bool finalize, opensubsonic_getSong_struct* so char* uri_songArtist = lcue_uriescape(songStruct->artist, (unsigned int)strlen(songStruct->artist)); char* uri_songAlbum = lcue_uriescape(songStruct->album, (unsigned int)strlen(songStruct->album)); if (uri_songTitle == NULL || uri_songArtist == NULL || uri_songAlbum == NULL) { - logger_log_error(__func__, "lcue_uriescape() error."); + logger_log_error(__func__, "lcue_uriescape() error (Could not URI escape required strings)."); free(currentTime_string); free(sig_md5_text); if (uri_songTitle != NULL) { free(uri_songTitle); } if (uri_songArtist != NULL) { free(uri_songArtist); } if (uri_songAlbum != NULL) { free(uri_songAlbum); } - return; // TODO return error + return 1; } // Assemble the payload @@ -263,8 +264,8 @@ void opensubsonic_scrobble_lastFm(bool finalize, opensubsonic_getSong_struct* so free(uri_songAlbum); free(uri_songArtist); if (rc == -1) { - logger_log_error(__func__, "asprintf() failed."); - return; // TODO return error + logger_log_error(__func__, "asprintf() failed (Could not assemble payload)."); + return 1; } // Send scrobble and receive response diff --git a/src/libopensubsonic/scrobble_lastFm.h b/src/libopensubsonic/scrobble_lastFm.h index c1157d0..de8fbab 100644 --- a/src/libopensubsonic/scrobble_lastFm.h +++ b/src/libopensubsonic/scrobble_lastFm.h @@ -4,6 +4,6 @@ #include "endpoint_getSong.h" char* opensubsonic_authenticate_lastFm(void); -void opensubsonic_scrobble_lastFm(bool finalize, opensubsonic_getSong_struct* songStruct); +int opensubsonic_scrobble_lastFm(bool finalize, opensubsonic_getSong_struct* songStruct); #endif