Skip to content

Commit

Permalink
fixing ted talks, youtube params
Browse files Browse the repository at this point in the history
  • Loading branch information
mamuso committed Jan 8, 2009
1 parent 0ee782a commit 6c8dcb9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions lib/acts_as_unvlogable/object_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ def instance_values #:nodoc:
values
end
end

end
11 changes: 8 additions & 3 deletions lib/acts_as_unvlogable/vg_ted.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ def initialize(url=nil, options={})
@url = url
raise unless URI::parse(url).path.split("/").include? "talks"
@page = Hpricot(open(url))
emb = @page.search("//input[@id='embedCode']").first.attributes['value']
tx = Hpricot(emb)
@flashvars = tx.search('//embed').first.attributes['flashvars'].to_s
embedder = @page.to_s.split("new SWFObject")[1].split("so.addParam")[0].gsub("\n", "").gsub("\t", "").split("so.addVariable(\"")
embedder.shift
emb =embedder.map {|k|
i = k.split("\",\"")
"&#{i[0]}=#{i[1].gsub('");', '')}"
}.join
emb = "#{url}?#{emb.gsub(" ", "")}"
@flashvars = "vu=http://video.ted.com/talks/embed/#{emb.query_param('hs').split("/")[-1].split("-stream-")[0]}-embed-PARTNER_high.flv&su=http://images.ted.com/images/ted/tedindex/embed-posters/#{emb.query_param('hs').split("/")[-1].split("-stream-")[0].gsub("_", "-")}.embed_thumbnail.jpg"
@args = CGI::parse(@flashvars)
end

Expand Down
6 changes: 4 additions & 2 deletions lib/acts_as_unvlogable/vg_youtube.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ def embed_url
end

# options
# :nosearchbox => true | removes the searchbox on the player
# You can read more about the youtube player options in
# http://code.google.com/intl/en/apis/youtube/player_parameters.html
# Use them in options (ex {:rel => 0, :color1 => '0x333333'})
#
def embed_html(width=425, height=344, options={})
"<object width='#{width}' height='#{height}'><param name='movie' value='#{embed_url}&fs=1#{'&showsearch=0' if options[:nosearchbox]}'></param><param name='allowFullScreen' value='true'></param><param name='allowscriptaccess' value='always'></param><embed src='#{embed_url}&fs=1#{'&showsearch=0' if options[:nosearchbox] == true}' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='#{width}' height='#{height}'></embed></object>" if @details.noembed == false
"<object width='#{width}' height='#{height}'><param name='movie' value='#{embed_url}#{options.map {|k,v| "&#{k}=#{v}"}}'></param><param name='allowFullScreen' value='true'></param><param name='allowscriptaccess' value='always'></param><embed src='#{embed_url}#{options.map {|k,v| "&#{k}=#{v}"}}' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='#{width}' height='#{height}'></embed></object>" if @details.noembed == false
end


Expand Down

0 comments on commit 6c8dcb9

Please sign in to comment.