Catch edge/null cases for song file and ID3 parsing
This commit is contained in:
parent
426d2680f7
commit
69ba9e1d14
|
@ -2,7 +2,7 @@
|
|||
|
||||
require_once dirname(__FILE__).'/../vendor/autoload.php';
|
||||
|
||||
$ini = parse_ini_file("/etc/homeaudio.ini");
|
||||
$ini = parse_ini_file("/etc/homeaudio.ini", false, INI_SCANNER_RAW);
|
||||
if ( isset($argv[1]) && ($argv[1] == "simulate") ) {
|
||||
define("SIMULATE", true);
|
||||
} else {
|
||||
|
@ -106,26 +106,37 @@ function parseSongs() {
|
|||
$info = $getid3->analyze(MP3ROOTDIR . $row['path'] . $row['song']);
|
||||
if ( isset($info['id3v2']['comments']['title'][0]) ) {
|
||||
$fields[':title'] = $info['id3v2']['comments']['title'][0];
|
||||
} else {
|
||||
$fields[':title'] = "";
|
||||
}
|
||||
if ( !isset($fields[':title']) || ($fields[':title'] == "") ) {
|
||||
@list($junk, $fields[':title']) = explode(" - ", substr($row['song'], 0, -4), 2);
|
||||
if ( is_null($fields[':title']) ) $fields[':title'] = substr($row['song'], 0, -4);
|
||||
}
|
||||
if ( isset($info['id3v2']['comments']['artist'][0]) ) {
|
||||
$fields[':artist'] = $info['id3v2']['comments']['artist'][0];
|
||||
} else {
|
||||
$fields[':artist'] = "";
|
||||
}
|
||||
if ( !isset($fields[':artist']) || ($fields[':artist'] == "") ) {
|
||||
@list($fields[':artist'], $junk) = explode(" - ", basename($row['path']), 2);
|
||||
if ( is_null($fields[':artist']) ) $fields[':artist'] = basename($row['path'], "/");
|
||||
}
|
||||
if ( isset($info['id3v2']['comments']['album'][0]) ) {
|
||||
$fields[':album'] = $info['id3v2']['comments']['album'][0];
|
||||
} else {
|
||||
$fields[':album'] = "";
|
||||
}
|
||||
if ( !isset($fields[':album']) || ($fields[':album'] == "") ) {
|
||||
@list($junk, $fields[':album']) = explode(" - ", basename($row['path']), 2);
|
||||
if ( is_null($fields[':album']) ) $fields[':album'] = basename($row['path'], "/");
|
||||
}
|
||||
if ( isset($info['id3v2']['comments']['year'][0]) ) {
|
||||
$fields[':year'] = $info['id3v2']['comments']['year'][0];
|
||||
} else {
|
||||
$fields[':year'] = "";
|
||||
}
|
||||
if ( !isset($fields[':year']) ) $fields[':year'] = "";
|
||||
if ( !isset($fields[':year']) || is_null($fields[':year']) ) $fields[':year'] = "";
|
||||
@list($min, $sec) = explode(":", $info['playtime_string'], 2);
|
||||
$fields[':length'] = (intval($min) * 60) + intval($sec);
|
||||
$fields[':artfile'] = "";
|
||||
|
|
Loading…
Reference in New Issue
Block a user