From c531bfc8756e38d291676ef627cad8524ecd1b72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ewilan=20Rivi=C3=A8re?= Date: Thu, 22 Jun 2023 17:36:41 +0200 Subject: [PATCH] `MetaTitle` improve `uniqueFilename` --- composer.json | 2 +- src/Tools/MetaTitle.php | 8 ++++---- tests/MetaTitleTest.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 2b9057d..ca54697 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 (.epub, .cbz, .cbr, .cb7, .cbt, .pdf) and audiobooks (.mp3, .m4a, .m4b, .flac, .ogg).", - "version": "1.3.33", + "version": "1.3.34", "keywords": [ "php", "ebook", diff --git a/src/Tools/MetaTitle.php b/src/Tools/MetaTitle.php index 83dda36..3ff5571 100644 --- a/src/Tools/MetaTitle.php +++ b/src/Tools/MetaTitle.php @@ -211,8 +211,8 @@ private function generateSlug(string $title, ?string $type, ?string $language): */ private function generateUniqueFilename(Ebook $ebook): string { - $author = $this->setSlug($ebook->authorMain()); - $filename = "{$author}"; + $language = $this->setSlug($ebook->language()); + $filename = "{$language}"; if ($ebook->series()) { $series = $this->setSlug($ebook->series()); $filename .= "-{$series}"; @@ -224,8 +224,8 @@ private function generateUniqueFilename(Ebook $ebook): string } $title = $this->setSlug($ebook->title()); $filename .= "-{$title}"; - $language = $this->setSlug($ebook->language()); - $filename .= "-{$language}"; + $author = $this->setSlug($ebook->authorMain()); + $filename .= "-{$author}"; $format = $this->setSlug($ebook->extension()); $filename .= "-{$format}"; diff --git a/tests/MetaTitleTest.php b/tests/MetaTitleTest.php index cebc50a..6a6e663 100644 --- a/tests/MetaTitleTest.php +++ b/tests/MetaTitleTest.php @@ -19,5 +19,5 @@ expect($meta->serieSlugSort())->toBe('a-comme-association'); expect($meta->serieSlugLang())->toBe('a-comme-association-epub-fr'); expect($meta->slugSortWithSerie())->toBe('a-comme-association-01_pale-lumiere-des-tenebres'); - expect($meta->uniqueFilename())->toBe('jean-m-auel-a-comme-association-01-la-pale-lumiere-des-tenebres-fr-epub'); + expect($meta->uniqueFilename())->toBe('fr-a-comme-association-01-la-pale-lumiere-des-tenebres-jean-m-auel-epub'); });