If id3 library is not present show default image

Checks for getid3 library. Prevents site from failing. No images are fetched from audio files and will just show default image instead with a message on log saying to run install.
This commit is contained in:
Codenift 2019-10-13 13:07:06 -04:00 committed by GitHub
parent 50450daca4
commit 88f90f33b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 4 deletions

View File

@ -113,8 +113,13 @@ class FileDataHelper {
*/ */
public static function saveArtworkData($analyzeFile, $filename, $importDir = null, $DbPath = null) public static function saveArtworkData($analyzeFile, $filename, $importDir = null, $DbPath = null)
{ {
$getID3 = new \getID3(); if (class_exists('getID3')) {
$getFileInfo = $getID3->analyze($analyzeFile); $getID3 = new \getID3();
$getFileInfo = $getID3->analyze($analyzeFile);
} else {
$getFileInfo = [];
Logging::error("Failed to load getid3 library. Please run either 'composer install' or the 'install' script.");
}
if(isset($getFileInfo['comments']['picture'][0])) { if(isset($getFileInfo['comments']['picture'][0])) {
@ -188,8 +193,13 @@ class FileDataHelper {
$dbAudioPath = $md["MDATA_KEY_FILEPATH"]; $dbAudioPath = $md["MDATA_KEY_FILEPATH"];
$fullpath = $fp . $dbAudioPath; $fullpath = $fp . $dbAudioPath;
$getID3 = new \getID3(); if (class_exists('getID3')) {
$getFileInfo = $getID3->analyze($fullpath); $getID3 = new \getID3();
$getFileInfo = $getID3->analyze($fullpath);
} else {
$getFileInfo = [];
Logging::error("Failed to load getid3 library. Please run either 'composer install' or the 'install' script.");
}
if(isset($getFileInfo['comments']['picture'][0])) { if(isset($getFileInfo['comments']['picture'][0])) {