Show
Ignore:
Timestamp:
06/26/08 22:07:46 (5 months ago)
Author:
sho
Message:

platform/tdiary/plugin/nicovideo.rb: added label and link to nicovideo plugin.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • platform/tdiary/plugin/nicovideo.rb

    r11024 r14647  
    88#    Link to the movie and show thumbnail , description...: 
    99#    <%= nicovideo 'sm99999999' %> 
     10# 
     11#    Link to the movie with original label: 
     12#    <%= nicovideo 'sm99999999', 'movie title' %> 
     13# 
     14#    Link to the movie with original label and link: 
     15#    <%= nicovideo 'sm99999999', 'movie title', 'http://example.com/video' %> 
    1016# 
    1117#    Show Inline player: 
     
    3339end 
    3440 
    35 def nicovideo_inline( elem ) 
    36         url = elem.to_a( 'watch_url' )[0].text 
     41def nicovideo_inline( elem, label = nil, link = nil ) 
     42        url = link || elem.to_a( 'watch_url' )[0].text 
    3743        thumb = elem.to_a( 'thumbnail_url' )[0].text 
    38         title = elem.to_a( 'title' )[0].text 
    39         desc = elem.to_a( 'description' )[0].text 
    40         comment = elem.to_a( 'last_res_body' )[0].text 
     44        title = label || elem.to_a( 'title' )[0].text 
     45        desc = label ? nil : elem.to_a( 'description' )[0].text 
     46        comment = label ? nil : elem.to_a( 'last_res_body' )[0].text 
    4147        length = elem.to_a( 'length' )[0].text 
    4248        view = elem.to_a( 'view_counter' )[0].text 
     
    4854        end 
    4955 
    50         if feed? then 
     56        if feed? or label then 
    5157                result = <<-HTML 
    5258                        <table border="0" cellpadding="4" cellspacing="0" summary="#{title}"><tr valign="top"> 
     
    8389end 
    8490 
    85 def nicovideo( video_id, label = nil ) 
     91def nicovideo( video_id, label = nil, link = nil ) 
    8692        begin 
    87                 @conf.to_native( nicovideo_inline( nicovideo_call_api( video_id ).elements ), 'UTF-8' ) 
     93                @conf.to_native( nicovideo_inline( nicovideo_call_api( video_id ).elements, label, link ), 'UTF-8' ) 
    8894        rescue ::Errno::ENOENT 
    8995                "<strong>Sorry, #{video_id} was deleted.</strong>" 
    90         rescue Timeout::Error,OpenURI::HTTPError,SecurityError 
     96        rescue Timeout::Error, OpenURI::HTTPError, SecurityError 
    9197                nicovideo_iframe( video_id ) 
    9298        end