From ace19a15e4b761e3aaa5724664986a869d1cc3b9 Mon Sep 17 00:00:00 2001 From: emkael Date: Mon, 31 Jan 2022 21:58:14 +0100 Subject: JSON feeds and Substack support --- providers/JsonFeed.php | 39 +++++++++++++++++++++++++++++++++++++++ providers/Substack.php | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 providers/JsonFeed.php create mode 100644 providers/Substack.php diff --git a/providers/JsonFeed.php b/providers/JsonFeed.php new file mode 100644 index 0000000..2d2ed9d --- /dev/null +++ b/providers/JsonFeed.php @@ -0,0 +1,39 @@ +_feedUrl = $this->_getFeedUrl($feed); + if (!$this->_feedUrl) { + throw new Exception('JSON feed "' . $feed . '" undefined'); + } + } + + abstract protected function _parseFeedContent($feed); + + protected function _fetchItems() { + $this->_feedJson = json_decode(file_get_contents($this->_feedUrl)); + return $this->_parseFeedContent($this->_feedJson); + } + + protected function _spamFilter($content) { + return $content; + } + + protected function _sortContent($content) { + return $content; + } + +} + +?> diff --git a/providers/Substack.php b/providers/Substack.php new file mode 100644 index 0000000..6dea64a --- /dev/null +++ b/providers/Substack.php @@ -0,0 +1,43 @@ +ID = sprintf($this->feedUrl . '/' . $item->publication_id); + $itemObject->Title = strval($item->title); + $itemObject->Time = $item->post_date; + $itemObject->Text = $item->body_html; + $itemObject->Link = $item->canonical_url; + $itemObject->Author = $item->publishedByLines[0]->name; + $items[] = $itemObject; + } + return $items; + } + + public function title() { + return sprintf("%s's substack", $this->_feed); + } + +} + +?> -- cgit v1.2.3