Skip to content

Commit

Permalink
Include audio runtime in metadata for Archive
Browse files Browse the repository at this point in the history
  • Loading branch information
redrun45 committed Dec 17, 2024
1 parent 740852f commit bdea9e3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
11 changes: 4 additions & 7 deletions application/controllers/private/Iarchive_upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <br /> 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();
Expand All @@ -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);

Expand All @@ -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);
Expand Down Expand Up @@ -147,18 +147,15 @@ 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');
$runtime = $this->section_model->get_total_project_runtime($project->id);

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)
Expand Down
1 change: 1 addition & 0 deletions application/libraries/Iarchive_uploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit bdea9e3

Please sign in to comment.