Class: Agqr::Recorder
- Inherits:
-
Object
- Object
- Agqr::Recorder
- Defined in:
- lib/agqr/recorder.rb,
lib/agqr/recorder/job.rb
Defined Under Namespace
Classes: Job
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#jobs ⇒ Object
Returns the value of attribute jobs.
Instance Method Summary collapse
- #agqr_stream_url ⇒ Object
-
#initialize(attributes) ⇒ Recorder
constructor
A new instance of Recorder.
- #load_programs ⇒ Object
- #programs ⇒ Object
- #record(job) ⇒ Object
- #reserve(program) ⇒ Object
- #rtmpdump ⇒ Object
- #save_path ⇒ Object
Constructor Details
#initialize(attributes) ⇒ Recorder
Returns a new instance of Recorder.
10 11 12 13 |
# File 'lib/agqr/recorder.rb', line 10 def initialize(attributes) @attributes = attributes @jobs = [] end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
8 9 10 |
# File 'lib/agqr/recorder.rb', line 8 def attributes @attributes end |
#jobs ⇒ Object
Returns the value of attribute jobs.
7 8 9 |
# File 'lib/agqr/recorder.rb', line 7 def jobs @jobs end |
Instance Method Details
#agqr_stream_url ⇒ Object
46 47 48 |
# File 'lib/agqr/recorder.rb', line 46 def agqr_stream_url attributes["agqr_stream_url"] end |
#load_programs ⇒ Object
15 16 17 18 19 20 |
# File 'lib/agqr/recorder.rb', line 15 def load_programs programs.each do |program| reserve(program) end exec end |
#programs ⇒ Object
38 39 40 |
# File 'lib/agqr/recorder.rb', line 38 def programs attributes["programs"] end |
#record(job) ⇒ Object
29 30 31 32 |
# File 'lib/agqr/recorder.rb', line 29 def record(job) cmd = "#{rtmpdump} -r #{agqr_stream_url} --live -B #{job.program.length} -o #{save_path}/#{job.program.title}_#{Time.now.strftime('%Y%m%d').gsub(' ', '')}.flv" system cmd end |
#reserve(program) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/agqr/recorder.rb', line 22 def reserve(program) job = Job.new(self) job.build(program) jobs << job job.start end |
#rtmpdump ⇒ Object
34 35 36 |
# File 'lib/agqr/recorder.rb', line 34 def rtmpdump attributes["rtmpdump"] end |
#save_path ⇒ Object
42 43 44 |
# File 'lib/agqr/recorder.rb', line 42 def save_path attributes["save_path"] end |