\r
#include "ardour/audio_library.h"\r
\r
+using namespace PBD;\r
+\r
static const std::string base_url = "http://www.freesound.org/api";\r
static const std::string api_key = "9d77cb8d841b4bcfa960e1aae62224eb"; // ardour3\r
\r
-\r
//------------------------------------------------------------------------\r
Mootcher::Mootcher()\r
: curl(curl_easy_init())\r
}\r
\r
curl_easy_setopt(curl, CURLOPT_URL, url.c_str() );\r
- std::cerr << "doRequest: " << url << std::endl;\r
\r
// perform online request\r
CURLcode res = curl_easy_perform(curl);\r
if( res != 0 ) {\r
- std::cerr << "curl error " << res << " (" << curl_easy_strerror(res) << ")" << std::endl;\r
+ error << string_compose (_("curl error %1 (%2)"), res, curl_easy_strerror(res)) << endmsg;\r
return "";\r
}\r
\r
snprintf(buf, 23, "p=%d&", page);\r
params += buf;\r
}\r
- \r
- params += "q=" + query; \r
\r
- if (filter != "")\r
- params += "&f=" + filter;\r
+ char *eq = curl_easy_escape(curl, query.c_str(), query.length());\r
+ params += "q=\"" + std::string(eq) + "\"";\r
+ free(eq);\r
+\r
+ if (filter != "") {\r
+ char *ef = curl_easy_escape(curl, filter.c_str(), filter.length());\r
+ params += "&f=" + std::string(ef);\r
+ free(ef);\r
+ }\r
\r
if (sort)\r
params += "&s=" + sortMethodString(sort);\r
\r
- params += "&fields=id,original_filename,duration,serve"; \r
+ params += "&fields=id,original_filename,duration,filesize,samplerate,license,serve";\r
\r
return doRequest("/sounds/search", params);\r
}\r
std::string xml;\r
\r
\r
- std::cerr << "getSoundResourceFile(" << ID << ")" << std::endl;\r
-\r
// download the xmlfile into xml_page\r
xml = doRequest("/sounds/" + ID, "");\r
\r
\r
// if the page is not a valid xml document with a 'freesound' root\r
if (freesound == NULL) {\r
- std::cerr << "getSoundResourceFile: There is no valid root in the xml file" << std::endl;\r
+ error << _("getSoundResourceFile: There is no valid root in the xml file") << endmsg;\r
return "";\r
}\r
\r
if (strcmp(doc.root()->name().c_str(), "response") != 0) {\r
- std::cerr << "getSoundResourceFile: root =" << doc.root()->name() << ", != response" << std::endl;\r
+ error << string_compose (_("getSoundResourceFile: root = %1, != response"), doc.root()->name()) << endmsg;\r
return "";\r
}\r
\r
if (testFile) { \r
fseek (testFile , 0 , SEEK_END);\r
if (ftell (testFile) > 256) {\r
- std::cerr << "audio file " << audioFileName << " already exists" << std::endl;\r
fclose (testFile);\r
return audioFileName;\r
}\r
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, audioFileWrite);\r
curl_easy_setopt(curl, CURLOPT_WRITEDATA, theFile);\r
\r
- std::cerr << "downloading " << audioFileName << " from " << audioURL << "..." << std::endl;\r
/* hack to get rid of the barber-pole stripes */\r
caller->freesound_progress_bar.hide();\r
caller->freesound_progress_bar.show();\r
\r
std::string prog;\r
- prog = string_compose (_("%1: [Stop]->"), originalFileName);\r
+ prog = string_compose (_("%1"), originalFileName);\r
caller->freesound_progress_bar.set_text(prog);\r
\r
curl_easy_setopt (curl, CURLOPT_NOPROGRESS, 0); // turn on the progress bar\r
caller->freesound_progress_bar.set_text("");\r
\r
if( res != 0 ) {\r
- std::cerr << "curl error " << res << " (" << curl_easy_strerror(res) << ")" << std::endl;\r
+ error << string_compose (_("curl error %1 (%2)"), res, curl_easy_strerror(res)) << endmsg;\r
remove( audioFileName.c_str() ); \r
return "";\r
} else {\r
- std::cerr << "done!" << std::endl;\r
// now download the tags &c.\r
getSoundResourceFile(ID);\r
}\r
while (Glib::MainContext::get_default()->iteration (false)) {\r
/* do nothing */\r
}\r
- std::cerr << "progress: " << dlnow << " of " << dltotal << " \r";\r
return 0;\r
}\r
\r