diff options
author | Colin Fletcher <colin.m.fletcher@googlemail.com> | 2013-10-07 14:44:35 +0100 |
---|---|---|
committer | Colin Fletcher <colin.m.fletcher@googlemail.com> | 2013-10-07 14:59:40 +0100 |
commit | a3465ff5d3b830e79a0e383b3c85df0c8cc3af9e (patch) | |
tree | 1872ca71bce4a93eb1433d7d6d4637df843a844b /libs/ardour/export_handler.cc | |
parent | 15b4ebbb074ce679c5ea7fb44061934fe572cad5 (diff) |
Working Soundcloud export
Adds an 'upload' property to ExportFormatSpecification, to indicate that files
exported with that format specfication should be uploaded to Soundcloud, and
makes it editable in the export format dialogue.
Adds fields for the Soundcloud username & password to the file format selection
page, as well as an option to make the uploaded files public and open them in
the system browser.
Possible improvements not yet implemented:
- make upload happen in its own thread
- cosmetic tidying up of dialogue control layout
- remember username & password
Diffstat (limited to 'libs/ardour/export_handler.cc')
-rw-r--r-- | libs/ardour/export_handler.cc | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/libs/ardour/export_handler.cc b/libs/ardour/export_handler.cc index 4a6b0552c5..7ca6cb8c53 100644 --- a/libs/ardour/export_handler.cc +++ b/libs/ardour/export_handler.cc @@ -31,6 +31,9 @@ #include "ardour/export_status.h" #include "ardour/export_format_specification.h" #include "ardour/export_filename.h" +#include "ardour/soundcloud_upload.h" +#include "pbd/openuri.h" +#include "pbd/basename.h" #include "i18n.h" @@ -280,22 +283,50 @@ ExportHandler::finish_timespan () while (config_map.begin() != timespan_bounds.second) { ExportFormatSpecPtr fmt = config_map.begin()->second.format; + std::string filepath = config_map.begin()->second.filename->get_path(fmt); if (fmt->with_cue()) { - export_cd_marker_file (current_timespan, fmt, config_map.begin()->second.filename->get_path(fmt), CDMarkerCUE); + export_cd_marker_file (current_timespan, fmt, filepath, CDMarkerCUE); } if (fmt->with_toc()) { - export_cd_marker_file (current_timespan, fmt, config_map.begin()->second.filename->get_path(fmt), CDMarkerTOC); + export_cd_marker_file (current_timespan, fmt, filepath, CDMarkerTOC); } + if (fmt->upload()) { + SoundcloudUploader *soundcloud_uploader = new SoundcloudUploader; + std::string token = soundcloud_uploader->Get_Auth_Token(upload_username, upload_password); + std::cerr + << "uploading " + << filepath << std::endl + << "username = " << upload_username + << ", password = " << upload_password + << " - token = " << token << " ..." + << std::endl; + std::string path = soundcloud_uploader->Upload ( + filepath, + PBD::basename_nosuffix(filepath), // title + token, + upload_public, + this); + + if (path.length() != 0) { + if (upload_open) { + std::cerr << "opening " << path << " ..." << std::endl; + open_uri(path.c_str()); // open the soundcloud website to the new file + } + } else { + error << _("upload to Soundcloud failed. Perhaps your email or password are incorrect?\n") << endmsg; + } + delete soundcloud_uploader; + } config_map.erase (config_map.begin()); } start_timespan (); } -/*** CD Marker sutff ***/ +/*** CD Marker stuff ***/ struct LocationSortByStart { bool operator() (Location *a, Location *b) { |