Skip to content

Commit

Permalink
[TldrTechBridge] Fix and improve bridge (RSS-Bridge#4090)
Browse files Browse the repository at this point in the history
  • Loading branch information
SqrtMinusOne authored Apr 27, 2024
1 parent d31f207 commit f3ca567
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions bridges/TldrTechBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ class TldrTechBridge extends BridgeAbstract
'type' => 'list',
'values' => [
'Tech' => 'tech',
'Crypto' => 'crypto',
'Web Dev' => 'webdev',
'AI' => 'ai',
'Web Dev' => 'engineering',
'Information Security' => 'infosec',
'Product Management' => 'product',
'DevOps' => 'devops',
'Crypto' => 'crypto',
'Design' => 'design',
'Marketing' => 'marketing',
'Founders' => 'founders',
'Cybersecurity' => 'cybersecurity'
],
'defaultValue' => 'tech'
]
Expand All @@ -48,12 +52,17 @@ public function collectData()
// Convert /<topic>/2023-01-01 to unix timestamp
$date_items = explode('/', $child->href);
$date = strtotime(end($date_items));
$this->items[] = [
'uri' => self::URI . $child->href,
'title' => $child->plaintext,
'timestamp' => $date,
'content' => $this->extractContent(self::URI . $child->href),
];
$item_url = self::URI . ltrim($child->href, '/');
try {
$this->items[] = [
'uri' => self::URI . $child->href,
'title' => $child->plaintext,
'timestamp' => $date,
'content' => $this->extractContent($item_url),
];
} catch (HttpException $e) {
continue;
}
$added++;
if ($added >= $limit) {
break;
Expand All @@ -66,7 +75,7 @@ private function extractContent($url)
$html = getSimpleHTMLDOM($url);
$content = $html->find('div.content-center.mt-5', 0);
if (!$content) {
return '';
throw new HttpException('Could not find content', 500);
}
$subscribe_form = $content->find('div.mt-5 > div > form', 0);
if ($subscribe_form) {
Expand Down

0 comments on commit f3ca567

Please sign in to comment.