lib/onebox/engine/youtube_onebox.rb in onebox-1.7.5 vs lib/onebox/engine/youtube_onebox.rb in onebox-1.7.6
- old
+ new
@@ -82,24 +82,27 @@
end
def list_thumbnail_url
@list_thumbnail_url ||= begin
url = "https://www.youtube.com/oembed?format=json&url=https://www.youtube.com/playlist?list=#{list_id}"
- data = Onebox::Helpers.symbolize_keys(::MultiJson.load(Onebox::Helpers.fetch_response(url).body))
+ response = Onebox::Helpers.fetch_response(url) rescue "{}"
+ data = Onebox::Helpers.symbolize_keys(::MultiJson.load(response))
data[:thumbnail_url]
rescue
nil
end
end
def video_oembed_data
url = "https://www.youtube.com/oembed?format=json&url=https://www.youtube.com/watch?v=#{video_id}"
- Onebox::Helpers.symbolize_keys(::MultiJson.load(Onebox::Helpers.fetch_response(url).body))
+ response = Onebox::Helpers.fetch_response(url) rescue "{}"
+ Onebox::Helpers.symbolize_keys(::MultiJson.load(response))
end
def list_oembed_data
url = "https://www.youtube.com/oembed?format=json&url=https://www.youtube.com/playlist?list=#{list_id}"
- Onebox::Helpers.symbolize_keys(::MultiJson.load(Onebox::Helpers.fetch_response(url).body))
+ response = Onebox::Helpers.fetch_response(url) rescue "{}"
+ Onebox::Helpers.symbolize_keys(::MultiJson.load(response))
end
def embed_params
p = {'feature' => 'oembed', 'wmode' => 'opaque'}