]> source.dussan.org Git - nextcloud-server.git/commitdiff
feat: replace id3parser with mp3info 38498/head
authorDaniel Kesselberg <mail@danielkesselberg.de>
Sun, 28 May 2023 14:57:21 +0000 (16:57 +0200)
committerDaniel Kesselberg <mail@danielkesselberg.de>
Wed, 28 Jun 2023 12:58:59 +0000 (14:58 +0200)
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
3rdparty
lib/private/Preview/MP3.php

index 216b791c9081f06a4ed6581a436020647dd41bbd..268aaeff738002179c0f5e9d9542ec362d987a5f 160000 (submodule)
--- a/3rdparty
+++ b/3rdparty
@@ -1 +1 @@
-Subproject commit 216b791c9081f06a4ed6581a436020647dd41bbd
+Subproject commit 268aaeff738002179c0f5e9d9542ec362d987a5f
index ff6ff86c9663dc1cbc709172a895c94b4de6cc7e..4c5f932f47792ed9ca98a3356e6beb0ac89a0fd7 100644 (file)
  */
 namespace OC\Preview;
 
-use ID3Parser\ID3Parser;
-
 use OCP\Files\File;
 use OCP\IImage;
 use Psr\Log\LoggerInterface;
+use wapmorgan\Mp3Info\Mp3Info;
 
 class MP3 extends ProviderV2 {
        /**
@@ -46,11 +45,12 @@ class MP3 extends ProviderV2 {
         * {@inheritDoc}
         */
        public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage {
-               $getID3 = new ID3Parser();
-
                $tmpPath = $this->getLocalFile($file);
+
                try {
-                       $tags = $getID3->analyze($tmpPath);
+                       $audio = new Mp3Info($tmpPath, true);
+                       /** @var string|null|false $picture */
+                       $picture = $audio->getCover();
                } catch (\Throwable $e) {
                        \OC::$server->get(LoggerInterface::class)->info($e->getMessage(), [
                                'exception' => $e,
@@ -61,12 +61,7 @@ class MP3 extends ProviderV2 {
                        $this->cleanTmpFiles();
                }
 
-               $picture = isset($tags['id3v2']['APIC'][0]['data']) ? $tags['id3v2']['APIC'][0]['data'] : null;
-               if (is_null($picture) && isset($tags['id3v2']['PIC'][0]['data'])) {
-                       $picture = $tags['id3v2']['PIC'][0]['data'];
-               }
-
-               if (!is_null($picture)) {
+               if (is_string($picture)) {
                        $image = new \OCP\Image();
                        $image->loadFromData($picture);