Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 3 additions & 52 deletions application/controllers/private/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,8 @@ function copy_project_files()
{
$file_name = $this->_copy_file($local_file, $copy_to_dir);
}
else
{
$file_name = $this->_get_file($section->listen_url, $copy_to_dir);
}

if (!$file_name) continue;
if (!$local_file or !$file_name) continue;

$file_name = trim($file_name);
$file_path = $copy_to_dir . '/' . $file_name;
Expand All @@ -328,7 +324,7 @@ function copy_project_files()
$this->librivox_id3tag->_update_section($section->id, array('file_name' => $file_name, 'playtime' => $playtime));
}

$this->ajax_output(array('message' => 'Files copied.', 'tags' => $tag_data, 'full_tags' => $fullid3_tags), TRUE);
$this->ajax_output(array('message' => 'Files copied.'), TRUE);
}

function get_file_tags()
Expand Down Expand Up @@ -528,38 +524,6 @@ function _copy_file($local_file, $copy_to_dir)
return ($copied) ? $file_name : false;
}

function _get_file($file_url, $copy_to_dir)
{
set_time_limit(0);

$file_name = $this->_get_file_name_from_url($file_url);

$fp = fopen($copy_to_dir . '/' . $file_name, 'w');

$ch = curl_init($file_url);

curl_setopt_array($ch, array(
CURLOPT_URL => $file_url,
CURLOPT_RETURNTRANSFER => 1,
//CURLOPT_FILE => $fp,
CURLOPT_TIMEOUT => 50

));

$results = curl_exec($ch);
if (curl_errno($ch))
{
return false;
}

curl_close($ch);

fwrite($fp, $results); //old style, let me debug something. TODO: update
fclose($fp);

return $file_name;
}

function _get_file_name_from_url($url)
{
$query_marker = strpos($url, '?');
Expand Down Expand Up @@ -851,15 +815,6 @@ function test_copy_file()
echo $copied;
}

function test_copy_remote_file()
{
$listen_url = 'http://upload.librivox.org/share/uploads/rg/aristopia_00_holford.mp3';
$listen_url = 'https://librivox.local/librivox-validator-books/the_secret_garden_1308/aristopia_00_holford.mp3';
$copy_to_dir = 'C:/test_files/';

$this->_get_file($listen_url, $copy_to_dir);
}

function test_get_file()
{
//echo 'TEST';
Expand Down Expand Up @@ -897,12 +852,8 @@ function test_get_file()
{
$file_name = $this->_copy_file($local_file, $copy_to_dir);
}
else
{
$file_name = $this->_get_file($section->listen_url, $copy_to_dir);
}

if (!$file_name)
if (!$local_file or !$file_name)
{
echo 'No file name';
return;
Expand Down