Compare commits
2 Commits
6189a8b17f
...
63f86aa8e4
Author | SHA1 | Date | |
---|---|---|---|
63f86aa8e4 | |||
c7faeb6bc8 |
@ -4,9 +4,10 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#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,28 @@ 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");
|
||||
/*Make the artist name URL safe.*/
|
||||
char *artist_name_esc = curl_easy_escape(curl, artist_name, 0);
|
||||
printf("%s", artist_name_esc);
|
||||
/*Format the MB URL to insert the Artist name for the query.*/
|
||||
snprintf(mb_url_full, sizeof(mb_url_full), mb_url, artist_name_esc);
|
||||
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 +141,7 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
|
||||
get_mb_id();
|
||||
get_mb_id("The Beatles");
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user