diff options
Diffstat (limited to 'apps/media/lib_scanner.php')
-rw-r--r-- | apps/media/lib_scanner.php | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/apps/media/lib_scanner.php b/apps/media/lib_scanner.php index ab38d76294b..c774c3c9fdb 100644 --- a/apps/media/lib_scanner.php +++ b/apps/media/lib_scanner.php @@ -88,8 +88,7 @@ class OC_MEDIA_SCANNER{ return; //invalid mp3 file } }else{ - $mimetype=OC_Filesystem::getMimeType($path); - if(substr($mimetype,0,4)!=='audio'){ + if(!self::isMusic($path)){ return; } if(!self::$getID3){ @@ -141,4 +140,14 @@ class OC_MEDIA_SCANNER{ $songId=OC_MEDIA_COLLECTION::addSong($title,$path,$artistId,$albumId,$length,$track,$size); return (!($title=='unkown' && $artist=='unkown' && $album=='unkown'))?$songId:0; } + + /** + * quick check if a song is a music file by checking the extention, not as good as a proper mimetype check but way faster + * @param string $filename + * @return bool + */ + public static function isMusic($filename){ + $ext=substr($filename,strrpos($filename,'.')+1); + return $ext=='mp3' || $ext=='flac' || $ext=='m4a' || $ext=='ogg' || $ext=='oga'; + } }
\ No newline at end of file |