rbtune 1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,51 @@
1
+ require "rbtune/radiko_premium"
2
+ require "rbtune/station"
3
+ require "player/ffmpeg"
4
+ require "date"
5
+ require "fileutils"
6
+
7
+ class DateTime
8
+ def timefree
9
+ strftime "%Y%m%d%H%M%S"
10
+ end
11
+ end
12
+
13
+
14
+ class TimeFree < RadikoPremium
15
+ def self.stations
16
+ []
17
+ end
18
+
19
+ def record(filename, starttime, sec)
20
+ endtime = starttime + sec/60/60/24
21
+
22
+ from = starttime.timefree
23
+ to = endtime.timefree
24
+ # pp [@channel, from, to]
25
+ uri = channel_to_uri from, to
26
+ player = create_player uri
27
+ dt = datetime starttime
28
+ recfile = make_recfile filename, dt
29
+ stdout, stderr, status = player.rec recfile, nil
30
+ case stderr
31
+ when /400 Bad Request/
32
+ raise HTTPBadRequestException
33
+ when /403 Forbidden/
34
+ raise HTTPForbiddenException
35
+ end
36
+ end
37
+
38
+ def channel_to_uri(from, to)
39
+ %Q(https://radiko.jp/v2/api/ts/playlist.m3u8?l=15&station_id=#{@channel}&ft=#{from}&to=#{to})
40
+ end
41
+
42
+
43
+ def create_player(uri)
44
+ ffmpeg = FFMpeg.new
45
+ ffmpeg['loglevel'] = 'info'
46
+ ffmpeg['headers'] = %Q("X-Radiko-AuthToken: #{authtoken}")
47
+ ffmpeg['i'] = %Q("#{uri}")
48
+ ffmpeg['acodec'] = 'copy' # acodecオプションはiオプションのあとに置かないとエラー
49
+ ffmpeg
50
+ end
51
+ end
@@ -0,0 +1,3 @@
1
+ module Rbtune
2
+ VERSION = "1.0"
3
+ end
@@ -0,0 +1,34 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "rbtune/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rbtune"
8
+ spec.version = Rbtune::VERSION
9
+ spec.authors = ["ASAHI,Michiharu"]
10
+ spec.email = ["fusuian@gmail.com"]
11
+
12
+ spec.summary = %q{The Japanese IP simulcast Player and Recorder.}
13
+ spec.description = %q{Playing and Recording Radiko, Radiru*Radiru and the other IP simulcast sites.}
14
+ spec.homepage = "https://github.com/fusuian/rbtune"
15
+ spec.license = "MIT"
16
+ spec.required_ruby_version = Gem::Requirement.new("~> 2.5")
17
+
18
+
19
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
20
+ f.match(%r{^(test|spec|features)/})
21
+ end
22
+ spec.bindir = "exe"
23
+ spec.executables = %w(rbtune timefree)
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_dependency "mechanize", "~> 2.7"
27
+ spec.add_dependency "rmagick", "= 2.13.2" # swf_ruby が依存するので固定
28
+ spec.add_dependency "swf_ruby", "~> 0.2"
29
+ spec.add_dependency "pit", "~> 0.0.7"
30
+ spec.add_development_dependency "bundler", "~> 2.1"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ # spec.add_development_dependency "pry"
33
+
34
+ end
metadata ADDED
@@ -0,0 +1,158 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rbtune
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ platform: ruby
6
+ authors:
7
+ - ASAHI,Michiharu
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-07-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mechanize
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rmagick
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 2.13.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 2.13.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: swf_ruby
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.2'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pit
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.0.7
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.0.7
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.1'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.1'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '10.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '10.0'
97
+ description: Playing and Recording Radiko, Radiru*Radiru and the other IP simulcast
98
+ sites.
99
+ email:
100
+ - fusuian@gmail.com
101
+ executables:
102
+ - rbtune
103
+ - timefree
104
+ extensions: []
105
+ extra_rdoc_files: []
106
+ files:
107
+ - ".gitignore"
108
+ - Gemfile
109
+ - LICENSE
110
+ - README.md
111
+ - Rakefile
112
+ - bin/console
113
+ - bin/rbplay
114
+ - bin/setup
115
+ - exe/rbtune
116
+ - exe/timefree
117
+ - lib/keychain.rb
118
+ - lib/player/ffmpeg.rb
119
+ - lib/player/mplayer.rb
120
+ - lib/player/player.rb
121
+ - lib/player/rtmpdump.rb
122
+ - lib/rbtune.rb
123
+ - lib/rbtune/agqr.rb
124
+ - lib/rbtune/jcba.rb
125
+ - lib/rbtune/listenradio.rb
126
+ - lib/rbtune/radiko.rb
127
+ - lib/rbtune/radiko_premium.rb
128
+ - lib/rbtune/radio.rb
129
+ - lib/rbtune/radiru.rb
130
+ - lib/rbtune/simul.rb
131
+ - lib/rbtune/station.rb
132
+ - lib/rbtune/timefree.rb
133
+ - lib/rbtune/version.rb
134
+ - rbtune.gemspec
135
+ homepage: https://github.com/fusuian/rbtune
136
+ licenses:
137
+ - MIT
138
+ metadata: {}
139
+ post_install_message:
140
+ rdoc_options: []
141
+ require_paths:
142
+ - lib
143
+ required_ruby_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - "~>"
146
+ - !ruby/object:Gem::Version
147
+ version: '2.5'
148
+ required_rubygems_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ requirements: []
154
+ rubygems_version: 3.1.2
155
+ signing_key:
156
+ specification_version: 4
157
+ summary: The Japanese IP simulcast Player and Recorder.
158
+ test_files: []