From 172b49a308dd83aec20068f2086690122396c0d8 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 21 May 2024 21:49:04 -0400 Subject: [PATCH] Broadcastify uploader fixes - 5.0 (#957) * upload call_info.call_json * remove filename upload * use log_header() --- .../broadcastify_uploader.cc | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/plugins/broadcastify_uploader/broadcastify_uploader.cc b/plugins/broadcastify_uploader/broadcastify_uploader.cc index 62e89a838..32b4426b1 100644 --- a/plugins/broadcastify_uploader/broadcastify_uploader.cc +++ b/plugins/broadcastify_uploader/broadcastify_uploader.cc @@ -137,14 +137,11 @@ class Broadcastify_Uploader : public Plugin_Api { mime = curl_mime_init(curl); part = curl_mime_addpart(mime); - curl_mime_filedata(part, call_info.status_filename); + curl_mime_data(part, call_info.call_json.dump().c_str(), CURL_ZERO_TERMINATED); + curl_mime_filename(part, "call_meta.json"); curl_mime_type(part, "application/json"); curl_mime_name(part, "metadata"); - part = curl_mime_addpart(mime); - curl_mime_data(part, call_info.converted, CURL_ZERO_TERMINATED); - curl_mime_name(part, "filename"); - part = curl_mime_addpart(mime); curl_mime_data(part, std::to_string(call_info.length).c_str(), CURL_ZERO_TERMINATED); curl_mime_name(part, "callDuration"); @@ -261,14 +258,16 @@ class Broadcastify_Uploader : public Plugin_Api { long response_code; curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code); + std::string loghdr = log_header(call_info.short_name,call_info.call_num,call_info.talkgroup_display,call_info.freq); + if (res != CURLM_OK || response_code != 200) { - BOOST_LOG_TRIVIAL(error) << "[" << call_info.short_name << "]\t\033[0;34m" << call_info.call_num << "C\033[0m\tTG: " << call_info.talkgroup_display << "\tFreq: " << format_freq(call_info.freq) << "\tBroadcastify Metadata Upload Error: " << response_buffer; + BOOST_LOG_TRIVIAL(error) << loghdr << "Broadcastify Metadata Upload Error: " << response_buffer; return 1; } std::size_t spacepos = response_buffer.find(' '); if (spacepos < 1) { - BOOST_LOG_TRIVIAL(error) << "[" << call_info.short_name << "]\t\033[0;34m" << call_info.call_num << "C\033[0m\tTG: " << call_info.talkgroup_display << "\tFreq: " << format_freq(call_info.freq) << "\tBroadcastify Metadata Upload Error: " << response_buffer; + BOOST_LOG_TRIVIAL(error) << loghdr << response_buffer; return 1; } @@ -276,30 +275,31 @@ class Broadcastify_Uploader : public Plugin_Api { std::string message = response_buffer.substr(spacepos + 1); if (code == "1" && (message.rfind("SKIPPED", 0) == 0)) { - BOOST_LOG_TRIVIAL(info) << "[" << call_info.short_name << "]\t\033[0;34m" << call_info.call_num << "C\033[0m\tTG: " << call_info.talkgroup_display << "\tFreq: " << format_freq(call_info.freq) << "\tBroadcastify Upload Skipped: " << message; + BOOST_LOG_TRIVIAL(info) << loghdr << "Broadcastify Upload Skipped: " << message; return 0; } + if (code == "1" && (message.rfind("REJECTED", 0) == 0)) { - BOOST_LOG_TRIVIAL(error) << "[" << call_info.short_name << "]\t\033[0;34m" << call_info.call_num << "C\033[0m\tTG: " << call_info.talkgroup_display << "\tFreq: " << format_freq(call_info.freq) << "\tBroadcastify Upload REJECTED: " << message; + BOOST_LOG_TRIVIAL(error) << loghdr << "Broadcastify Upload REJECTED: " << message; return 0; } if (code != "0") { - BOOST_LOG_TRIVIAL(error) << "[" << call_info.short_name << "]\t\033[0;34m" << call_info.call_num << "C\033[0m\tTG: " << call_info.talkgroup_display << "\tFreq: " << format_freq(call_info.freq) << "\tBroadcastify Metadata Upload Error: " << message; + BOOST_LOG_TRIVIAL(error) << loghdr << "Broadcastify Metadata Upload Error: " << message; return 1; } CURLcode audio_error = this->upload_audio_file(call_info.converted, message); if (audio_error) { - BOOST_LOG_TRIVIAL(error) << "[" << call_info.short_name << "]\t\033[0;34m" << call_info.call_num << "C\033[0m\tTG: " << call_info.talkgroup_display << "\tFreq: " << format_freq(call_info.freq) << "\tBroadcastify Audio Upload Error: " << curl_easy_strerror(audio_error); + BOOST_LOG_TRIVIAL(error) << loghdr << "Broadcastify Audio Upload Error: " << curl_easy_strerror(audio_error); return 1; } struct stat file_info; stat(call_info.converted, &file_info); - BOOST_LOG_TRIVIAL(info) << "[" << call_info.short_name << "]\t\033[0;34m" << call_info.call_num << "C\033[0m\tTG: " << call_info.talkgroup_display << "\tFreq: " << format_freq(call_info.freq) << "\tBroadcastify Upload Success - file size: " << file_info.st_size; + BOOST_LOG_TRIVIAL(info) << loghdr << "Broadcastify Upload Success - file size: " << file_info.st_size; return 0; } else { return 1;