From 171c0503684cd35e0cac050f3928b98880ee1d2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20P=C5=82aczek?= Date: Fri, 3 Oct 2025 15:08:45 +0200 Subject: [PATCH] Add original title --- README.md | 8 +++++++- src/Api/AbstractBookInfo.php | 1 + src/DataParser.php | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 47f6796..d70b9f0 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,13 @@ Place this in the composer.json. }] } ``` -Then execute +Then execute to get latest version: + +```bash +composer require techtube/bookinfo +``` + +or this to get specific version: ```bash composer require techtube/bookinfo:"1.0.4" diff --git a/src/Api/AbstractBookInfo.php b/src/Api/AbstractBookInfo.php index bf07c07..75410d2 100644 --- a/src/Api/AbstractBookInfo.php +++ b/src/Api/AbstractBookInfo.php @@ -9,6 +9,7 @@ abstract class AbstractBookInfo public string $isbn; public string $description; public string $title; + public string $originalTitle; public string $category; public array $cover_url; public int $pages; diff --git a/src/DataParser.php b/src/DataParser.php index 7417896..d0722a7 100644 --- a/src/DataParser.php +++ b/src/DataParser.php @@ -25,6 +25,7 @@ class DataParser $info->isbn = $document->first('meta[property="books:isbn"]')->getAttribute('content'); $info->description = trim($document->first('#book-description p')->text()); $info->title = trim($document->first('h1.book__title')->text()); + $info->originalTitle = trim($document->first("//*[contains(text(), 'Tytuł oryginału:')]", Query::TYPE_XPATH)?->nextSibling('dd')?->text() ?? ''); $info->category = trim($document->first('.book__category')->text()); $info->cover_url = $this->generateCoverUrls( $document->first('meta[property="og:image"]')->getAttribute('content')