lib/onebox/engine/youtube_onebox.rb in onebox-1.5.17 vs lib/onebox/engine/youtube_onebox.rb in onebox-1.5.18
- old
+ new
@@ -55,9 +55,17 @@
end
html
end
+ def video_title
+ yt_oembed_url = "http://www.youtube.com/oembed?format=json&url=http://www.youtube.com/watch?v=#{video_id.split('?')[0]}"
+ yt_oembed_data = Onebox::Helpers.symbolize_keys(::MultiJson.load(Onebox::Helpers.fetch_response(yt_oembed_url).body))
+ yt_oembed_data[:title]
+ rescue
+ return nil
+ end
+
# Regex to parse strings like "1h3m2s". Also accepts bare numbers (which are seconds).
TIMESTR_REGEX = /(\d+h)?(\d+m)?(\d+s?)?/
def embed_params
p = {'feature' => 'oembed', 'wmode' => 'opaque'}