sleeproom 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8ccc2b043aff09d26b34628f302b06b38f3cca3aba8193bcd0164a294b6a74df
4
- data.tar.gz: 97fac01b4349e11eaa28cdb0fb4dbe83c4c9d4874d29c7002abc3ba2ec2f757b
3
+ metadata.gz: 176b96c36ba23668dfa2b208022214cf61fa3a3d25d206466ebc8f01ceb1e4e2
4
+ data.tar.gz: 3bc135a5913ccc38dd81e4f49a8e3c33e8db9986eb282c5a61014725fca3bb0b
5
5
  SHA512:
6
- metadata.gz: 8ca356b737df0e57a5e442ff71e42a127698bcdd0b5a803272f35de0fcccc667d8b5796383795baa51706ba332f441ce2e4e59e54a971cbdc387d636cc489fd7
7
- data.tar.gz: b3a840d7063a2a6ee531093134a56d3c975abb70fa826096c233f174a75d75692025543699597db2205333470e94cc5a6750bdf6a7be957a83f997376f5c047d
6
+ metadata.gz: 1a907be22130df26ce7dd9a66c4753e06b31570724d4aaf4e90a62b0c147f6d86d010ce3dae31a7db32ab07600d99dbf302f1efb82473ef94dc6affe84cb3b0d
7
+ data.tar.gz: 06d08117b5c8c9c392619ba57c85f658e4fdf1a75902d163ed53e51b77234ef949fa8dd17ebedcc021ee5edfdd334f1193792fc5219ed27cbdb3fdae362f8150
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sleeproom (0.2.0)
5
- async
6
- async-http-faraday
7
- async-websocket
8
- colorize
9
- configatron
10
- terminal-table
4
+ sleeproom (0.3.0)
5
+ async (~> 1.26.0)
6
+ async-http-faraday (~> 0.9.0)
7
+ async-websocket (~> 0.15.0)
8
+ colorize (~> 0.8.0)
9
+ configatron (~> 4.5.0)
10
+ terminal-table (~> 1.8.0)
11
11
 
12
12
  GEM
13
13
  remote: https://rubygems.org/
@@ -1,6 +1,7 @@
1
+ #!/usr/bin/env ruby
1
2
  # frozen_string_literal: true
2
3
 
3
4
  require "sleeproom/cli"
4
5
 
5
6
  cli = SleepRoom::CLI.new(ARGV)
6
- cli.run
7
+ cli.run
@@ -15,7 +15,11 @@ module SleepRoom
15
15
  end
16
16
 
17
17
  def streaming_url
18
- @json["streaming_url_list"].sort_by{|hash| -hash["quality"]}.first["url"]
18
+ if @json["streaming_url_list"].nil?
19
+ raise Error.new("streaming url is null.")
20
+ else
21
+ @json["streaming_url_list"].sort_by{|hash| -hash["quality"]}.first["url"]
22
+ end
19
23
  end
20
24
  end
21
25
  end
@@ -159,7 +159,7 @@ module SleepRoom
159
159
  api = API::StreamingAPI.new(@room_id)
160
160
  streaming_url_list = api.streaming_url
161
161
  rescue => e
162
- SleepRoom.error(e.message)
162
+ SleepRoom.error(e.full_message)
163
163
  log("[parseStreamingUrl] Retry...")
164
164
  retry
165
165
  end
@@ -187,7 +187,8 @@ module SleepRoom
187
187
  })
188
188
  task.async do |t|
189
189
  while true
190
- if !SleepRoom.running?(pid) && !API::RoomAPI.new(@room).live?
190
+ live = API::RoomAPI.new(@room).live?
191
+ if !SleepRoom.running?(pid) && !live
191
192
  log("Download complete.")
192
193
  @downlaoding = false
193
194
  @queue.add({
@@ -198,9 +199,19 @@ module SleepRoom
198
199
  status: :complete,
199
200
  })
200
201
  break
202
+ elsif live && !SleepRoom.running?(pid)
203
+ log("Minyami crash.")
204
+ streaming_url = parse_streaming_url
205
+ output = build_output
206
+ pid = SleepRoom::Record.call_minyami(url: streaming_url, output: output)
207
+ elsif !live && SleepRoom.running?(pid)
208
+ log("Live stop.")
201
209
  end
