diff --git a/apps/rss_feeds/models.py b/apps/rss_feeds/models.py index 0822c5c1f..92c3e944e 100755 --- a/apps/rss_feeds/models.py +++ b/apps/rss_feeds/models.py @@ -2496,6 +2496,15 @@ class MStory(mongo.Document): def decoded_story_title(self): return html.unescape(self.story_title) + @property + def story_content_str(self): + story_content = self.story_content + if not story_content and self.story_content_z: + story_content = smart_str(zlib.decompress(self.story_content_z)) + + return story_content + + def save(self, *args, **kwargs): story_title_max = MStory._fields['story_title'].max_length story_content_type_max = MStory._fields['story_content_type'].max_length @@ -2794,12 +2803,10 @@ class MStory(mongo.Document): story_content = None if not text: - story_content = self.story_content - if not story_content and self.story_content_z: - story_content = zlib.decompress(self.story_content_z) + story_content = self.story_content_str elif text: if self.original_text_z: - story_content = zlib.decompress(self.original_text_z) + story_content = smart_str(zlib.decompress(self.original_text_z)) if not story_content: return @@ -2815,6 +2822,28 @@ class MStory(mongo.Document): return images = soup.findAll('img') + + # Add youtube thumbnail and insert appropriately before/after images. + # Give the Youtube a bit of an edge. + video_thumbnails = soup.findAll('iframe', src=lambda x: x and 'youtube.com' in x) + for video_thumbnail in video_thumbnails: + video_src = video_thumbnail.get('src') + video_id = re.search('.*?youtube.com/embed/(.*)(\?.*)?$', video_src) + if video_id: + video_img_url = f"https://img.youtube.com/vi/{video_id}/0.jpg" + else: + logging.debug(f" ***> Couldn't find youtube url in {video_thumbnail}: {video_src}") + continue + iframe_index = story_content.index('= 1024: diff --git a/media/js/newsblur/models/stories.js b/media/js/newsblur/models/stories.js index 8c82b484f..baf153162 100644 --- a/media/js/newsblur/models/stories.js +++ b/media/js/newsblur/models/stories.js @@ -62,7 +62,6 @@ NEWSBLUR.Models.Story = Backbone.Model.extend({ if (this.get('image_urls').length >= index+1) { var url = this.get('image_urls')[index]; if (window.location.protocol == 'https:' && - NEWSBLUR.Globals.is_staff && _.str.startsWith(url, "http://")) { var secure_url = this.get('secure_image_urls')[url]; if (secure_url) url = secure_url;