diff options
author | dec05eba <dec05eba@protonmail.com> | 2025-03-19 22:07:09 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2025-03-19 22:07:09 +0100 |
commit | e9ff36f9985e669317043f80b8edf5d17d4c0c3e (patch) | |
tree | 52d735151c165cb5575d479bf8edcccbe6142f93 /src/html.c | |
parent | 9d030864b347cea5bfda842a535312e41e9d0f75 (diff) |
Diffstat (limited to 'src/html.c')
-rw-r--r-- | src/html.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -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 ? "low" : "critical", "-t", "5000", "--", 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; @@ -455,7 +457,7 @@ static int download_html_items_in_reverse(const char *plugin_filepath, Buffer *d } /* 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); @@ -486,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; |