diff --git a/composer.json b/composer.json index 5593755..ac83b52 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.1", + "version": "2.6.3", "keywords": [ "php", "ebook", diff --git a/src/Formats/Cba/Parser/CbamTemplate.php b/src/Formats/Cba/Parser/CbamTemplate.php index 10e46b9..3c3f185 100644 --- a/src/Formats/Cba/Parser/CbamTemplate.php +++ b/src/Formats/Cba/Parser/CbamTemplate.php @@ -128,6 +128,11 @@ private function parse(): void $this->title = $this->extract('Title'); $this->series = $this->extract('Series'); $this->number = $this->extractFloat('Number'); + + if ($this->series && ! $this->number) { + $this->number = 0; + } + $this->count = $this->extractInt('Count'); $this->volume = $this->extractFloat('Volume'); $this->alternateSeries = $this->extract('AlternateSeries'); diff --git a/tests/CbaTest.php b/tests/CbaTest.php index ce934f2..c62350d 100644 --- a/tests/CbaTest.php +++ b/tests/CbaTest.php @@ -250,3 +250,10 @@ expect($comicMeta->number())->toBe(22.5); expect($comicMeta->storyArcNumber())->toBe(2.5); }); + +it('can parse series without volume', function () { + $metadata = XmlReader::make(file_get_contents(COMIC_INFO_SERIES_WITHOUT_VOLUME)); + $cba = CbamTemplate::make($metadata); + + expect($cba->getNumber())->toBe(0); +}); diff --git a/tests/Pest.php b/tests/Pest.php index abab036..aa24507 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -17,6 +17,7 @@ define('CBZ_CBAM_VOLUME', __DIR__.'/media/cba-cbam-volume.cbz'); define('COMIC_INFO_BASIC', __DIR__.'/media/ComicInfoBasic.xml'); +define('COMIC_INFO_SERIES_WITHOUT_VOLUME', __DIR__.'/media/ComicInfoSeriesWithoutVolume.xml'); define('EPUB_CONTAINER_EPUB2', __DIR__.'/media/container-epub2.xml'); define('EPUB_CONTAINER_EPUB2_BAD', __DIR__.'/media/container-epub2-bad.xml'); diff --git a/tests/media/ComicInfoSeriesWithoutVolume.xml b/tests/media/ComicInfoSeriesWithoutVolume.xml new file mode 100644 index 0000000..14dbd5d --- /dev/null +++ b/tests/media/ComicInfoSeriesWithoutVolume.xml @@ -0,0 +1,64 @@ + + + You Had One Job + Fantastic Four + Dan Slott + Paco Medina, Sean Izaakse + Paco Medina, Sean Izaakse + Jesus Aburtov, Marcio Menyz + THE RETURN OF THE NEW FANTASTIC FOUR?! The events of EMPYRE threaten all life on Earth + and the future balance of power throughout the cosmos! And the secret mission that the FF have + placed into Valeria and Franklin’s hands requires some big-league help! + 2020 + 10 + 1 + 24 + Marvel + Vertigo + en + CBZ + No + Alicia Masters, Captain Marvel, Franklin Richards, Human Torch, Invisible Woman, + Jo-Venn, Mr. Fantastic, N'kalla, Sky, Spider-Man, Thing, Valeria Richards, Wolverine + Cotati, Fantastic Four, Kree, New Fantastic Four, Skrulls + Earth, New York City, New York, United States of America, Skrull Empire, Skrull + Homeworld, Skrull Space, Skrull Starship, Skrull World, Wakanda + https://comicvine.gamespot.com/fantastic-four-22-you-had-one-job/4000-787351/ + Tagged with the ninjas.walk.alone fork of ComicTagger 1.3.3 using info from Comic Vine on + 2020-08-06 11:23:02. [CVDB787351] Scraped metadata from Comixology [CMXDB844632] + Empyre + Fantastic Four + Joe Caramagna + Espen Grundetjern, Iban Coello, John Rauch, Nick Bradshaw + Alanna Smith, Martin Biro, Tom Brevoort + Superhero + Teen + Zone-Empire + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file