summaryrefslogtreecommitdiff
path: root/providers/Substack.php
diff options
context:
space:
mode:
Diffstat (limited to 'providers/Substack.php')
-rw-r--r--providers/Substack.php23
1 files changed, 18 insertions, 5 deletions
diff --git a/providers/Substack.php b/providers/Substack.php
index 6dea64a..83a6e06 100644
--- a/providers/Substack.php
+++ b/providers/Substack.php
@@ -23,19 +23,32 @@ class Substack extends \Providers\JsonFeed {
$items = [];
foreach ($content as $item) {
$itemObject = new Item();
- $itemObject->ID = sprintf($this->feedUrl . '/' . $item->publication_id);
- $itemObject->Title = strval($item->title);
+ $itemObject->ID = sprintf($this->feedUrl . $item->id);
+ $itemObject->Title = $item->title;
+ if ($item->subtitle) {
+ $itemObject->Title .= ' | ' . $item->subtitle;
+ }
$itemObject->Time = $item->post_date;
- $itemObject->Text = $item->body_html;
+ $itemObject->Text = $item->truncated_body_text;
$itemObject->Link = $item->canonical_url;
- $itemObject->Author = $item->publishedByLines[0]->name;
+ $itemObject->Author = $item->publishedBylines[0]->name;
$items[] = $itemObject;
}
return $items;
}
public function title() {
- return sprintf("%s's substack", $this->_feed);
+ $cacheFile = sprintf($this->_getCachePath() . '.title', $this->_feed);
+ if (!file_exists($cacheFile)) {
+ $this->_fetchItems();
+ }
+ if ($this->_feedJson) {
+ $title = $this->_feedJson[0]->publishedBylines[0]->publicationUsers[0]->publication->name;
+ file_put_contents($cacheFile, $title);
+ return $title;
+ } else {
+ return file_get_contents($cacheFile);
+ }
}
}