Skip to content

Commit 199c378

Browse files
committed
Minor bug fixes
Technical specs - extracts text from all child nodes
1 parent 1dbb37d commit 199c378

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "hmerritt/imdb-api",
33
"description": "IMDB API that can fetch film data and search results",
44
"keywords": ["imdb", "api", "films", "search"],
5-
"license": "Apache 2.0",
5+
"license": "Apache-2.0",
66
"authors": [
77
{
88
"name": "Harry Merritt",

src/imdb.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public function film($query, $techSpecs=false) {
155155

156156
$response["title"] = $this->textClean($this->htmlFind($film_page, '.title_wrapper h1')->text);
157157
$response["year"] = $this->textClean($this->htmlFind($film_page, '.title_wrapper h1 #titleYear a')->text);
158-
$response["rating"] = $this->textClean($this->htmlFind($film_page, '.ratings_wrapper .ratingValue strong span')->text);
158+
$response["rating"] = $this->textClean($this->htmlFind($film_page, '.ratings_wrapper .ratingValue span[itemprop=ratingValue]')->text);
159159
$response["rating_votes"] = $this->textClean($this->htmlFind($film_page, '.ratings_wrapper span[itemprop=ratingCount]')->text);
160160
$response["length"] = $this->textClean($this->htmlFind($film_page, '.subtext time')->text);
161161
$response["plot"] = $this->textClean($this->htmlFind($film_page, '.plot_summary .summary_text')->text);
@@ -257,9 +257,10 @@ public function film($query, $techSpecs=false) {
257257
foreach ($techSpecs_table as $techSpecs_row)
258258
{
259259
// Get row title
260-
$row_title = $this->textClean($techSpecs_row->find('td')[0]->text);
260+
$row_title = $this->textClean($techSpecs_row->find('td')[0]->text(true));
261261
// Get row value
262-
$row_value = str_replace(" ", " <br> ", $this->textClean($techSpecs_row->find('td')[1]->text));
262+
// -> reutrn all text (within all child nodes)
263+
$row_value = str_replace(" ", " <br> ", $this->textClean($techSpecs_row->find('td')[1]->text(true)));
263264

264265
// Create response var
265266
$row = [$row_title, $row_value];

0 commit comments

Comments
 (0)