From 7bb23c8ce8fb1c3dab8dc8128ad40d37d4b550f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Fri, 6 Dec 2013 12:01:30 +0100 Subject: [PATCH] FIX: better handle errors in youtube onebox --- lib/oneboxer/youtube_onebox.rb | 3 ++- lib/tasks/posts.rake | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/oneboxer/youtube_onebox.rb b/lib/oneboxer/youtube_onebox.rb index 032352e813f..4ebdf43206b 100644 --- a/lib/oneboxer/youtube_onebox.rb +++ b/lib/oneboxer/youtube_onebox.rb @@ -3,12 +3,13 @@ require_dependency 'oneboxer/oembed_onebox' module Oneboxer class YoutubeOnebox < OembedOnebox matcher /^https?:\/\/(?:www\.)?(?:youtube\.com|youtu\.be)\/.+$/ + def oembed_endpoint "http://www.youtube.com/oembed?url=#{BaseOnebox.uriencode(@url.sub('https://', 'http://'))}&format=json" end def onebox - super.each do |entry| + (super || []).each do |entry| # Youtube allows HTTP and HTTPS, so replace them with the protocol-agnostic variant BaseOnebox.replace_agnostic entry # Add wmode=opaque to the iframe src URL so that the flash player is rendered within the document flow instead of on top diff --git a/lib/tasks/posts.rake b/lib/tasks/posts.rake index 6d875bb4a03..198829083af 100644 --- a/lib/tasks/posts.rake +++ b/lib/tasks/posts.rake @@ -26,7 +26,7 @@ def rebake_post(post,opts) # Extracts urls from the body TopicLink.extract_from post # make sure we trigger the post process - post.trigger_post_process(bypass_bump: true) + post.trigger_post_process(true) rescue => e puts "\n\nFailed to bake topic_id #{post.topic_id} post_id #{post.id} #{e}\n#{e.backtrace.join("\n")} \n\n"