summaryrefslogtreecommitdiffstats
path: root/apps/media
diff options
context:
space:
mode:
authorRobin Appelman <icewind1991@gmail.com>2012-01-08 17:29:35 +0100
committerRobin Appelman <icewind1991@gmail.com>2012-01-08 17:35:40 +0100
commit13784bee18ace83adc10d869e949420b797ac03f (patch)
tree1d969a582cb1ecf369a1783da1598cdb1a7423b8 /apps/media
parent041e3575d157e1ac0886473c962af10726ae7e67 (diff)
downloadnextcloud-server-13784bee18ace83adc10d869e949420b797ac03f.tar.gz
nextcloud-server-13784bee18ace83adc10d869e949420b797ac03f.zip
mp3info is giving to much trouble, get rid of it
Diffstat (limited to 'apps/media')
-rw-r--r--apps/media/lib_scanner.php110
1 files changed, 46 insertions, 64 deletions
diff --git a/apps/media/lib_scanner.php b/apps/media/lib_scanner.php
index 320b1f79199..4039cce09ee 100644
--- a/apps/media/lib_scanner.php
+++ b/apps/media/lib_scanner.php
@@ -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,72 +69,55 @@ 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
- }
+ if(!self::isMusic($path)){
+ return;
+ }
+ if(!self::$getID3){
+ self::$getID3=@new getID3();
+ self::$getID3->encoding='UTF-8';
+ }
+ $data=@self::$getID3->analyze($file);
+ getid3_lib::CopyTagsToComments($data);
+ if(!isset($data['comments'])){
+ OC_Log::write('media',"error reading id3 tags in '$file'",OC_Log::WARN);
+ return;
+ }
+ if(!isset($data['comments']['artist'])){
+ OC_Log::write('media',"error reading artist tag in '$file'",OC_Log::WARN);
+ $artist='unknown';
}else{
- if(!self::isMusic($path)){
- return;
- }
- if(!self::$getID3){
- self::$getID3=@new getID3();
- self::$getID3->encoding='UTF-8';
- }
- $data=@self::$getID3->analyze($file);
- getid3_lib::CopyTagsToComments($data);
- if(!isset($data['comments'])){
- OC_Log::write('media',"error reading id3 tags in '$file'",OC_Log::WARN);
- return;
- }
- if(!isset($data['comments']['artist'])){
- OC_Log::write('media',"error reading artist tag in '$file'",OC_Log::WARN);
- $artist='unknown';
- }else{
- $artist=stripslashes($data['comments']['artist'][0]);
- }
- if(!isset($data['comments']['album'])){
- OC_Log::write('media',"error reading album tag in '$file'",OC_Log::WARN);
- $album='unknown';
- }else{
- $album=stripslashes($data['comments']['album'][0]);
- }
- if(!isset($data['comments']['title'])){
- OC_Log::write('media',"error reading title tag in '$file'",OC_Log::WARN);
- $title='unknown';
- }else{
- $title=stripslashes($data['comments']['title'][0]);
- }
- $size=$data['filesize'];
- if (isset($data['comments']['track']))
- {
- $track = $data['comments']['track'][0];
- }
- else if (isset($data['comments']['track_number']))
- {
- $track = $data['comments']['track_number'][0];
- $track = explode('/',$track);
- $track = $track[0];
- }
- else
- {
- $track = 0;
- }
- $length=isset($data['playtime_seconds'])?round($data['playtime_seconds']):0;
+ $artist=stripslashes($data['comments']['artist'][0]);
}
+ if(!isset($data['comments']['album'])){
+ OC_Log::write('media',"error reading album tag in '$file'",OC_Log::WARN);
+ $album='unknown';
+ }else{
+ $album=stripslashes($data['comments']['album'][0]);
+ }
+ if(!isset($data['comments']['title'])){
+ OC_Log::write('media',"error reading title tag in '$file'",OC_Log::WARN);
+ $title='unknown';
+ }else{
+ $title=stripslashes($data['comments']['title'][0]);
+ }
+ $size=$data['filesize'];
+ if (isset($data['comments']['track']))
+ {
+ $track = $data['comments']['track'][0];
+ }
+ else if (isset($data['comments']['track_number']))
+ {
+ $track = $data['comments']['track_number'][0];
+ $track = explode('/',$track);
+ $track = $track[0];
+ }
+ else
+ {
+ $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;