|
|
|
@ -30,7 +30,6 @@ class OC_MEDIA_SCANNER{ |
|
|
|
|
//these are used to store which artists and albums we found, it can save a lot of addArtist/addAlbum calls |
|
|
|
|
static private $artists=array(); |
|
|
|
|
static private $albums=array();//stored as "$artist/$album" to allow albums with the same name from different artists |
|
|
|
|
static private $useMp3Info=null; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* scan a folder for music |
|
|
|
@ -70,24 +69,7 @@ class OC_MEDIA_SCANNER{ |
|
|
|
|
* @return boolean |
|
|
|
|
*/ |
|
|
|
|
public static function scanFile($path){ |
|
|
|
|
if(is_null(self::$useMp3Info)){ |
|
|
|
|
self::$useMp3Info=OC_Helper::canExecute("mp3info"); |
|
|
|
|
} |
|
|
|
|
$file=OC_Filesystem::getLocalFile($path); |
|
|
|
|
if(substr($path,-3)=='mp3' and self::$useMp3Info){//use the command line tool id3info if possible |
|
|
|
|
$output=array(); |
|
|
|
|
$size=filesize($file); |
|
|
|
|
exec('mp3info -p "%a\n%l\n%t\n%n\n%S" "'.$file.'"',$output); |
|
|
|
|
if(count($output)>4){ |
|
|
|
|
$artist=$output[0]; |
|
|
|
|
$album=$output[1]; |
|
|
|
|
$title=$output[2]; |
|
|
|
|
$track=$output[3]; |
|
|
|
|
$length=$output[4]; |
|
|
|
|
}else{ |
|
|
|
|
return; //invalid mp3 file |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
if(!self::isMusic($path)){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -135,7 +117,7 @@ class OC_MEDIA_SCANNER{ |
|
|
|
|
$track = 0; |
|
|
|
|
} |
|
|
|
|
$length=isset($data['playtime_seconds'])?round($data['playtime_seconds']):0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(!isset(self::$artists[$artist])){ |
|
|
|
|
$artistId=OC_MEDIA_COLLECTION::addArtist($artist); |
|
|
|
|
self::$artists[$artist]=$artistId; |
|
|
|
|