diff --git a/.github/workflows/run-macos.yml b/.github/workflows/run-macos.yml index d75f7e3..8214aab 100644 --- a/.github/workflows/run-macos.yml +++ b/.github/workflows/run-macos.yml @@ -22,22 +22,23 @@ jobs: run: | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" brew update + brew upgrade brew install p7zip rar ghostscript brew install imagemagick shell: bash - - name: Add rar extension - run: | - git clone https://github.com/cataphract/php-rar - cd php-rar - phpize - ./configure - sudo make - sudo make install - pecl_path=$(pecl config-get ext_dir) - phpini_path=$(php -i | grep /.+/php.ini -oE) - sudo cp ./modules/rar.so $pecl_path - sudo echo "extension=rar.so" > $phpini_path + # - name: Add rar extension + # run: | + # git clone https://github.com/cataphract/php-rar + # cd php-rar + # phpize + # ./configure + # sudo make + # sudo make install + # pecl_path=$(pecl config-get ext_dir) + # phpini_path=$(php -i | grep /.+/php.ini -oE) + # sudo cp ./modules/rar.so $pecl_path + # sudo echo "extension=rar.so" > $phpini_path - name: Setup problem matchers run: | @@ -47,8 +48,8 @@ jobs: - name: Install dependencies run: composer update --prefer-dist --no-interaction - - name: Check extension rar - run: php -m | grep rar + # - name: Check extension rar + # run: php -m | grep rar - name: Check extension imagick run: php -m | grep imagick diff --git a/composer.json b/composer.json index e99a5db..31069ab 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.7", + "version": "2.6.8", "keywords": [ "php", "ebook", diff --git a/src/Formats/Audio/AudiobookModule.php b/src/Formats/Audio/AudiobookModule.php index fe3ee6c..e64c8f3 100644 --- a/src/Formats/Audio/AudiobookModule.php +++ b/src/Formats/Audio/AudiobookModule.php @@ -39,7 +39,11 @@ private function create(): self $authors = $audio->getArtist() ?? $audio->getAlbumArtist(); $genres = EbookUtils::parseStringWithSeperator($audio->getGenre()); - $genres = array_map('ucfirst', $genres); + if (! is_array($genres)) { + $genres = null; + } else { + $genres = array_map('ucfirst', $genres); + } $series = $audio->getTag('series') ?? $audio->getTag('mvnm'); $series_part = $audio->getTag('series-part') ?? $audio->getTag('mvin'); diff --git a/src/Formats/Epub/Parser/EpubHtml.php b/src/Formats/Epub/Parser/EpubHtml.php index 903f6c0..2356960 100644 --- a/src/Formats/Epub/Parser/EpubHtml.php +++ b/src/Formats/Epub/Parser/EpubHtml.php @@ -15,7 +15,7 @@ class EpubHtml public static function make(?string $html, ?string $filename): self { - $self = new self(); + $self = new self; if (! $html || ! $filename) { return $self; diff --git a/src/Formats/Epub/Parser/NcxItem.php b/src/Formats/Epub/Parser/NcxItem.php index 4664084..7e04c7f 100644 --- a/src/Formats/Epub/Parser/NcxItem.php +++ b/src/Formats/Epub/Parser/NcxItem.php @@ -165,7 +165,7 @@ protected function __construct( public static function make(array $xml): self { - $self = new self(); + $self = new self; $self->name = $xml['name'] ?? null; $self->content = $xml['content'] ?? null; @@ -203,7 +203,7 @@ protected function __construct( public static function make(array $xml): self { - $self = new self(); + $self = new self; $self->label = $xml['navLabel']['text'] ?? null; $self->src = $xml['content']['@attributes']['src'] ?? null; diff --git a/src/Formats/Mobi/Parser/MobiParser.php b/src/Formats/Mobi/Parser/MobiParser.php index fe337fc..13bd959 100644 --- a/src/Formats/Mobi/Parser/MobiParser.php +++ b/src/Formats/Mobi/Parser/MobiParser.php @@ -81,7 +81,7 @@ private function parse(): self $this->palmRecords[] = $record; } - $this->palmDOCHeader = new PalmDOCHeader(); + $this->palmDOCHeader = new PalmDOCHeader; $this->stream->seek($this->palmRecords[0]->offset); $this->palmDOCHeader->compression = $this->stream->binaryToDecimal($this->stream->read(2)); $this->stream->read(2); diff --git a/tests/AudiobookTest.php b/tests/AudiobookTest.php index a2bed52..986c744 100644 --- a/tests/AudiobookTest.php +++ b/tests/AudiobookTest.php @@ -101,3 +101,9 @@ expect($ebook->getVolume())->toBe(0); }); + +it('can parse audiobook without genres', function () { + $ebook = Ebook::read(AUDIOBOOK_EWILAN_NO_GENRES); + + expect($ebook->getTags())->toBeEmpty(); +}); diff --git a/tests/Pest.php b/tests/Pest.php index 200c654..28f677f 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -61,6 +61,7 @@ define('AUDIOBOOK_CHAPTERS', __DIR__.'/media/audiobook-test.m4b'); define('AUDIOBOOK_EWILAN_VOLUME', __DIR__.'/media/audiobook-ewilan-volume.m4b'); define('AUDIOBOOK_EWILAN_VOLUME_ZERO', __DIR__.'/media/audiobook-ewilan-volume-0.m4b'); +define('AUDIOBOOK_EWILAN_NO_GENRES', __DIR__.'/media/audiobook-ewilan-no-genres.m4b'); define('FORMAT_AZW3', __DIR__.'/media/alice-lewis-carroll.azw3'); define('FORMAT_DOCX', __DIR__.'/media/alice-lewis-carroll.docx'); diff --git a/tests/media/audiobook-ewilan-no-genres.m4b b/tests/media/audiobook-ewilan-no-genres.m4b new file mode 100644 index 0000000..9046b3c Binary files /dev/null and b/tests/media/audiobook-ewilan-no-genres.m4b differ