Class: Onebox::Engine::YoukuOnebox
- Inherits:
-
Object
- Object
- Onebox::Engine::YoukuOnebox
- Includes:
- Onebox::Engine, HTML
- Defined in:
- lib/onebox/engine/youku_onebox.rb
Constant Summary
Constants included from Onebox::Engine
Instance Attribute Summary
Attributes included from Onebox::Engine
Instance Method Summary collapse
- #placeholder_html ⇒ Object
- #to_html ⇒ Object
-
#video_id ⇒ Object
Try to get the video ID.
Methods included from Onebox::Engine
engines, included, #initialize, #options, #options=
Instance Method Details
#placeholder_html ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/onebox/engine/youku_onebox.rb', line 24 def placeholder_html if video_id = "http://v.youku.com/player/getPlayList/VideoIDS/#{video_id}" response = Onebox::Helpers.fetch_response() = MultiJson::load(response.body) if response && response.body image_src = if && ['data'] && ['data'][0] && ['data'][0]['logo'] ['data'][0]['logo'] else nil end "<img src='#{image_src}' width='480' height='270'>" else to_html end end |
#to_html ⇒ Object
20 21 22 |
# File 'lib/onebox/engine/youku_onebox.rb', line 20 def to_html "<iframe width='480' height='270' src='http://player.youku.com/embed/#{video_id}' frameborder='0' allowfullscreen></iframe>" end |
#video_id ⇒ Object
Try to get the video ID. Works for URLs of the form:
11 12 13 14 15 16 17 18 |
# File 'lib/onebox/engine/youku_onebox.rb', line 11 def video_id match = uri.path.match(/\/v_show\/id_([a-zA-Z0-9]*)(\.html)*/) return match[1] if match && match[1] nil rescue return nil end |