diff options
author | Daniel Kesselberg <mail@danielkesselberg.de> | 2023-05-28 16:57:21 +0200 |
---|---|---|
committer | Daniel Kesselberg <mail@danielkesselberg.de> | 2023-06-28 14:58:59 +0200 |
commit | 3757f390c36aa60ba3146799ff2764c8341f55b3 (patch) | |
tree | 0d96517afc1a3c03d1e58e89340521696b97f8d0 /lib/private/Preview | |
parent | fbc63fe57c7665e7a923ae70deac3ce8fa497acf (diff) | |
download | nextcloud-server-3757f390c36aa60ba3146799ff2764c8341f55b3.tar.gz nextcloud-server-3757f390c36aa60ba3146799ff2764c8341f55b3.zip |
feat: replace id3parser with mp3info
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
Diffstat (limited to 'lib/private/Preview')
-rw-r--r-- | lib/private/Preview/MP3.php | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/lib/private/Preview/MP3.php b/lib/private/Preview/MP3.php index ff6ff86c966..4c5f932f477 100644 --- a/lib/private/Preview/MP3.php +++ b/lib/private/Preview/MP3.php @@ -28,11 +28,10 @@ */ 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); |