diff options
author | 2023-05-28 05:01:45 +0530 | |
---|---|---|
committer | 2023-05-28 01:31:45 +0200 | |
commit | 227c7b8968d00be7b438e9c340158bcc9d2ae63f (patch) | |
tree | ced151a65fd63720753f5cc98875c861f3da2a60 | |
parent | 01f731cfa44cf9a3c6c4f6ef8bf29af9a13763ed (diff) | |
download | rss-bridge-227c7b8968d00be7b438e9c340158bcc9d2ae63f.tar.gz rss-bridge-227c7b8968d00be7b438e9c340158bcc9d2ae63f.tar.zst rss-bridge-227c7b8968d00be7b438e9c340158bcc9d2ae63f.zip |
Sleeper.com Alerts. Fixes #2234 (#3411)
* Sleeper.com Alerts. Fixes #2234
* fix: linter issue
-rw-r--r-- | bridges/SleeperFantasyFootballBridge.php | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/bridges/SleeperFantasyFootballBridge.php b/bridges/SleeperFantasyFootballBridge.php new file mode 100644 index 00000000..c506482c --- /dev/null +++ b/bridges/SleeperFantasyFootballBridge.php @@ -0,0 +1,44 @@ +<?php + +class SleeperFantasyFootballBridge extends BridgeAbstract +{ + const NAME = 'Sleeper.com Alerts'; + const URI = 'https://sleeper.com/topics/170000000000000000'; + const DESCRIPTION = 'Fantasy Football Alerts from Sleeper.com'; + const MAINTAINER = 'piyushpaliwal'; + const PARAMETERS = []; + + const CACHE_TIMEOUT = 3600; // 1 hour + + public function collectData() + { + $html = getSimpleHTMLDOMCached(self::URI, self::CACHE_TIMEOUT); + foreach ($html->find('div.content > div.latest-topics > a') as $index => $a) { + $content = $a->find('div.title > p', 0)->innertext; + $meta = $this->processString($a->find('div.desc > div.username', 0)->innertext); + $item['title'] = $content; + $item['content'] = $content; + $item['categories'] = $a->find('div.title div.tag', 0)->innertext; + $item['timestamp'] = $meta['timestamp']; + $item['author'] = $meta['author']; + $item['enclosures'] = $a->find('div.player-photo amp-img', 0)->src; + $this->items[] = $item; + if (count($this->items) >= 10) { + break; + } + } + } + + protected function processString($inputString) + { + $decodedString = str_replace([' ', '•'], [' ', '|'], $inputString); + $splitArray = explode(' | ', $decodedString); + $author = trim($splitArray[0]); + $timeString = trim($splitArray[1]); + $timestamp = strtotime($timeString); + return [ + 'author' => $author, + 'timestamp' => $timestamp + ]; + } +} |