aboutsummaryrefslogtreecommitdiff
path: root/src/html.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/html.c')
-rw-r--r--src/html.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/html.c b/src/html.c
index cb9904e..40cc1eb 100644
--- a/src/html.c
+++ b/src/html.c
@@ -327,7 +327,7 @@ int add_html(const char *name, const char *url, char *html_config_dir, char *pro
}
/*
- Create an ".in_progress" file to prevent periodic sync from reading rss data
+ Create an ".in_progress" file to prevent periodic sync from reading html data
before we have finished adding all the data.
*/
remove(in_progress_filepath);
@@ -364,7 +364,7 @@ int add_html(const char *name, const char *url, char *html_config_dir, char *pro
}
size_t num_download_items = download_items_start ? (((DownloadItemsData*)buffer_end(&download_items_buffer)) - download_items_start) : 0;
- result = write_plugin_json_to_file(html_tracked_dir, "data", url, updated, download_items_start, num_download_items, plugin_name);
+ result = write_plugin_json_to_file(html_tracked_dir, "data", url, updated, download_items_start, num_download_items, plugin_name, NULL);
if(result != 0) {
fprintf(stderr, "Failed to create %s/data\n", html_tracked_dir);
remove_recursive(html_tracked_dir);
@@ -382,7 +382,7 @@ static int int_min(int a, int b) {
return a < b ? a : b;
}
-static int download_html_items_in_reverse(const char *plugin_filepath, Buffer *download_items_buffer, TrackedHtml *tracked_html, char *html_tracked_dir, const char *download_dir) {
+static int download_html_items_in_reverse(const char *plugin_filepath, Buffer *download_items_buffer, TrackedHtml *tracked_html, char *html_tracked_dir, const char *download_dir, bool show_error_notifications) {
const char *home_dir = get_home_dir();
char download_finished_script[PATH_MAX];
@@ -426,8 +426,10 @@ static int download_html_items_in_reverse(const char *plugin_filepath, Buffer *d
if(result != 0)
fprintf(stderr, "Failed while downloading html, url: %s\n", download_items_it->link);
- const char *notify_args[] = { "notify-send", "-a", "automedia", "-u", result == 0 ? "normal" : "critical", "-t", "10000", "--", result == 0 ? "Download finished" : "Download failed", notify_msg, NULL };
- program_exec(notify_args, NULL, NULL);
+ if(result == 0 || show_error_notifications) {
+ const char *notify_args[] = { "notify-send", "-a", "automedia", "-u", result == 0 ? "low" : "critical", "-t", "5000", "--", result == 0 ? "Download finished" : "Download failed", notify_msg, NULL };
+ program_exec(notify_args, NULL, NULL);
+ }
if(result != 0)
break;
@@ -447,16 +449,15 @@ static int download_html_items_in_reverse(const char *plugin_filepath, Buffer *d
TrackedItem tracked_item;
tracked_item.title = tracked_html->title;
- tracked_item.link = tracked_html->link;
tracked_item.json_data = tracked_html->json_data;
- result = tracked_item_update_latest(&tracked_item, html_tracked_dir, added_download_items, NULL, timestamps, download_item_index);
+ result = tracked_item_update_latest(&tracked_item, html_tracked_dir, added_download_items, NULL, timestamps, download_item_index, NULL);
buffer_deinit(&json_element_buffer);
return result;
}
/* TODO: Make asynchronous. Right now this will only complete when the whole chapter download completes */
-int sync_html(TrackedHtml *tracked_html, char *program_dir, const char *download_dir, char *html_config_dir) {
+int sync_html(TrackedHtml *tracked_html, char *program_dir, const char *download_dir, char *html_config_dir, bool show_error_notifications) {
/* TODO: This can be cached */
int html_config_dir_len = strlen(html_config_dir);
@@ -487,7 +488,7 @@ int sync_html(TrackedHtml *tracked_html, char *program_dir, const char *download
char *html_tracked_dir = html_config_dir;
strcat(html_tracked_dir, "/tracked/");
- result = download_html_items_in_reverse(plugin_filepath, &download_items_buffer, tracked_html, html_tracked_dir, download_dir);
+ result = download_html_items_in_reverse(plugin_filepath, &download_items_buffer, tracked_html, html_tracked_dir, download_dir, show_error_notifications);
if(result != 0) {
fprintf(stderr, "Failed while download html item for url: %s\n", tracked_html->link);
goto cleanup;