use curl_escape on artist and title tags

This commit is contained in:
Andrzej Rybczak
2009-01-28 22:37:46 +01:00
parent b2d3fef275
commit b8f73ae6a6

View File

@@ -111,7 +111,11 @@ void * GetArtistInfo(void *ptr)
CURLcode code;
string url = "http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=" + artist + "&api_key=d94e5b6e26469a2d1ffae8ef20131b79";
char *c_artist = curl_easy_escape(0, artist.c_str(), artist.length());
string url = "http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=";
url += c_artist;
url += "&api_key=d94e5b6e26469a2d1ffae8ef20131b79";
pthread_mutex_lock(&curl);
CURL *info = curl_easy_init();
@@ -124,6 +128,8 @@ void * GetArtistInfo(void *ptr)
curl_easy_cleanup(info);
pthread_mutex_unlock(&curl);
curl_free(c_artist);
if (code != CURLE_OK)
{
*sInfo << "Error while fetching artist's info: " << curl_easy_strerror(code);
@@ -285,10 +291,13 @@ void *GetLyrics(void *song)
string result;
char *c_artist = curl_easy_escape(0, artist.c_str(), artist.length());
char *c_title = curl_easy_escape(0, title.c_str(), title.length());
string url = "http://lyricwiki.org/api.php?artist=";
url += artist;
url += c_artist;
url += "&song=";
url += title;
url += c_title;
url += "&fmt=xml";
pthread_mutex_lock(&curl);
@@ -302,6 +311,9 @@ void *GetLyrics(void *song)
curl_easy_cleanup(lyrics);
pthread_mutex_unlock(&curl);
curl_free(c_artist);
curl_free(c_title);
if (code != CURLE_OK)
{
*sLyrics << "Error while fetching lyrics: " << curl_easy_strerror(code);