Class: RHACK::Youtube
Constant Summary collapse
- URI =
{:info => "http://www.youtube.com/get_video_info?video_id=%s"}
Instance Attribute Summary collapse
-
#track ⇒ Object
readonly
Returns the value of attribute track.
Class Method Summary collapse
Instance Method Summary collapse
- #dl(id, fd = nil, &block) ⇒ Object
- #dlmp3(id, mp3 = nil) ⇒ Object
-
#initialize(frame = nil) ⇒ Youtube
constructor
A new instance of Youtube.
Constructor Details
#initialize(frame = nil) ⇒ Youtube
Returns a new instance of Youtube.
190 191 192 193 194 195 |
# File 'lib/rhack/clients/examples.rb', line 190 def initialize frame=nil super :dl, frame, :eval => false @f.ss.each {|s| s.timeout=600} require 'open3' require 'mp3info' end |
Instance Attribute Details
#track ⇒ Object (readonly)
Returns the value of attribute track.
188 189 190 |
# File 'lib/rhack/clients/examples.rb', line 188 def track @track end |
Class Method Details
.dl(id) ⇒ Object
219 |
# File 'lib/rhack/clients/examples.rb', line 219 def self.dl(id) new.dl(id) end |
.dlmp3(id) ⇒ Object
220 |
# File 'lib/rhack/clients/examples.rb', line 220 def self.dlmp3(id) new.dlmp3(id) end |
Instance Method Details
#dl(id, fd = nil, &block) ⇒ Object
197 198 199 200 201 202 |
# File 'lib/rhack/clients/examples.rb', line 197 def dl(id, fd=nil, &block) if block info(id) {|lnk| __dl(lnk, fd, block)} else __dl(info(id), fd) end end |
#dlmp3(id, mp3 = nil) ⇒ Object
204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/rhack/clients/examples.rb', line 204 def dlmp3(id, mp3=nil) dl(id) {|flv| if !File.file?(df = mp3||flv.sub(/.flv$/, '.mp3')) Open3.popen3("ffmpeg -i '#{flv}' -ab 262144 -ar 44100 '#{df}'") {|i,o,e| if $verbose t = e.gets2 and t and t[/^size=/] and print t until e.eof? puts "\n#{t}" end } end Mp3Info.open(df, :encoding=>'utf-8') {|mp3| mp3.tag2.TPE1, mp3.tag2.TIT2 = @track[1..2] } } end |