From 6d1acf2f01a08e523c5a185cb3ca0ce2fb878dfa Mon Sep 17 00:00:00 2001 From: redrun Date: Sun, 8 Dec 2024 00:17:41 -0600 Subject: [PATCH] Include audio runtime in metadata for Archive Fixes #132. --- application/controllers/private/Iarchive_upload.php | 11 ++++------- application/libraries/Iarchive_uploader.php | 1 + 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/application/controllers/private/Iarchive_upload.php b/application/controllers/private/Iarchive_upload.php index 2548a838..2c34963d 100644 --- a/application/controllers/private/Iarchive_upload.php +++ b/application/controllers/private/Iarchive_upload.php @@ -51,6 +51,7 @@ public function upload() $description = $this->_get_full_description($params, $project); $params['description'] = _normalize_and_deduplicate_newlines_in_html($description); //Standardizes whitespace, replacing newlines with
tags $params['language'] = $this->data['language_code']; + $params['totaltime'] = $this->_get_total_runtime($project); // Close db connection before uploading to avoid hogging connections $this->db->close(); @@ -73,6 +74,7 @@ public function upload() //update the project $update['url_iarchive'] = $config['iarchive_project_page'] . '/' . $params['project_slug']; $update['zip_url'] = 'https://www.archive.org/download/' . $params['project_slug'] . '/' . $params['project_slug'] . '_64kb_mp3.zip'; + $update['totaltime'] = $params['totaltime']; $this->project_model->update($project->id, $update); @@ -84,8 +86,6 @@ public function upload() $this->_update_section_sizes($project); - $this->_update_total_runtime($project); - $this->_update_total_zipsize($project); $this->ajax_output(array('message' => 'Success', 'link' => $link, 'files' => $files, 'params' => $params, 'retval' => $retval), true); @@ -147,7 +147,7 @@ function _update_section_sizes($project) return $this->section_model->update_section_sizes($project->id); } - function _update_total_runtime($project) + function _get_total_runtime($project) { $this->load->helper('previewer'); $this->load->model('section_model'); @@ -155,10 +155,7 @@ function _update_total_runtime($project) if (empty($runtime)) $runtime = 0; - $totaltime = format_playtime($runtime); - - $this->load->model('project_model'); - $this->project_model->update($project->id, array('totaltime' => $totaltime)); + return format_playtime($runtime); } function _update_total_zipsize($project) diff --git a/application/libraries/Iarchive_uploader.php b/application/libraries/Iarchive_uploader.php index c4aceca8..65235b0a 100644 --- a/application/libraries/Iarchive_uploader.php +++ b/application/libraries/Iarchive_uploader.php @@ -70,6 +70,7 @@ function curl($params) $headers[] = 'x-archive-meta-subject:'.$params['subject']; $headers[] = 'x-archive-meta-licenseurl:'.$params['licenseurl']; $headers[] = 'x-archive-meta-call--number:'.$params['project_id']; + $headers[] = 'x-archive-meta-runtime:'.$params['totaltime']; curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);