Skip to content

Commit

Permalink
Merge pull request #95 from kiwilan/develop
Browse files Browse the repository at this point in the history
v2.6.8
  • Loading branch information
ewilan-riviere authored Jul 28, 2024
2 parents 7787fbd + 2cb0f54 commit 335f00a
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 20 deletions.
29 changes: 15 additions & 14 deletions .github/workflows/run-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
6 changes: 5 additions & 1 deletion src/Formats/Audio/AudiobookModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/Formats/Epub/Parser/EpubHtml.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/Formats/Epub/Parser/NcxItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Formats/Mobi/Parser/MobiParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions tests/AudiobookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
1 change: 1 addition & 0 deletions tests/Pest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Binary file added tests/media/audiobook-ewilan-no-genres.m4b
Binary file not shown.

0 comments on commit 335f00a

Please sign in to comment.