From e1fac42bf1eb0bc1fd6c9645f61c49b15e84960f Mon Sep 17 00:00:00 2001 From: Samuel Clay Date: Wed, 23 Nov 2022 12:21:46 -0500 Subject: [PATCH] Fixing NYPost feed by ensuring enclosures with href attrbiutes are added to stories even without content. Thanks @kleinmatic! --- apps/rss_feeds/models.py | 1 + utils/story_functions.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/rss_feeds/models.py b/apps/rss_feeds/models.py index 70a735e1f..2fd7079d8 100755 --- a/apps/rss_feeds/models.py +++ b/apps/rss_feeds/models.py @@ -2615,6 +2615,7 @@ class MStory(mongo.Document): RE_RS_KEY = re.compile(r"^RS:(\d+):(\d+)$") def __str__(self): + content = self.story_content_z if self.story_content_z else "" return f"{self.story_hash}: {self.story_title[:20]} ({len(self.story_content_z)} bytes)" @property diff --git a/utils/story_functions.py b/utils/story_functions.py index 6de184687..57172d429 100644 --- a/utils/story_functions.py +++ b/utils/story_functions.py @@ -151,9 +151,9 @@ def pre_process_story(entry, encoding): # Add each media enclosure as a Download link for media_content in chain(entry.get('media_content', [])[:15], entry.get('links', [])[:15]): - media_url = media_content.get('url', '') + media_url = media_content.get('url', media_content.get('href', '')) media_type = media_content.get('type', media_content.get('medium', '')) - if media_url and media_type and entry['story_content'] and media_url not in entry['story_content']: + if media_url and media_type and media_url not in entry['story_content']: media_type_name = media_type.split('/')[0] if 'audio' in media_type and media_url: entry['story_content'] += """