diff options
author | Robin Appelman <icewind1991@gmail.com> | 2011-08-01 23:53:01 +0200 |
---|---|---|
committer | Robin Appelman <icewind1991@gmail.com> | 2011-08-01 23:55:47 +0200 |
commit | 9f981de85437930ec89ecc85c2e79f096f65b5bb (patch) | |
tree | 49a313889f8aefdc131af360d539a4840d7422d5 /apps/media/lib_scanner.php | |
parent | ad45c78b44f887be547329501cba7c84c3a3c331 (diff) | |
download | nextcloud-server-9f981de85437930ec89ecc85c2e79f096f65b5bb.tar.gz nextcloud-server-9f981de85437930ec89ecc85c2e79f096f65b5bb.zip |
fance collection scanning wip
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 |