Display RSS episode descriptions based on the <content:encoded> RSS tags
The previously used <description> tag often only contains plain text, whereas <content:encoded> is typically HTML-encoded and hence better suited for display. Closes #1405
This commit is contained in:
parent
369122b32b
commit
906bbb34bb
|
@ -636,6 +636,7 @@ class RssFeedItemSerializer(serializers.Serializer):
|
|||
links = serializers.ListField()
|
||||
tags = serializers.ListField(required=False)
|
||||
summary_detail = serializers.DictField(required=False)
|
||||
content = serializers.ListField(required=False)
|
||||
published_parsed = DummyField(required=False)
|
||||
image = serializers.DictField(required=False)
|
||||
|
||||
|
@ -648,6 +649,16 @@ class RssFeedItemSerializer(serializers.Serializer):
|
|||
"text": content,
|
||||
}
|
||||
|
||||
def validate_content(self, v):
|
||||
# TODO: Are there RSS feeds that use more than one content item?
|
||||
content = v[0].get("value")
|
||||
if not content:
|
||||
return
|
||||
return {
|
||||
"content_type": v[0].get("type", "text/plain"),
|
||||
"text": content,
|
||||
}
|
||||
|
||||
def validate_image(self, v):
|
||||
url = v.get("href")
|
||||
if url:
|
||||
|
@ -782,6 +793,15 @@ class RssFeedItemSerializer(serializers.Serializer):
|
|||
if tags:
|
||||
tags_models.set_tags(track, *tags)
|
||||
|
||||
# "content" refers to the <content:encoded> node in the RSS feed,
|
||||
# whereas "summary_detail" refers to the <description> node.
|
||||
# <description> is intended to be used as a short summary and is often
|
||||
# encoded merely as plain text, whereas <content:encoded> contains
|
||||
# the full episode description and is generally encoded as HTML.
|
||||
#
|
||||
# For details, see https://www.rssboard.org/rss-profile#element-channel-item-description
|
||||
summary = validated_data.get("content")
|
||||
if not summary:
|
||||
summary = validated_data.get("summary_detail")
|
||||
if summary:
|
||||
common_utils.attach_content(track, "description", summary)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Improve formatting of RSS episode descriptions (#1405)
|
Loading…
Reference in New Issue