Fixing NYPost feed by ensuring enclosures with href attrbiutes are added to stories even without content. Thanks @kleinmatic!

This commit is contained in:
Samuel Clay 2022-11-23 12:21:46 -05:00
parent c756bb6bcf
commit e1fac42bf1
2 changed files with 3 additions and 2 deletions

View file

@ -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

View file

@ -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'] += """<br><br>