void
ExportDialog::do_export ()
{
- profile_manager->prepare_for_export ();
- handler->upload_username = soundcloud_selector->username();
- handler->upload_password = soundcloud_selector->password();
- handler->upload_public = soundcloud_selector->upload_public();
- handler->upload_open = soundcloud_selector->upload_open();
-
- handler->SoundcloudProgress.connect_same_thread(
- *this,
- boost::bind(&ExportDialog::soundcloud_upload_progress, this, _1, _2, _3)
- );
+ try {
+ profile_manager->prepare_for_export ();
++ handler->upload_username = soundcloud_selector->username();
++ handler->upload_password = soundcloud_selector->password();
++ handler->upload_public = soundcloud_selector->upload_public();
++ handler->upload_open = soundcloud_selector->upload_open();
++
++ handler->SoundcloudProgress.connect_same_thread(
++ *this,
++ boost::bind(&ExportDialog::soundcloud_upload_progress, this, _1, _2, _3)
++ );
+#if 0
- handler->SoundcloudProgress.connect(
- *this, invalidator (*this),
- boost::bind(&ExportDialog::soundcloud_upload_progress, this, _1, _2, _3),
- gui_context()
- );
++ handler->SoundcloudProgress.connect(
++ *this, invalidator (*this),
++ boost::bind(&ExportDialog::soundcloud_upload_progress, this, _1, _2, _3),
++ gui_context()
++ );
+#endif
- handler->do_export ();
- show_progress ();
+ handler->do_export ();
+ show_progress ();
+ } catch(std::exception & e) {
+ error << string_compose (_("Export initialization failed: %1"), e.what()) << endmsg;
+ notify_errors(true);
+ }
}
void
#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 "pbd/system_exec.h"
+ #include "ardour/session_metadata.h"
#include "i18n.h"
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);
+ std::string filename = config_map.begin()->second.filename->get_path(fmt);
if (fmt->with_cue()) {
- export_cd_marker_file (current_timespan, fmt, filepath, CDMarkerCUE);
- }
+ export_cd_marker_file (current_timespan, fmt, filename, CDMarkerCUE);
+ }
if (fmt->with_toc()) {
- export_cd_marker_file (current_timespan, fmt, filepath, CDMarkerTOC);
+ export_cd_marker_file (current_timespan, fmt, filename, CDMarkerTOC);
+ }
+
+ if (fmt->tag()) {
+ AudiofileTagger::tag_file(filename, *SessionMetadata::Metadata());
}
- { 'f', filepath },
- { 'd', Glib::path_get_dirname(filepath) },
- { 'b', PBD::basename_nosuffix(filepath) },
+ if (!fmt->command().empty()) {
+
+#if 0 // would be nicer with C++11 initialiser...
+ std::map<char, std::string> subs {
- subs.insert (std::pair<char, std::string> ('f', filepath));
- subs.insert (std::pair<char, std::string> ('d', Glib::path_get_dirname(filepath)));
- subs.insert (std::pair<char, std::string> ('b', PBD::basename_nosuffix(filepath)));
++ { 'f', filename },
++ { 'd', Glib::path_get_dirname(filename) },
++ { 'b', PBD::basename_nosuffix(filename) },
+ { 'u', upload_username },
+ { 'p', upload_password}
+ };
+#endif
+
+ PBD::ScopedConnection command_connection;
+ std::map<char, std::string> subs;
- << filepath << std::endl
++ subs.insert (std::pair<char, std::string> ('f', filename));
++ subs.insert (std::pair<char, std::string> ('d', Glib::path_get_dirname(filename)));
++ subs.insert (std::pair<char, std::string> ('b', PBD::basename_nosuffix(filename)));
+ subs.insert (std::pair<char, std::string> ('u', upload_username));
+ subs.insert (std::pair<char, std::string> ('p', upload_password));
+
+
+ std::cerr << "running command: " << fmt->command() << "..." << std::endl;
+ SystemExec *se = new SystemExec(fmt->command(), subs);
+ se->ReadStdout.connect_same_thread(command_connection, boost::bind(&ExportHandler::command_output, this, _1, _2));
+ if (se->start (2) == 0) {
+ // successfully started
+ std::cerr << "started!" << std::endl;
+ while (se->is_running ()) {
+ // wait for system exec to terminate
+ // std::cerr << "waiting..." << std::endl;
+ usleep (1000);
+ }
+ }
+ std::cerr << "done! deleting..." << std::endl;
+ delete (se);
+ }
+
+ if (fmt->upload()) {
+ SoundcloudUploader *soundcloud_uploader = new SoundcloudUploader;
+ std::string token = soundcloud_uploader->Get_Auth_Token(upload_username, upload_password);
+ std::cerr
+ << "uploading "
- filepath,
- PBD::basename_nosuffix(filepath), // title
++ << filename << std::endl
+ << "username = " << upload_username
+ << ", password = " << upload_password
+ << " - token = " << token << " ..."
+ << std::endl;
+ std::string path = soundcloud_uploader->Upload (
++ filename,
++ PBD::basename_nosuffix(filename), // 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());
}