aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-08-29 00:15:41 +0200
committerdec05eba <dec05eba@protonmail.com>2020-08-29 00:15:41 +0200
commitd83f804b43241e261fe88564f238cd9d43b913df (patch)
treea87967231f54aeb15a2cdf56d9a3b6bf20acc59f
parentc76c8696bc66437fdffb52f87a15b338df3b93cc (diff)
Fix broken add rss by torrent name
-rwxr-xr-xautomediabin116592 -> 116632 bytes
-rw-r--r--src/program.c2
-rw-r--r--src/rss.c18
3 files changed, 14 insertions, 6 deletions
diff --git a/automedia b/automedia
index c270422..76e5785 100755
--- a/automedia
+++ b/automedia
Binary files differ
diff --git a/src/program.c b/src/program.c
index be4f8cc..00f242b 100644
--- a/src/program.c
+++ b/src/program.c
@@ -92,6 +92,7 @@ int program_exec(const char **args, ProgramOutputCallback output_callback, void
close(fd[WRITE_END]);
int result = program_read_output(pid, fd[READ_END], output_callback, userdata);
+ /*
if(result != 0) {
fprintf(stderr, "Failed to execute program (");
const char **arg = args;
@@ -103,6 +104,7 @@ int program_exec(const char **args, ProgramOutputCallback output_callback, void
}
fprintf(stderr, ")\n");
}
+ */
close(fd[READ_END]);
return result;
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) {