Accessing Podcast Extension getSummary in RSS Feed Entry

In a Xenforo project, we are importing podcasts from an RSS feed in Feedburner.

The Feedburner RSS XML contains an <itunes:summary> tag that describes the podcast. We would like to show that summary text to the members so they can decide whether they would like to listen to the podcast.

Xenforo is using \Laminas\Feed\Rss\Entry::getContent() to populate a template variable, but there is no corresponding content in the RSS XML, therefore the {content} template variable is resulting as empty.

I have found that I can patch the \Laminas\Feed\Rss\Entry::getContent() method to use the Podcast extension’s getSummary() to populate the empty $content variable before returning it. That gives us what we want:

// file: /src/vendor/laminas/laminas-feed/src/Reader/Entry/Rss.php
// line: 136 at 20201005

/**
 * Get the entry content
 *
 * @return string
 */
public function getContent()
{
    if (array_key_exists('content', $this->data)) {
        return $this->data['content'];
    }

    $content = $this->getExtension('Content')->getContent();

    if (! $content) {
        $content = $this->getDescription();
    }

    if (empty($content)) {
        $content = $this->getExtension('Atom')->getContent();
    }
    
    // begin antz 20201005 - implement iTunes podcast in RSS feed importer
    if (empty($content)) {
        $content = nl2br($this->getExtension('Podcast')->getSummary());
    }
    // end antz 20201005 - implement iTunes podcast in RSS feed importer

    $this->data['content'] = $content;

    return $this->data['content'];
}

Now, the only thing is that we don’t want to be hacking and patching the Laminas files because the changes are likely to be overwritten with future upgrades, and also Xenforo performs periodic file integrity checks and it is generating a big error message that all staff are seeing in the Administration Control Panel, and that message can’t be dismissed.

I am requesting advice how to best implement this feature. It seems to me that Laminas Rss should have a method getSummary() in order to access the Podcast Extension’s getSummary() method, and then Xenforo could use that to populate a {summary} variable for our template.

Hello and welcome to our forums! :smiley:

laminas-feed can consume different types of feeds. Types like podcasts can read and write with the help of extensions.
“Podcast” is one core extension and it is registered by default.

So you can read the summary of an (iTunes) podcast directly:

$feed = Laminas\Feed\Reader\Reader::import('https://feeds.megaphone.fm/drumhistory');

echo $feed->getTitle(); // "Drum History"
echo $feed->getSubtitle(); // "A podcast all about the rich history of the drums…"
echo $feed->getSummary(); // "A podcast all about the rich history of the drums - and how they became what they are today! Join Bart van der Zee as he speaks with experts about the curious journey of the ever-evolving drum set."
echo $feed->getPodcastType(); // "episodic"
echo $feed->getCastAuthor(); // "Bart Vanderzee"

See also the extension folder:

Thank you Frank! … I have found that the Xenforo feed importer can use $entry->getSummary() to access the itunes:summary element, and that is the best place to do it. I can now make the Entry’s summary text available to the template and it does not impact the existing Content text.

So I am pleased to find that solution and I will move my code into that file :slight_smile:

Solution in Xenforo Feed Importer
// XF\Service\Feed\Reader::getFeedEntries() at line 135:
    $entryData = [
    				'id' => $entry->getId(),
    				'title' => html_entity_decode($entry->getTitle(), ENT_COMPAT, 'utf-8'),
    				'description' => html_entity_decode($entry->getDescription(), ENT_COMPAT, 'utf-8'),
    				'date_modified' => $dateModified,
    				'author' => $this->getAuthorsAsString($entry->getAuthors()),
    				'link' => $entry->getLink(),
    				// begin patch antz 20201102 - make podcast summary content available in RSS feed imports
    				'summary' => $this->getContent(nl2br($entry->getSummary())),
    				// end patch antz 20201102 - make podcast summary content available in RSS feed imports
    				'content' => $this->getContent($content)
    			];