diff --git a/get_artist_art.c b/get_artist_art.c index b955184..45a0dd8 100644 --- a/get_artist_art.c +++ b/get_artist_art.c @@ -4,9 +4,10 @@ #include #include +#define version_str "1.0" #define conf_file "config.ini" #define mb_url \ - "https://musicbrainz.org/ws/2/artist?query=artist:\"Slayer\"&fmt=json" + "https://musicbrainz.org/ws/2/artist?query=artist:\"%s\"&fmt=json" const char *get_conf_str(char set_key[]) { const char *prog_conf = malloc(10 * sizeof(char)); @@ -65,21 +66,27 @@ void print_conf(const char m_dir[], const int mb_conf, } } -const char *get_mb_id() { +const char *get_mb_id(char *artist_name) { int response_code; const char *mb_id; CURL *curl; CURLcode res; char *buffer; long res_len; + char mb_url_full[100]; curl_global_init(CURL_GLOBAL_DEFAULT); curl = curl_easy_init(); if (curl) { - curl_easy_setopt(curl, CURLOPT_URL, mb_url); - curl_easy_setopt(curl, CURLOPT_USERAGENT, "get_artist_art.py/1.0"); + char *artist_name_esc = curl_easy_escape(curl, artist_name, 0); + printf("%s", artist_name_esc); + snprintf(mb_url_full, sizeof(mb_url_full), mb_url, artist_name_esc); + // snprintf(mb_url_full, sizeof(mb_url_full), "%s", curl_easy_escape(curl, mb_url_full, 0)); + printf("%s\n", mb_url_full); + curl_easy_setopt(curl, CURLOPT_URL, mb_url_full); + curl_easy_setopt(curl, CURLOPT_USERAGENT, "get_artist_art.py/1.0"); res = curl_easy_perform(curl); @@ -133,7 +140,7 @@ int main(int argc, char **argv) { } } - get_mb_id(); + get_mb_id("The Beatles"); return EXIT_SUCCESS; } \ No newline at end of file