getID3: Boolean to force MP3 check
Apparently MP3 encoders can muck up an MP3 file pretty bad. getID3 can read these files, but it takes extra work and thus is only done if the file carries a relevant extension. Shimmie's files don't have an extension, so a boolean was added to analyze() in order to force this check.
This commit is contained in:
parent
c9bacdf56d
commit
afd75f1134
2 changed files with 12 additions and 4 deletions
5
lib/getid3/THIS_HAS_BEEN_MODIFIED.txt
Normal file
5
lib/getid3/THIS_HAS_BEEN_MODIFIED.txt
Normal file
|
@ -0,0 +1,5 @@
|
|||
In compliance with GPL, this message is to notify you that getID3 has been modified.
|
||||
|
||||
getid3.php was modified September 23, 2012 to add a boolean to force MP3 checking.
|
||||
|
||||
It carries the same license as its original.
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
//Modified from its original version - September 23, 2012
|
||||
//$forcemp3 added to analyze to force MP3 detection even if extension isn't .mp3
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
/// getID3() by James Heinrich <info@getid3.org> //
|
||||
// available at http://getid3.sourceforge.net //
|
||||
|
@ -343,7 +346,7 @@ class getID3
|
|||
}
|
||||
|
||||
// public: analyze file
|
||||
function analyze($filename) {
|
||||
function analyze($filename, $forcemp3 = FALSE) {
|
||||
try {
|
||||
if (!$this->openfile($filename)) {
|
||||
return $this->info;
|
||||
|
@ -390,7 +393,7 @@ class getID3
|
|||
$formattest = fread($this->fp, 32774);
|
||||
|
||||
// determine format
|
||||
$determined_format = $this->GetFileFormat($formattest, $filename);
|
||||
$determined_format = $this->GetFileFormat($formattest, $filename, $forcemp3);
|
||||
|
||||
// unable to determine file format
|
||||
if (!$determined_format) {
|
||||
|
@ -1102,7 +1105,7 @@ class getID3
|
|||
|
||||
|
||||
|
||||
function GetFileFormat(&$filedata, $filename='') {
|
||||
function GetFileFormat(&$filedata, $filename='', $forcemp3) {
|
||||
// this function will determine the format of a file based on usually
|
||||
// the first 2-4 bytes of the file (8 bytes for PNG, 16 bytes for JPG,
|
||||
// and in the case of ISO CD image, 6 bytes offset 32kb from the start
|
||||
|
@ -1119,7 +1122,7 @@ class getID3
|
|||
}
|
||||
|
||||
|
||||
if (preg_match('#\.mp[123a]$#i', $filename)) {
|
||||
if (preg_match('#\.mp[123a]$#i', $filename) || $forcemp3 == TRUE) {
|
||||
// Too many mp3 encoders on the market put gabage in front of mpeg files
|
||||
// use assume format on these if format detection failed
|
||||
$GetFileFormatArray = $this->GetFileFormatArray();
|
||||
|
|
Reference in a new issue