From 600dca63b65ba9e2bcb5dced66fe325f84e5d715 Mon Sep 17 00:00:00 2001 From: "me@ow.nekobit.net" Date: Fri, 15 Apr 2022 03:42:09 +0000 Subject: [PATCH] Fix scrobble functions and set values correctly FossilOrigin-Name: bcf4568212e9d4ced1a597444d19b1b196778a0d9641989f351b7b260d45f951 --- include/mastodont.h | 1 + include/mastodont_scrobbles.h | 8 +++++--- src/scrobbles.c | 22 +++++++++++----------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/include/mastodont.h b/include/mastodont.h index 910f942..24ea041 100644 --- a/include/mastodont.h +++ b/include/mastodont.h @@ -23,6 +23,7 @@ #include #include #include +#include /* Functions required form curl */ void mastodont_global_curl_init(); diff --git a/include/mastodont_scrobbles.h b/include/mastodont_scrobbles.h index e37d06f..8817e0e 100644 --- a/include/mastodont_scrobbles.h +++ b/include/mastodont_scrobbles.h @@ -58,8 +58,10 @@ int mstdnt_scrobbles_result(struct mstdnt_fetch_results* results, struct mstdnt_scrobble* scrobbles[], size_t* size); -int _mstdnt_scrobbles_from_result_callback(struct mstdnt_fetch_results* results, - struct mstdnt_storage* storage, - void* arg); +int _mstdnt_scrobbles_result_callback(struct mstdnt_fetch_results* results, + struct mstdnt_storage* storage, + void* arg); + +int mstdnt_scrobble_json(struct mstdnt_scrobble* scrobble, cJSON* js); #endif /* MASTODONT_SCROBBLES_H */ diff --git a/src/scrobbles.c b/src/scrobbles.c index 654a2a0..924e552 100644 --- a/src/scrobbles.c +++ b/src/scrobbles.c @@ -20,7 +20,7 @@ #include #include -int mstdnt_scrobble_from_json(struct mstdnt_scrobble* scrobble, cJSON* js) +int mstdnt_scrobble_json(struct mstdnt_scrobble* scrobble, cJSON* js) { cJSON* v; @@ -29,12 +29,12 @@ int mstdnt_scrobble_from_json(struct mstdnt_scrobble* scrobble, cJSON* js) struct _mstdnt_val_ref vals[] = { { "account", &(scrobble->account), _mstdnt_val_account_call }, - { "album", &(scrobble->id), _mstdnt_val_string_call }, - { "artist", &(scrobble->id), _mstdnt_val_string_call }, - { "created_at", &(scrobble->id), _mstdnt_val_string_call }, + { "album", &(scrobble->album), _mstdnt_val_string_call }, + { "artist", &(scrobble->artist), _mstdnt_val_string_call }, + { "created_at", &(scrobble->created_at), _mstdnt_val_string_call }, { "id", &(scrobble->id), _mstdnt_val_string_call }, - { "length", &(scrobble->id), _mstdnt_val_uint_call }, - { "title", &(scrobble->id), _mstdnt_val_string_call } + { "length", &(scrobble->length), _mstdnt_val_uint_call }, + { "title", &(scrobble->title), _mstdnt_val_string_call } }; for (v = js; v; v = v->next) @@ -75,12 +75,12 @@ int mstdnt_scrobbles_result(struct mstdnt_fetch_results* results, } -int _mstdnt_scrobbles_from_result_callback(struct mstdnt_fetch_results* results, - struct mstdnt_storage* storage, - void* _args) +int _mstdnt_scrobbles_result_callback(struct mstdnt_fetch_results* results, + struct mstdnt_storage* storage, + void* _args) { struct _mstdnt_scrobbles_cb_args* args = _args; - return mstdnt_scrobbles_from_result(results, storage, args->scrobbles, args->size); + return mstdnt_scrobbles_result(results, storage, args->scrobbles, args->size); } int mastodont_get_scrobbles(mastodont_t* data, @@ -117,7 +117,7 @@ int mastodont_get_scrobbles(mastodont_t* data, NULL, 0, CURLOPT_HTTPGET, &cb_args, - _mstdnt_scrobbles_from_result_callback + _mstdnt_scrobbles_result_callback }; return mastodont_request(data, &req_args);