ARD: proper cleanup
[ardour.git] / libs / ardour / soundcloud_upload.cc
index ab3a20480b6a485bcbcea653c3cfa668337a90fe..da887d49f50cc0784b3dd324bf6290026a1c1b38 100644 (file)
 
 
 *************************************************************************************/
+#include "ardour/debug.h"
 #include "ardour/soundcloud_upload.h"
 
 #include "pbd/xml++.h"
 #include <pbd/error.h>
-//#include "pbd/filesystem.h"
 
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -35,8 +35,6 @@
 
 using namespace PBD;
 
-// static const std::string base_url = "http://api.soundcloud.com/tracks/13158665?client_id=";
-
 size_t
 WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data)
 {
@@ -78,13 +76,13 @@ SoundcloudUploader::Get_Auth_Token( std::string username, std::string password )
        curl_formadd(&formpost,
                        &lastptr,
                        CURLFORM_COPYNAME, "client_id",
-                       CURLFORM_COPYCONTENTS, "e7ac891eef866f139773cf8102b7a719",
+                       CURLFORM_COPYCONTENTS, "6dd9cf0ad281aa57e07745082cec580b",
                        CURLFORM_END);
 
        curl_formadd(&formpost,
                        &lastptr,
                        CURLFORM_COPYNAME, "client_secret",
-                       CURLFORM_COPYCONTENTS, "d78f34d19f09d26731801a0cb0f382c4",
+                       CURLFORM_COPYCONTENTS, "53f5b0113fb338800f8a7a9904fc3569",
                        CURLFORM_END);
 
        curl_formadd(&formpost,
@@ -119,13 +117,13 @@ SoundcloudUploader::Get_Auth_Token( std::string username, std::string password )
 
        // perform online request
        CURLcode res = curl_easy_perform(curl_handle);
-       if( res != 0 ) {
-               std::cerr << "curl error " << res << " (" << curl_easy_strerror(res) << ")" << std::endl;
+       if (res != 0) {
+               DEBUG_TRACE (DEBUG::Soundcloud, string_compose ("curl error %1 (%2)", res, curl_easy_strerror(res) ) );
                return "";
        }
 
-       if(xml_page.memory){
-               //cheesy way to parse the json return value.  find access_token, then advance 3 quotes
+       if (xml_page.memory){
+               // cheesy way to parse the json return value.  find access_token, then advance 3 quotes
 
                if ( strstr ( xml_page.memory , "access_token" ) == NULL) {
                        error << _("Upload to Soundcloud failed.  Perhaps your email or password are incorrect?\n") << endmsg;
@@ -148,7 +146,7 @@ int
 SoundcloudUploader::progress_callback(void *caller, double dltotal, double dlnow, double ultotal, double ulnow)
 {
        SoundcloudUploader *scu = (SoundcloudUploader *) caller;
-       std::cerr << scu->title << ": uploaded " << ulnow << " of " << ultotal << std::endl;
+       DEBUG_TRACE (DEBUG::Soundcloud, string_compose ("%1: uploaded %2 of %3", scu->title, ulnow, ultotal) );
        scu->caller->SoundcloudProgress(ultotal, ulnow, scu->title); /* EMIT SIGNAL */
        return 0;
 }
@@ -297,26 +295,26 @@ SoundcloudUploader::Upload(std::string file_path, std::string title, std::string
 
        if(xml_page.memory){
 
-               std::cout << xml_page.memory << std::endl;
+               DEBUG_TRACE (DEBUG::Soundcloud, xml_page.memory);
 
                XMLTree doc;
                doc.read_buffer( xml_page.memory );
                XMLNode *root = doc.root();
 
                if (!root) {
-                       std::cout << "no root XML node!" << std::endl;
+                       DEBUG_TRACE (DEBUG::Soundcloud, "no root XML node!");
                        return "";
                }
 
                XMLNode *url_node = root->child("permalink-url");
                if (!url_node) {
-                       std::cout << "no child node \"permalink-url\" found!" << std::endl;
+                       DEBUG_TRACE (DEBUG::Soundcloud, "no child node \"permalink-url\" found!");
                        return "";
                }
 
                XMLNode *text_node = url_node->child("text");
                if (!text_node) {
-                       std::cout << "no text node found!" << std::endl;
+                       DEBUG_TRACE (DEBUG::Soundcloud, "no text node found!");
                        return "";
                }