Skip to content

Commit

Permalink
[InternetDownloadManagerBridge] add bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
tillcash committed Sep 12, 2024
1 parent 80c43f1 commit 07228a0
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions bridges/InternetDownloadManagerBridge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

class InternetDownloadManagerBridge extends BridgeAbstract
{
const NAME = 'Internet Download Manager News';
const URI = 'https://www.internetdownloadmanager.com/news.html';
const DESCRIPTION = 'IDM update changelog';
const MAINTAINER = 'tillcash';
const MAX_ITEMS = 10;

public function collectData()
{
$dom = getSimpleHTMLDOM(self::URI);
$elements = $dom->find('.col-center.with__nav > h3');
$count = 0;

foreach ($elements as $element) {
if ($count >= self::MAX_ITEMS) {
break;
}

// Extract the release date information
$dateInfo = $element->next_sibling()->plaintext;
preg_match('/\(Released: (.*?)\)/', $dateInfo, $matches);
$date = $matches[1] ?? time();

// Extract the content of the changelog
$content = $element->next_sibling()->next_sibling()->outertext;

$this->items[] = [
'title' => $element->plaintext,
'timestamp' => $date,
'content' => $content,
];

$count++;
}
}
}

0 comments on commit 07228a0

Please sign in to comment.