Skip to content

Commit 55dcc74

Browse files
committed
Merge pull request #76 from younes0/master
DC terms + Publishing Dates meta for HTML
2 parents 20553c9 + 188fbab commit 55dcc74

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

src/Providers/Dcterms.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ public function run()
2121
}
2222

2323
foreach (Utils::getMetas($html) as $meta) {
24-
if (stripos($meta[0], 'dc.') === 0) {
25-
$this->bag->set(substr($meta[0], 3), $meta[1]);
24+
foreach (['dc.', 'dc:', 'dcterms:'] as $prefix) {
25+
if (stripos($meta[0], $prefix) === 0) {
26+
$key = substr($meta[0], strlen($prefix));
27+
$this->bag->set($key, $meta[1]);
28+
}
2629
}
2730
}
2831
}
@@ -56,6 +59,10 @@ public function getAuthorName()
5659
*/
5760
public function getPublishedTime()
5861
{
59-
return $this->bag->get('date');
62+
foreach (['date', 'date.created', 'date.issued'] as $key) {
63+
if ($found = $this->bag->get($key)) {
64+
return $found;
65+
}
66+
}
6067
}
6168
}

src/Providers/Html.php

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,29 @@ public function getHeight()
138138
*/
139139
public function getPublishedTime()
140140
{
141-
return $this->bag->get('pub_date')
142-
?: $this->bag->get('date')
143-
?: $this->bag->get('pagerender')
144-
?: $this->bag->get('datepublished');
141+
$keys = [
142+
'article:published_time',
143+
'created',
144+
'date',
145+
'datepublished',
146+
'datePublished',
147+
'newsrepublic:publish_date',
148+
'pagerender',
149+
'pub_date',
150+
'publication-date',
151+
'publish-date',
152+
'rc.datecreation',
153+
'timestamp',
154+
'article:modified_time',
155+
'eomportal-lastupdate',
156+
'shareaholic:article_published_time',
157+
];
158+
159+
foreach ($keys as $key) {
160+
if ($found = $this->bag->get($key)) {
161+
return $found;
162+
}
163+
}
145164
}
146165

147166
/**

0 commit comments

Comments
 (0)