Hi,

When I installed ownCloud I saw that the dependency to mp3info for ID3
tag support was missing. So I installed it and uploaded some songs just
to realize that no songs are shown in the media app. I remembered that
all my MP3s use ID3v2 whereas mp3info just supports ID3v1. So I had a
look at the code and saw that the getid3 library is there, but if
mp3info was installed it was not used. I uninstalled mp3info and all
songs showed up in the media app!
I think mp3info is obsolete and should be removed completely. Attached
is a patch that does this. Furthermore, if the patch is applied the
following sites should be updated as well:

http://owncloud.org/install/advanced/
http://owncloud.org/install/configure/

Daniel

>From 822b4c158f3271802a58dd535ebf2865164f8970 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20K=C3=B6b?= <daniel.k...@peony.at>
Date: Mon, 2 Jan 2012 20:19:23 +0100
Subject: [PATCH] Remove obsolete support for mp3info (covered by getid3).

---
 apps/admin_dependencies_chk/settings.php |    6 --
 apps/media/lib_scanner.php               |   82 ++++++++++++------------------
 2 files changed, 32 insertions(+), 56 deletions(-)

diff --git a/apps/admin_dependencies_chk/settings.php b/apps/admin_dependencies_chk/settings.php
index 3402805..ce90dd6 100644
--- a/apps/admin_dependencies_chk/settings.php
+++ b/apps/admin_dependencies_chk/settings.php
@@ -45,12 +45,6 @@ $modules[] =array(
 	'message'=> $l->t('The php-gd module is needed to create thumbnails of your images'));
 
 $modules[] =array(
-	'status' => OC_Helper::canExecute("mp3info") ? 'ok' : 'warning',
-	'part'=> 'mp3info',
-	'modules'=> array('media'),
-	'message'=> $l->t('The program mp3info is useful to discover ID3 tags of your music files'));
-
-$modules[] =array(
 	'status' => function_exists("ldap_bind") ? 'ok' : 'error',
 	'part'=> 'php-ldap',
 	'modules'=> array('user_ldap'),
diff --git a/apps/media/lib_scanner.php b/apps/media/lib_scanner.php
index c2bea2d..aa3064b 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,59 +69,42 @@ class OC_MEDIA_SCANNER{
 	 * @return boolean
 	 */
 	public static function scanFile($path){
-		if(is_null(self::$useMp3Info)){
-			self::$useMp3Info=OC_Helper::canExecute("mp3info");
+		if(!self::isMusic($path)){
+			return;
+		}
+		if(!self::$getID3){
+			self::$getID3=@new getID3();
+			self::$getID3->encoding='UTF-8';
 		}
 		$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
-			}
+		$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'];
-			$track=(isset($data['comments']['track']))?$data['comments']['track'][0]: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'];
+		$track=(isset($data['comments']['track']))?$data['comments']['track'][0]: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;
-- 
1.7.4.1

_______________________________________________
Owncloud mailing list
Owncloud@kde.org
https://mail.kde.org/mailman/listinfo/owncloud

Reply via email to