Merge pull request #9341 from BarryJRowe/master

Added in fixes for using config parameters instead of the ai service url
This commit is contained in:
Twinaphex 2019-08-23 03:28:05 +02:00 committed by GitHub
commit 396d6c6ad9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3196,6 +3196,11 @@ static bool run_translation_service(void)
strlcpy(new_ai_service_url,
settings->arrays.ai_service_url, sizeof(new_ai_service_url));
/* if query already exists in url, then use &'s instead */
if (strrchr(new_ai_service_url, '?') != NULL)
separator = '&';
/* source lang */
if (settings->uints.ai_service_source_lang != TRANSLATION_LANG_DONT_CARE)
{
const char *lang_source = ai_service_get_str(
@ -3203,15 +3208,16 @@ static bool run_translation_service(void)
if (!string_is_empty(lang_source))
{
snprintf(new_ai_service_url,
sizeof(new_ai_service_url),
"%csource_lang=", separator);
char temp_string[PATH_MAX_LENGTH];
snprintf(temp_string,
sizeof(temp_string),
"%csource_lang=%s", separator, lang_source);
separator = '&';
strlcat(new_ai_service_url, lang_source,
sizeof(new_ai_service_url));
strlcat(new_ai_service_url, temp_string, sizeof(new_ai_service_url));
}
}
/* target lang */
if (settings->uints.ai_service_target_lang != TRANSLATION_LANG_DONT_CARE)
{
const char *lang_target = ai_service_get_str(
@ -3219,15 +3225,36 @@ static bool run_translation_service(void)
if (!string_is_empty(lang_target))
{
snprintf(new_ai_service_url,
sizeof(new_ai_service_url),
"%ctarget_lang=", separator);
char temp_string[PATH_MAX_LENGTH];
snprintf(temp_string,
sizeof(temp_string),
"%ctarget_lang=%s", separator, lang_target);
separator = '&';
strlcat(new_ai_service_url, lang_target,
strlcat(new_ai_service_url, temp_string,
sizeof(new_ai_service_url));
}
}
/* mode */
{
char temp_string[PATH_MAX_LENGTH];
char* mode_chr = "image";
if (settings->uints.ai_service_mode == 1)
mode_chr = "sound";
snprintf(temp_string,
sizeof(temp_string),
"%coutput=%s", separator, mode_chr);
separator = '&';
strlcat(new_ai_service_url, temp_string,
sizeof(new_ai_service_url));
}
RARCH_LOG("Server URL: %s\n", new_ai_service_url);
task_push_http_post_transfer(new_ai_service_url,
json_buffer, true, NULL, handle_translation_cb, NULL);