Skip to content

Commit

Permalink
Merge pull request #203 from Simounet/feat/jsonld-logger-infos
Browse files Browse the repository at this point in the history
Logger infos added for JsonLd parsing
  • Loading branch information
j0k3r authored May 14, 2019
2 parents c7fcea0 + e2314b6 commit c1fe002
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Extractor/ContentExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -1163,21 +1163,25 @@ private function extractJsonLdInformation($html)
// just in case datePublished isn't defined, we use the modified one at first
if (isset($data['dateModified'])) {
$this->date = $data['dateModified'];
$this->logger->info('date matched from JsonLd: {date}', ['date' => $this->date]);
}

if (isset($data['datePublished'])) {
$this->date = $data['datePublished'];
$this->logger->info('date matched from JsonLd: {date}', ['date' => $this->date]);
}

// sometimes the date is an array
if (\is_array($this->date)) {
$this->date = reset($this->date);
$this->logger->info('date matched from JsonLd: {date}', ['date' => $this->date]);
}

// body should be a DOMNode
if (isset($data['articlebody'])) {
$dom = new \DOMDocument('1.0', 'utf-8');
$this->body = $dom->createElement('p', htmlspecialchars(trim($data['articlebody'])));
$this->logger->info('body matched from JsonLd: {body}', ['body' => $this->body]);
}

if (isset($data['headline'])) {
Expand All @@ -1197,6 +1201,7 @@ private function extractJsonLdInformation($html)

foreach ($authors as $author) {
$this->addAuthor($author);
$this->logger->info('author matched from JsonLd: {author}', ['author' => $author]);
}
}
}
Expand All @@ -1205,6 +1210,7 @@ private function extractJsonLdInformation($html)
foreach ($candidateNames as $name) {
if (!\in_array($name, $ignoreNames, true)) {
$this->title = $name;
$this->logger->info('title matched from JsonLd: {{title}}', ['title' => $name]);
}
}
}
Expand Down

0 comments on commit c1fe002

Please sign in to comment.