Skip to content

Commit

Permalink
WIP: Ignore mp3 files that mp3gain cannot process
Browse files Browse the repository at this point in the history
In the validator, sometimes audio files either have a typo in their
path, or aren't actually audio files (when this patch was being
tested, the offending files were HTML files from a 301 redirect
response). In those cases, mp3gain does not return any useful output.
Specifically, instead of printing the header line plus the actually
useful line, it just prints the header line, with an error message
going to stderr (which we ignore because we only look at stdout).

This patch just makes the validator skip any such files.

Resolves LibriVox#119

Change-Id: Id08899ef6f415aeece6912e9676a7bcab05caf81
  • Loading branch information
notartom committed Apr 16, 2021
1 parent f3bc85f commit d297065
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions application/libraries/Librivox_id3tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ function _create_files_table($dir, $map = array(), $freeze = false)

//analyze volume
$mp3gain_result = $this->librivox_mp3gain->analyze_file($dir, $file);
if (! $mp3gain_result) continue;

$file_array = $this-> _create_file_array($freeze); //prototype

Expand Down
10 changes: 7 additions & 3 deletions application/libraries/Librivox_mp3gain.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,13 @@ public function analyze_file($dir, $file_name)
$command = $this->mp3gain . ' ' . $this->flag . $dir. $file_name;
exec($command, $output);

$parts = explode("\t", $output[1]);
if (count($output) > 1) {
$parts = explode("\t", $output[1]);
return $parts;
} else {
return false;
}

return $parts;

}

Expand All @@ -89,4 +93,4 @@ public function adjust($dir, $map)
unset($output);
}
}
}
}

0 comments on commit d297065

Please sign in to comment.