agqr-recorder 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ec7f14cef0d4b152158804659c004205dff68320
4
+ data.tar.gz: 8b5c118818469accfe348a60e02965ddf9f37cf6
5
+ SHA512:
6
+ metadata.gz: 5b88bb992a669ef430936b401a274062725a2d198a9826980b59be18c200541e8e9604cc0a8d40369ce9e0492ac83e16dc3be443f9caaae43f92f6f2862cbaef
7
+ data.tar.gz: 62eeef0316788735513aebce7d4ee532ff4eaca0523c3226dec0509469a007b52c5caca9d2c82b11b4c0f95b47cd0084016ea1c193f62b3892053121200cfad1
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in agqr.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Tomohiro Suwa(tsuwatch)
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # Agqr::Recorder
2
+ Record agqr-program by cron format
3
+
4
+ ## Installation
5
+
6
+ Add this line to your application's Gemfile:
7
+
8
+ gem 'agqr-recorder'
9
+
10
+ And then execute:
11
+
12
+ $ bundle
13
+
14
+ Or install it yourself as:
15
+
16
+ $ gem install agqr-recorder
17
+
18
+ ## Usage
19
+
20
+ ### Configuration
21
+ ```
22
+ agqr_stream_url: rtmp://fms-base1.mitene.ad.jp/agqr/aandg2
23
+ save_path: pato/to/save/dir
24
+ rtmpdump: path_to_rtmpdump
25
+
26
+ programs:
27
+ - title: program_title
28
+ schedule: cron_format
29
+ length: recording_time
30
+ ```
31
+
32
+ ## Contributing
33
+
34
+ 1. Fork it ( https://github.com/[my-github-username]/agqr-recorder/fork )
35
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
36
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
37
+ 4. Push to the branch (`git push origin my-new-feature`)
38
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'agqr/recorder/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "agqr-recorder"
8
+ spec.version = Agqr::VERSION
9
+ spec.authors = ["Tomohiro Suwa(tsuwatch)"]
10
+ spec.email = ["neoen.gsn@gmail.com"]
11
+ spec.summary = %q{Record agqr-program by cron format}
12
+ spec.description = %q{Record agqr-program by cron format}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "chrono"
22
+ spec.add_development_dependency "bundler", "~> 1.6"
23
+ spec.add_development_dependency "rake"
24
+ end
data/bin/agqr-recorder ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require_relative "../lib/agqr"
4
+
5
+ Agqr.run ARGV
data/lib/agqr.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'yaml'
2
+ require "agqr/recorder"
3
+
4
+ module Agqr
5
+ class << self
6
+
7
+ def run(argv)
8
+ if argv[0] == "--help"
9
+ puts "Usage: #{File.basename(__FILE__)} [config_file=config.yml]"
10
+ exit
11
+ end
12
+
13
+ config = YAML.load_file(argv[0] || "config.yml")
14
+ recorder = Agqr::Recorder.new(config)
15
+ recorder.load_programs
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,13 @@
1
+ module Agqr
2
+ class Program
3
+
4
+ attr_reader :title, :schedule, :length
5
+
6
+ def initialize(program)
7
+ @title = program["title"]
8
+ @schedule = program["schedule"]
9
+ @length = program["length"]
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,58 @@
1
+ require "agqr/recorder/job"
2
+ require "agqr/recorder/version"
3
+
4
+ module Agqr
5
+ class Recorder
6
+
7
+ attr_accessor :jobs
8
+ attr_reader :attributes
9
+
10
+ def initialize(attributes)
11
+ @attributes = attributes
12
+ @jobs = []
13
+ end
14
+
15
+ def load_programs
16
+ programs.each do |program|
17
+ reserve(program)
18
+ end
19
+ exec
20
+ end
21
+
22
+ def reserve(program)
23
+ job = Job.new(self)
24
+ job.build(program)
25
+ jobs << job
26
+ job.start
27
+ end
28
+
29
+ def record(job)
30
+ 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"
31
+ system cmd
32
+ end
33
+
34
+ def rtmpdump
35
+ attributes["rtmpdump"]
36
+ end
37
+
38
+ def programs
39
+ attributes["programs"]
40
+ end
41
+
42
+ def save_path
43
+ attributes["save_path"]
44
+ end
45
+
46
+ def agqr_stream_url
47
+ attributes["agqr_stream_url"]
48
+ end
49
+
50
+ private
51
+
52
+ def exec
53
+ loop do
54
+ end
55
+ end
56
+
57
+ end
58
+ end
@@ -0,0 +1,32 @@
1
+ require "chrono"
2
+ require "agqr/program"
3
+
4
+ module Agqr
5
+ class Recorder
6
+ class Job
7
+
8
+ attr_reader :recorder, :program, :thread
9
+
10
+ def initialize(recorder)
11
+ @recorder = recorder
12
+ end
13
+
14
+ def build(program)
15
+ @program = Program.new(program)
16
+ end
17
+
18
+ def start
19
+ @thread = Thread.new do
20
+ Chrono::Trigger.new(program.schedule) do
21
+ recorder.record self
22
+ end.run
23
+ end
24
+ end
25
+
26
+ def stop
27
+ thread.kill
28
+ end
29
+
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,3 @@
1
+ module Agqr
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: agqr-recorder
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Tomohiro Suwa(tsuwatch)
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: chrono
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Record agqr-program by cron format
56
+ email:
57
+ - neoen.gsn@gmail.com
58
+ executables:
59
+ - agqr-recorder
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - .gitignore
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - agqr-recorder.gemspec
69
+ - bin/agqr-recorder
70
+ - lib/agqr.rb
71
+ - lib/agqr/program.rb
72
+ - lib/agqr/recorder.rb
73
+ - lib/agqr/recorder/job.rb
74
+ - lib/agqr/recorder/version.rb
75
+ homepage: ''
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.1.11
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: Record agqr-program by cron format
99
+ test_files: []