From a01a8c4857b4dbf0f46b6ff16c89f7e15d7df8bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ewilan=20Rivi=C3=A8re?= Date: Sun, 28 Jul 2024 15:55:50 +0200 Subject: [PATCH] v2.6.9 Add `duration_human_readable` for `getExtras()` method for audiobooks. Works with `kiwilan/php-audio` v3.0.08. --- composer.json | 4 ++-- src/Formats/Audio/AudiobookModule.php | 2 ++ tests/AudiobookTest.php | 9 +++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 31069ab..503abcf 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "kiwilan/php-ebook", "description": "PHP package to read metadata and extract covers from eBooks, comics and audiobooks.", - "version": "2.6.8", + "version": "2.6.9", "keywords": [ "php", "ebook", @@ -43,7 +43,7 @@ "kiwilan/php-xml-reader": "^1.0.11" }, "require-dev": { - "kiwilan/php-audio": "^3.0.06", + "kiwilan/php-audio": "^3.0.08", "laravel/pint": "^1.7", "pestphp/pest": "^1.20", "pestphp/pest-plugin-parallel": "^1.2", diff --git a/src/Formats/Audio/AudiobookModule.php b/src/Formats/Audio/AudiobookModule.php index e64c8f3..0b8102c 100644 --- a/src/Formats/Audio/AudiobookModule.php +++ b/src/Formats/Audio/AudiobookModule.php @@ -82,6 +82,7 @@ private function create(): self 'copyright' => $this->parseTag($audio->getTag('copyright')), 'stik' => $audio->getStik(), 'duration' => $audio->getDuration(), + 'duration_human_readable' => $audio->getDurationHumanReadable(), 'audio_title' => $audio->getTitle(), 'audio_artist' => $audio->getArtist(), 'audio_album' => $audio->getAlbum(), @@ -152,6 +153,7 @@ public function toEbook(): Ebook 'disc_number' => $this->getAudioValue('disc_number'), 'stik' => $this->getAudioValue('stik'), 'duration' => $this->getAudioValue('duration'), + 'duration_human_readable' => $this->getAudioValue('duration_human_readable'), 'audio_title' => $this->getAudioValue('audio_title'), 'audio_artist' => $this->getAudioValue('audio_artist'), 'audio_album' => $this->getAudioValue('audio_album'), diff --git a/tests/AudiobookTest.php b/tests/AudiobookTest.php index 986c744..727d340 100644 --- a/tests/AudiobookTest.php +++ b/tests/AudiobookTest.php @@ -107,3 +107,12 @@ expect($ebook->getTags())->toBeEmpty(); }); + +it('can parse audiobook emma', function () { + $ebook = Ebook::read(AUDIOBOOK_EWILAN); + $duration = $ebook->getExtra('duration'); + $duration_human_readable = $ebook->getExtra('duration_human_readable'); + + expect($duration)->toBe(33.0); + expect($duration_human_readable)->toBe('00:00:33'); +});