FIX: better handle errors in youtube onebox

This commit is contained in:
Régis Hanol 2013-12-06 12:01:30 +01:00
parent 418856a789
commit 7bb23c8ce8
2 changed files with 3 additions and 2 deletions

View File

@ -3,12 +3,13 @@ require_dependency 'oneboxer/oembed_onebox'
module Oneboxer module Oneboxer
class YoutubeOnebox < OembedOnebox class YoutubeOnebox < OembedOnebox
matcher /^https?:\/\/(?:www\.)?(?:youtube\.com|youtu\.be)\/.+$/ matcher /^https?:\/\/(?:www\.)?(?:youtube\.com|youtu\.be)\/.+$/
def oembed_endpoint def oembed_endpoint
"http://www.youtube.com/oembed?url=#{BaseOnebox.uriencode(@url.sub('https://', 'http://'))}&format=json" "http://www.youtube.com/oembed?url=#{BaseOnebox.uriencode(@url.sub('https://', 'http://'))}&format=json"
end end
def onebox def onebox
super.each do |entry| (super || []).each do |entry|
# Youtube allows HTTP and HTTPS, so replace them with the protocol-agnostic variant # Youtube allows HTTP and HTTPS, so replace them with the protocol-agnostic variant
BaseOnebox.replace_agnostic entry 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 # Add wmode=opaque to the iframe src URL so that the flash player is rendered within the document flow instead of on top

View File

@ -26,7 +26,7 @@ def rebake_post(post,opts)
# Extracts urls from the body # Extracts urls from the body
TopicLink.extract_from post TopicLink.extract_from post
# make sure we trigger the post process # make sure we trigger the post process
post.trigger_post_process(bypass_bump: true) post.trigger_post_process(true)
rescue => e rescue => e
puts "\n\nFailed to bake topic_id #{post.topic_id} post_id #{post.id} #{e}\n#{e.backtrace.join("\n")} \n\n" puts "\n\nFailed to bake topic_id #{post.topic_id} post_id #{post.id} #{e}\n#{e.backtrace.join("\n")} \n\n"