Feature request: make itunes:summary available as a template variable in RSS feed import

antzcode

New member
The RSS feed importer automatically imports feed entries from an RSS feed. Each entry in the feed creates a new thread.

When importing a Podcast feed, the feed entries provide an <itunes:summary>...</itunes:summary> element and an <enclosure /> element.

Example of a podcast feed item from https://feeds.feedburner.com/FocusOnTheFamilyDailyBroadcast.rss:
XML:
<item>
            <title>Teaching Boys to Respect Women</title>
            <itunes:subtitle />
            <itunes:author>Guest: Dave Willis</itunes:author>
            <itunes:summary>In a discussion based on his book "Raising Boys Who Respect Girls," Dave Willis offers parents advice for cultivating within their young sons a healthy respect for others, particularly girls and women.

Get Dave's book for your donation of any amount: https://store.focusonthefamily.com/singleitem/checkout/donation/item/don-daily-broadcast-product-2020-10-28

Get more episode resources: https://www.focusonthefamily.com/episodes/broadcast/teaching-boys-to-respect-women/

If you've listened to any of our podcasts, please give us your feedback: https://focusonthefamily.com/podcastsurvey/</itunes:summary>
            <pubDate>Wed, 28 Oct 2020 10:00:00 +0000</pubDate>

        
            <itunes:duration>1623</itunes:duration>
            <itunes:image href="https://images.subsplash.com/base64/L2ltYWdlLmpwZz9pZD1kYjMyYzY1Ny1iZTU3LTQ3YzEtYmRjOC02NDE2YTYxMzAwNzcmdz0xNDAwJmg9MTQwMA.jpg" />
            <itunes:order>2</itunes:order>
            <guid isPermaLink="false">a78b265a39b584edc1ab0dba83c55c5b</guid>
            <itunes:explicit>no</itunes:explicit>
        <enclosure url="http://feedproxy.google.com/~r/FocusOnTheFamilyDailyBroadcast/~5/2uAs6R-LfQo/audio.mp3" length="0" type="audio/mp3" /><feedburner:origEnclosureLink>https://dts.podtrac.com/redirect.mp3/focusonthefamily.mc.tritondigital.com/FOTF_BROADCAST_P/media/e56f2401-2081-465f-83d4-2585a5ea7adb/audio.mp3</feedburner:origEnclosureLink></item>

        <item>

The enclosure element has the mp3 resource of the podcast. The itunes:summary element describes the topic and content of the podcast so that a reader can decide whether the podcast is relevant and interesting to them before listening to it.

Xenforo provides a template to configure the markup of the thread content when we import the feed entries:

xenforo-feed-import-template-20201102.png

In the present form (Xenforo v2.2.1), the content of itunes:summary is not available as a template variable (eg: {summary}). In addition to that, the {content} variable is empty, which results in a thread being created with only a title and an mp3.

Our members have complained that it is annoying to them that they cannot see any description of the podcast before listening to it.

I have found that it is easy to provide the content of the itunes:summary element to the template as a {summary} variable with only one line of PHP code. As a result, a thread is created that contains the podcast and summary:

focus-on-the-family-rss-feed-entry-20201030.png

That is an ideal solution and I think it should be considered an ideal feature of XF RSS Importer.

The change I have made is in a file that belongs to Xenforo core, so it is now triggering the periodic file integrity script and generating a big red warning message in the Admin Panel:

file-integrity-warning.png

file-integrity-warning-detail.png

The error message cannot be dismissed and it is reflecting poorly upon my proficiency as a developer.

I would like to request that Xenforo may consider adding the change to the core so that the itunes:summary text is available by design.

The change is found on line 136 of /src/XF/Service/Feed/Reader.php:

Original code:

PHP:
            $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(),
                'content' => $this->getContent($content)
            ];

New code:

PHP:
            $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(),
                'summary' => $this->getContent(nl2br($entry->getSummary())),
                'content' => $this->getContent($content)
            ];

Note the addition of the 'summary' array property above the 'content' property:

PHP:
                'summary' => $this->getContent(nl2br($entry->getSummary())),

That converts plain text line breaks to html <br /> tags and then sanitises the text according to the existing rules for the 'content' property. No other changes are needed for this feature.
 
Upvote 4

dvsDave

Well-known member
This would make my life so much easier. I want to import a number of podcast RSS feeds and make it easy for users to listen to them directly on my site.

Even better would be to simply allow us to import the contents of any custom tag instead of limiting it to {title} {content} {author} {link}

podcast's have the files in the <guid> </guid> or the <enclosure> tag, so we should be able to just use {guid} or {enclosure} to insert the contents of the tag into the post.
 
Top