202
- t.sleep 60
210
+ t.sleep 120
203
211
  end
212
+ rescue Faraday::ConnectionFailed
213
+ log("Network error.")
214
+ retry
204
215
  end.wait
205
216
  end
206
217
 
@@ -4,6 +4,7 @@ require "configatron"
4
4
  require "colorize"
5
5
  require "fileutils"
6
6
  require "yaml"
7
+ require "logger"
7
8
 
8
9
  module SleepRoom
9
10
  class Error < StandardError; end
@@ -111,10 +112,6 @@ module SleepRoom
111
112
  file: {
112
113
  use: true,
113
114
  path: "#{sleeproom_dir}/log"
114
- },
115
- websocket: {
116
- log: true,
117
- ping_log: false
118
115
  }
119
116
  }
120
117
  }
@@ -197,18 +194,43 @@ module SleepRoom
197
194
  # @param string [String]
198
195
  # @return [nil]
199
196
  def self.info(string)
200
- STDOUT.puts("[INFO] #{string}".colorize(:white))
197
+ log(:info, "[INFO] #{string}".colorize(:white))
201
198
  end
202
199
 
203
200
  # @param string [String]
204
201
  # @return [nil]
205
202
  def self.warning(string)
206
- warn("[WARN] #{string}".colorize(:yellow))
203
+ log(:warning, "[WARN] #{string}".colorize(:yellow))
207
204
  end
208
205
 
209
206
  # @param string [String]
210
207
  # @return [nil]
211
208
  def self.error(string)
212
- STDOUT.puts("[ERROR] #{string}".colorize(:red))
209
+ log(:error, "[ERROR] #{string}".colorize(:red))
210
+ end
211
+
212
+ def self.log(type, log)
213
+ case type
214
+ when :info
215
+ puts(log)
216
+ when :warning
217
+ warn(log)
218
+ when :error
219
+ puts(log)
220
+ end
221
+ file_logger(type, log) if configatron.logger.file.use == true
222
+ end
223
+
224
+ def self.file_logger(type, log)
225
+ path = configatron.logger.file.path
226
+ logger = Logger.new(path)
227
+ case type
228
+ when :info
229
+ logger.info(log)
230
+ when :warning
231
+ logger.warning(log)
232
+ when :error
233
+ logger.error(log)
234
+ end
213
235
  end
214
236
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SleepRoom
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
@@ -25,12 +25,12 @@ Gem::Specification.new do |spec|
25
25
  spec.executables = ["sleeproom"]
26
26
  spec.require_paths = ["lib"]
27
27
 
28
- spec.add_runtime_dependency("colorize")
29
- spec.add_runtime_dependency("async")
30
- spec.add_runtime_dependency("async-websocket")
31
- spec.add_runtime_dependency("configatron")
32
- spec.add_runtime_dependency("async-http-faraday")
33
- spec.add_runtime_dependency("terminal-table")
28
+ spec.add_runtime_dependency("colorize", "~> 0.8.0")
29
+ spec.add_runtime_dependency("async", "~> 1.26.0")
30
+ spec.add_runtime_dependency("async-websocket", "~> 0.15.0")
31
+ spec.add_runtime_dependency("configatron", "~> 4.5.0")
32
+ spec.add_runtime_dependency("async-http-faraday", "~> 0.9.0")
33
+ spec.add_runtime_dependency("terminal-table", "~> 1.8.0")
34
34
 
35
35
  spec.post_install_message = <<~STR
36
36
  SleepRoom 需要:
metadata CHANGED
@@ -1,99 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sleeproom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-12 00:00:00.000000000 Z
11
+ date: 2020-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 0.8.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 0.8.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: async
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 1.26.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 1.26.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: async-websocket
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 0.15.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 0.15.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: configatron
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 4.5.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: 4.5.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: async-http-faraday
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: 0.9.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: 0.9.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: terminal-table
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: 1.8.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: 1.8.0
97
97
  description:
98
98
  email:
99
99
  - i@wug.moe