From d83f804b43241e261fe88564f238cd9d43b913df Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 29 Aug 2020 00:15:41 +0200 Subject: Fix broken add rss by torrent name --- src/rss.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/rss.c') diff --git a/src/rss.c b/src/rss.c index c71c1ce..e81b44b 100644 --- a/src/rss.c +++ b/src/rss.c @@ -233,12 +233,12 @@ static int get_rss_url_from_episode_info(const char *episode_name, EpisodeInfo * char group_name_escaped[1536]; for(;;) { - printf("Enter the name of the submitter (leave empty to choose \"%s\" or type \"anon\" to choose all submitters: ", episode_info->group_name); + printf("Enter the name of the submitter (leave empty to choose \"%s\" or type \"anon\" to choose all submitters): ", episode_info->group_name); + fflush(stdout); if(!fgets(response, sizeof(response), stdin)) { fprintf(stderr, "Failed to read response from stdin\n"); return -1; } - fprintf(stderr, "response: %s\n", response); char *response_str = strip(response); if(strcmp(response, "anon") == 0) { @@ -247,7 +247,7 @@ static int get_rss_url_from_episode_info(const char *episode_name, EpisodeInfo * if(strlen(response_str) == 0) response_str = episode_info->group_name; - url_escape(response, group_name_escaped); + url_escape(response_str, group_name_escaped); char url[4096]; if(snprintf(url, sizeof(url), "https://nyaa.si/user/%s", group_name_escaped) >= (int)sizeof(url)) { fprintf(stderr, "Error: url is too long!\n"); @@ -274,6 +274,7 @@ static int get_rss_url_from_episode_info(const char *episode_name, EpisodeInfo * printf("Are you sure you want to track \"%s\" by %s after \"%s\" ? (Y)es/No: ", generic_name, selected_submitter, episode_name); else printf("Are you sure you want to track \"%s\" by all submitters after \"%s\" ? (Y)es/No: ", generic_name, episode_name); + fflush(stdout); char sresp[128]; if(!fgets(sresp, sizeof(sresp), stdin)) { @@ -291,10 +292,13 @@ static int get_rss_url_from_episode_info(const char *episode_name, EpisodeInfo * } } + char generic_name_escaped[2048]; + url_escape(generic_name, generic_name_escaped); + if(selected_submitter) - sprintf(rss_url, "https://nyaa.si/?page=rss&q=%s&c=0_0&f=0&u=%s", group_name_escaped, selected_submitter); + sprintf(rss_url, "https://nyaa.si/?page=rss&q=%s&c=0_0&f=0&u=%s", generic_name_escaped, group_name_escaped); else - sprintf(rss_url, "https://nyaa.si/?page=rss&q=%s&c=0_0&f=0", group_name_escaped); + sprintf(rss_url, "https://nyaa.si/?page=rss&q=%s&c=0_0&f=0", generic_name_escaped); return 0; } @@ -303,6 +307,7 @@ static int get_rss_url_from_episode_info(const char *episode_name, EpisodeInfo * /* Same for add_html */ int add_rss(const char *name, const char *url, char *rss_config_dir, const char *start_after) { int result = 0; + char rss_url[4096]; Buffer buffer; buffer_init(&buffer); @@ -314,7 +319,6 @@ int add_rss(const char *name, const char *url, char *rss_config_dir, const char goto cleanup; } - char rss_url[4096]; if(get_rss_url_from_episode_info(url, &episode_info, rss_url) != 0) goto cleanup; @@ -324,6 +328,8 @@ int add_rss(const char *name, const char *url, char *rss_config_dir, const char goto cleanup; } + url = rss_url; + buffer_clear(&buffer); result = download_to_buffer(url, &buffer); if(result != 0) { -- cgit v1.2.3