From cff81a0630937e0ffd59198a43a18f6c2b66b19a Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 5 Mar 2021 11:23:10 +0100 Subject: Fix start after --- src/rss_html_common.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/rss_html_common.c b/src/rss_html_common.c index e8e98a5..c72273c 100644 --- a/src/rss_html_common.c +++ b/src/rss_html_common.c @@ -21,24 +21,26 @@ int write_plugin_json_to_file(const char *dir, const char *filename, const char if(plugin_name) cJSON_AddStringToObject(json_body, "plugin", plugin_name); - cJSON *downloaded_item_json = cJSON_CreateObject(); - if(!downloaded_item_json) { + cJSON *downloaded_json = cJSON_AddArrayToObject(json_body, "downloaded"); + if(!downloaded_json) { result = -1; goto cleanup; } - if(start_after) + if(start_after) { + cJSON *downloaded_item_json = cJSON_CreateObject(); + if(!downloaded_item_json) { + result = -1; + goto cleanup; + } + cJSON_AddStringToObject(downloaded_item_json, "title", start_after); - if(start_after_url) - cJSON_AddStringToObject(downloaded_item_json, "url", start_after_url); - cJSON_AddStringToObject(downloaded_item_json, "time", updated); + cJSON_AddStringToObject(downloaded_item_json, "time", updated); + if(start_after_url) + cJSON_AddStringToObject(downloaded_item_json, "url", start_after_url); - cJSON *downloaded_json = cJSON_AddArrayToObject(json_body, "downloaded"); - if(!downloaded_json) { - result = -1; - goto cleanup; + cJSON_AddItemToArray(downloaded_json, downloaded_item_json); } - cJSON_AddItemToArray(downloaded_json, downloaded_item_json); char *json_body_str = cJSON_Print(json_body); if(!json_body_str) { -- cgit v1.2.3