Skip to content

Commit

Permalink
[HinduTamilBridge] refactor (#4146)
Browse files Browse the repository at this point in the history
* [HinduTamilBridge] refactor

* [HinduTamilBridge] fixed lint

* [HinduTamilBridge] fixed lint 2

* Update HinduTamilBridge.php
  • Loading branch information
tillcash authored Jul 5, 2024
1 parent 4539eb6 commit da8cfdf
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions bridges/HinduTamilBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,18 @@ public function collectData()
protected function parseItem($item)
{
$dom = getSimpleHTMLDOMCached($item['uri']);
$content = $dom->find('#pgContentPrint', 0);

$date = $dom->find('p span.date', 1);
if ($date) {
$item['timestamp'] = $this->convertToRFC3339($date->plaintext);
if ($content === null) {
return $item;
}

$content = $dom->find('#pgContentPrint', 0);
if (!$content) {
return $item;
$date = $dom->find('p span.date', 1);
if ($date) {
$item['timestamp'] = $this->toRFC3339($date->plaintext);
}

$image = $dom->find('#LoadArticle figure', 0);
$image = $dom->find('#LoadArticle figure', 0) ?? '';
$item['content'] = $image . $this->cleanContent($content);

return $item;
Expand All @@ -89,15 +89,14 @@ private function cleanContent($content)
return $content;
}

private function convertToRFC3339($DateString)
private function toRFC3339($dateString)
{
$timestamp = strtotime(trim($DateString));
$timestamp = strtotime(trim($dateString));

if ($timestamp !== false) {
$rfc3339DateTime = date('Y-m-d\TH:i:s', $timestamp) . '+05:30';
return $rfc3339DateTime;
} else {
if ($timestamp === false) {
return null;
}

return date('Y-m-d\TH:i:s', $timestamp) . '+05:30';
}
}

0 comments on commit da8cfdf

Please sign in to comment.