ehbrs-tools 0.34.0 → 0.35.1

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: 8ec0a90959fd8dc48f9c799b20af55016cd219efae701640eb2060ff55ceeab9
4
- data.tar.gz: 754779dd2ae2cce3b6495793c975027b6f0240997b42688fbd9d8935caba7920
3
+ metadata.gz: c5318bb59f255a65bf78684c4638ce923fa4f67ceafa4acf33037b86c705fd67
4
+ data.tar.gz: e0a413e38849986ef0ecd63fffb9cfc3ba38d887f6f80c179379978d6bf0b6a6
5
5
  SHA512:
6
- metadata.gz: f2d1cf8696c59243b3b3756830ec520d762b9fce5f5ae96a94a32c95d001d7420d1fdfd2d14c771208bb3163d3761b5b312383b61a29f48c652a8d63529a9cd3
7
- data.tar.gz: c9225832e1bf272b8c1a8be6bafedce2eaea075c6564d04b0912ce78fc6d63d43571c786bb65202b8651b89f3bf263dff6a42962589f9a0b52d9d40e9f01dbe1
6
+ metadata.gz: 807ce4c38107b8b74ab4f25af8a9b1e82a882ccb1c12dd325c356073fa09d95f57abc0220f77854001172b687e9bcb6f75083d353e886497f8b5f748c4ae0b3e
7
+ data.tar.gz: 9a940673ba6ee30b09748da01c8537f07cb7a59978837b3f91f2e06919b2040f834c18109d07c34fd81c0ef736d0e58dece03717ff47fede8346d6dabdcc2051
data/Gemfile.lock CHANGED
@@ -1,76 +1,25 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ehbrs-tools (0.34.0)
4
+ ehbrs-tools (0.35.1)
5
5
  avm-tools (~> 0.145, >= 0.145.1)
6
6
  eac_cli (~> 0.30, >= 0.30.1)
7
7
  eac_ruby_utils (~> 0.112)
8
- ehbrs_ruby_utils (~> 0.20)
8
+ ehbrs_ruby_utils (~> 0.22)
9
9
  filesize (~> 0.2)
10
10
  inifile (~> 3.0)
11
11
  os (~> 1.1, >= 1.1.4)
12
12
  telegram-bot-ruby (~> 0.23)
13
13
 
14
- PATH
15
- remote: sub/aranha-parsers
16
- specs:
17
- aranha-parsers (0.15.0)
18
- activesupport (>= 4.0.0)
19
- addressable (~> 2.8, >= 2.8.1)
20
- eac_ruby_utils (~> 0.112)
21
- faraday (~> 2.7, >= 2.7.4)
22
- faraday-gzip (~> 0.1)
23
- nokogiri (~> 1.14)
24
- ofx-parser (~> 1.1)
25
-
26
- PATH
27
- remote: sub/aranha-selenium
28
- specs:
29
- aranha-selenium (0.5.0)
30
- eac_ruby_utils (~> 0.106, >= 0.106.1)
31
- selenium-webdriver (~> 3.142, >= 3.142.7)
32
-
33
- PATH
34
- remote: sub/aranha
35
- specs:
36
- aranha (0.19.0)
37
- aranha-parsers (~> 0.15)
38
- aranha-selenium (~> 0.5)
39
- eac_ruby_utils (~> 0.112)
40
-
41
- PATH
42
- remote: sub/eac_cli
43
- specs:
44
- eac_cli (0.30.1)
45
- colorize (~> 0.8, >= 0.8.1)
46
- eac_config (~> 0.12)
47
- eac_ruby_utils (~> 0.112)
48
-
49
- PATH
50
- remote: sub/eac_docker
51
- specs:
52
- eac_docker (0.6.0)
53
- eac_ruby_utils (~> 0.112)
54
- eac_templates (~> 0.3, >= 0.3.2)
55
-
56
14
  PATH
57
15
  remote: sub/eac_rest
58
16
  specs:
59
- eac_rest (0.7.0)
17
+ eac_rest (0.7.1)
60
18
  eac_fs (~> 0.16)
61
19
  eac_ruby_utils (~> 0.112)
62
20
  faraday (~> 2.7, >= 2.7.4)
63
21
  faraday-multipart (~> 1.0, >= 1.0.4)
64
22
 
65
- PATH
66
- remote: sub/eac_ruby_base0
67
- specs:
68
- eac_ruby_base0 (0.17.3)
69
- avm-eac_ruby_base1 (~> 0.29)
70
- eac_cli (~> 0.30, >= 0.30.1)
71
- eac_fs (~> 0.16)
72
- eac_ruby_utils (~> 0.112)
73
-
74
23
  PATH
75
24
  remote: sub/eac_ruby_utils
76
25
  specs:
@@ -81,21 +30,15 @@ PATH
81
30
  filesize (~> 0.2)
82
31
  net-ssh (~> 4.2)
83
32
 
84
- PATH
85
- remote: sub/eac_templates
86
- specs:
87
- eac_templates (0.3.2)
88
- eac_config (~> 0.11, >= 0.11.1)
89
- eac_ruby_utils (~> 0.102, >= 0.102.1)
90
-
91
33
  PATH
92
34
  remote: sub/ehbrs_ruby_utils
93
35
  specs:
94
- ehbrs_ruby_utils (0.20.0)
36
+ ehbrs_ruby_utils (0.22.0)
95
37
  aranha (~> 0.19)
96
38
  aranha-parsers (~> 0.15)
97
39
  avm (~> 0.62)
98
40
  eac_fs (~> 0.16)
41
+ eac_rest (~> 0.7, >= 0.7.1)
99
42
  eac_ruby_utils (~> 0.112)
100
43
  eac_templates (~> 0.3, >= 0.3.2)
101
44
  taglib-ruby (~> 1.1, >= 1.1.3)
@@ -112,6 +55,21 @@ GEM
112
55
  zeitwerk (~> 2.3)
113
56
  addressable (2.8.1)
114
57
  public_suffix (>= 2.0.2, < 6.0)
58
+ aranha (0.19.0)
59
+ aranha-parsers (~> 0.15)
60
+ aranha-selenium (~> 0.5)
61
+ eac_ruby_utils (~> 0.112)
62
+ aranha-parsers (0.15.0)
63
+ activesupport (>= 4.0.0)
64
+ addressable (~> 2.8, >= 2.8.1)
65
+ eac_ruby_utils (~> 0.112)
66
+ faraday (~> 2.7, >= 2.7.4)
67
+ faraday-gzip (~> 0.1)
68
+ nokogiri (~> 1.14)
69
+ ofx-parser (~> 1.1)
70
+ aranha-selenium (0.5.0)
71
+ eac_ruby_utils (~> 0.106, >= 0.106.1)
72
+ selenium-webdriver (~> 3.142, >= 3.142.7)
115
73
  ast (2.4.2)
116
74
  avm (0.62.0)
117
75
  aranha-parsers (~> 0.14, >= 0.14.4)
@@ -179,9 +137,16 @@ GEM
179
137
  thread_safe (~> 0.3, >= 0.3.1)
180
138
  diff-lcs (1.5.0)
181
139
  dry-inflector (1.0.0)
140
+ eac_cli (0.30.1)
141
+ colorize (~> 0.8, >= 0.8.1)
142
+ eac_config (~> 0.12)
143
+ eac_ruby_utils (~> 0.112)
182
144
  eac_config (0.12.0)
183
145
  addressable (~> 2.8, >= 2.8.1)
184
146
  eac_ruby_utils (~> 0.107)
147
+ eac_docker (0.6.0)
148
+ eac_ruby_utils (~> 0.112)
149
+ eac_templates (~> 0.3, >= 0.3.2)
185
150
  eac_fs (0.16.0)
186
151
  content-type (~> 0.0, >= 0.0.2)
187
152
  eac_ruby_utils (~> 0.107, >= 0.107.1)
@@ -189,12 +154,20 @@ GEM
189
154
  eac_git (0.14.0)
190
155
  eac_ruby_utils (~> 0.107)
191
156
  parseconfig (~> 1.1, >= 1.1.2)
157
+ eac_ruby_base0 (0.17.3)
158
+ avm-eac_ruby_base1 (~> 0.29)
159
+ eac_cli (~> 0.30, >= 0.30.1)
160
+ eac_fs (~> 0.16)
161
+ eac_ruby_utils (~> 0.112)
192
162
  eac_ruby_gem_support (0.5.1)
193
163
  eac_ruby_utils (~> 0.74)
194
164
  rspec (~> 3.9)
195
165
  rubocop (~> 0.80.1)
196
166
  rubocop-rails (~> 2.4.2)
197
167
  rubocop-rspec (~> 1.38.1)
168
+ eac_templates (0.3.2)
169
+ eac_config (~> 0.11, >= 0.11.1)
170
+ eac_ruby_utils (~> 0.102, >= 0.102.1)
198
171
  faraday (2.7.4)
199
172
  faraday-net_http (>= 2.0, < 3.1)
200
173
  ruby2_keywords (>= 0.0.4)
@@ -205,12 +178,11 @@ GEM
205
178
  multipart-post (~> 2)
206
179
  faraday-net_http (3.0.2)
207
180
  filesize (0.2.0)
208
- git (1.13.1)
181
+ git (1.13.2)
209
182
  addressable (~> 2.8)
210
183
  rchardet (~> 1.8)
211
184
  hpricot (0.8.6)
212
185
  htmlbeautifier (1.4.2)
213
- httpclient (2.8.3)
214
186
  i18n (1.12.0)
215
187
  concurrent-ruby (~> 1.0)
216
188
  ice_nine (0.11.2)
@@ -220,7 +192,7 @@ GEM
220
192
  minitest (5.17.0)
221
193
  multipart-post (2.3.0)
222
194
  net-ssh (4.2.0)
223
- nokogiri (1.14.0-x86_64-linux)
195
+ nokogiri (1.14.1-x86_64-linux)
224
196
  racc (~> 1.4)
225
197
  ofx-parser (1.1.0)
226
198
  hpricot (>= 0.6)
@@ -240,7 +212,7 @@ GEM
240
212
  rspec-core (~> 3.12.0)
241
213
  rspec-expectations (~> 3.12.0)
242
214
  rspec-mocks (~> 3.12.0)
243
- rspec-core (3.12.0)
215
+ rspec-core (3.12.1)
244
216
  rspec-support (~> 3.12.0)
245
217
  rspec-expectations (3.12.2)
246
218
  diff-lcs (>= 1.2.0, < 2.0)
@@ -293,16 +265,9 @@ PLATFORMS
293
265
  x86_64-linux
294
266
 
295
267
  DEPENDENCIES
296
- aranha!
297
- aranha-parsers!
298
- aranha-selenium!
299
- eac_cli!
300
- eac_docker!
301
268
  eac_rest!
302
- eac_ruby_base0!
303
269
  eac_ruby_gem_support (~> 0.3)
304
270
  eac_ruby_utils!
305
- eac_templates!
306
271
  ehbrs-tools!
307
272
  ehbrs_ruby_utils!
308
273
 
@@ -0,0 +1,110 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Ehbrs
6
+ module Tools
7
+ class Runner
8
+ class Videos
9
+ class Languages
10
+ class FileRunner
11
+ enable_simple_cache
12
+ enable_speaker
13
+ common_constructor :runner, :file do
14
+ run
15
+ end
16
+
17
+ private
18
+
19
+ def run
20
+ start_banner
21
+ extract_check || delete_check
22
+ end
23
+
24
+ def start_banner
25
+ infov 'File', file
26
+ infov " * Tracks (#{tracks.count})", tracks.map(&:to_label).join(', ')
27
+ infov " * Languages (#{languages.count})", languages.map(&:to_label).join(', ')
28
+ end
29
+
30
+ def tracks_uncached
31
+ audios_if_selected + subtitles_if_selected
32
+ end
33
+
34
+ def audios_if_selected
35
+ return [] unless runner.include_audios?
36
+
37
+ container.audios.map do |s|
38
+ ::Ehbrs::Tools::Runner::Videos::Languages::Track.new(runner, s, file)
39
+ end
40
+ end
41
+
42
+ def subtitles_if_selected
43
+ return [] unless runner.include_subtitles?
44
+
45
+ container.subtitles.map do |s|
46
+ ::Ehbrs::Tools::Runner::Videos::Languages::Track.new(runner, s, file)
47
+ end
48
+ end
49
+
50
+ def included_tracks_uncached
51
+ tracks.select(&:included?)
52
+ end
53
+
54
+ def container_uncached
55
+ ::EhbrsRubyUtils::Videos::Container.new(file)
56
+ end
57
+
58
+ def track_label(track)
59
+ track.to_s.green
60
+ end
61
+
62
+ def languages_uncached
63
+ ::Set.new(
64
+ tracks.map do |s|
65
+ ::Ehbrs::Tools::Runner::Videos::Languages::Language.new(runner, s.language)
66
+ end
67
+ ).to_a.sort
68
+ end
69
+
70
+ def delete_check
71
+ return unless runner.delete?
72
+
73
+ infov 'Delete args', ::Shellwords.join(delete_tracks_job_args)
74
+ delete_tracks_job.run
75
+ end
76
+
77
+ def delete_tracks_job_uncached
78
+ ::EhbrsRubyUtils::Videos::ConvertJob.new(file, delete_tracks_job_args)
79
+ end
80
+
81
+ def delete_tracks_job_args
82
+ %w[-map 0] + tracks.flat_map(&:delete_ffmpeg_args) + %w[-c copy]
83
+ end
84
+
85
+ def extract_check
86
+ return false unless runner.extract?
87
+
88
+ unless included_tracks.any?
89
+ infom 'No selected tracks'
90
+ return true
91
+ end
92
+
93
+ infov 'Extract args', ::Shellwords.join(extract_tracks_job_args)
94
+ extract_tracks_command.system!
95
+ true
96
+ end
97
+
98
+ def extract_tracks_job_args
99
+ ['-txt_format', 'text', '-i', file] + tracks.flat_map(&:extract_ffmpeg_args)
100
+ end
101
+
102
+ def extract_tracks_command_uncached
103
+ ::Ehbrs::Executables.ffmpeg.command(*extract_tracks_job_args)
104
+ end
105
+ end
106
+ end
107
+ end
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Ehbrs
6
+ module Tools
7
+ class Runner
8
+ class Videos
9
+ class Languages
10
+ class Labelized < ::SimpleDelegator
11
+ attr_reader :runner
12
+
13
+ def initialize(runner, object)
14
+ @runner = runner
15
+ super(object)
16
+ end
17
+
18
+ def to_label
19
+ return to_s unless runner.keep_languages?
20
+
21
+ to_s.colorize(runner.keep_languages.include?(language) ? :green : :red)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'ehbrs/tools/runner/videos/languages/labelized'
5
+
6
+ module Ehbrs
7
+ module Tools
8
+ class Runner
9
+ class Videos
10
+ class Languages
11
+ class Language < ::Ehbrs::Tools::Runner::Videos::Languages::Labelized
12
+ def to_s
13
+ __getobj__
14
+ end
15
+
16
+ def language
17
+ __getobj__
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'ehbrs/tools/runner/videos/languages/labelized'
5
+
6
+ module Ehbrs
7
+ module Tools
8
+ class Runner
9
+ class Videos
10
+ class Languages
11
+ class Track < ::Ehbrs::Tools::Runner::Videos::Languages::Labelized
12
+ BLANK_LANGUAGE = 'BLANK'
13
+
14
+ attr_reader :file
15
+
16
+ def initialize(runner, object, file)
17
+ super(runner, object)
18
+ @file = file
19
+ end
20
+
21
+ def delete_ffmpeg_args
22
+ return [] if included?
23
+
24
+ ['-map', "-0:#{index}"]
25
+ end
26
+
27
+ def extract_ffmpeg_args
28
+ return [] unless included?
29
+
30
+ ['-map', "0:#{index}", extract_target]
31
+ end
32
+
33
+ def included?
34
+ runner.keep_languages.include?(language)
35
+ end
36
+
37
+ def language
38
+ language_with_title.presence || BLANK_LANGUAGE
39
+ end
40
+
41
+ def extract_target
42
+ file.basename_sub('.*') { |b| "#{b}.#{language}_#{index}.srt" }
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_base0/core_ext'
4
+ require 'ehbrs/executables'
5
+ require 'ehbrs_ruby_utils/videos/container'
6
+ require 'ehbrs_ruby_utils/videos/convert_job'
7
+
8
+ module Ehbrs
9
+ module Tools
10
+ class Runner
11
+ class Videos
12
+ class Languages
13
+ runner_with :help, :filesystem_traverser do
14
+ desc 'Lê e modifica trilhas com idiomas de um vídeo.'
15
+ bool_opt '-a', '--audios', 'Seleciona áudios.'
16
+ bool_opt '-d', '--delete', 'Remove trilhas selecionadas.'
17
+ bool_opt '-e', '--extract', 'Extrai trilhas selecionadas'
18
+ arg_opt '-k', '--keep', 'Mantém legendas com o idioma especificado.', repeat: true
19
+ bool_opt '-s', '--subtitles', 'Seleciona legendas.'
20
+ end
21
+
22
+ def keep_languages?
23
+ keep_languages.any?
24
+ end
25
+
26
+ delegate :delete?, :extract?, to: :parsed
27
+
28
+ def run
29
+ infov 'Keep', keep_languages
30
+ all_languages_banner
31
+ end
32
+
33
+ def keep_languages
34
+ parsed.keep.map(&:strip).reject(&:blank?)
35
+ end
36
+
37
+ def include_audios?
38
+ parsed.audios?
39
+ end
40
+
41
+ def include_subtitles?
42
+ parsed.subtitles?
43
+ end
44
+
45
+ def traverser_check_file(file)
46
+ @files << ::Ehbrs::Tools::Runner::Videos::Languages::FileRunner.new(self, file)
47
+ end
48
+
49
+ private
50
+
51
+ def all_languages_uncached
52
+ ::Set.new(files.flat_map(&:languages)).to_a.sort
53
+ end
54
+
55
+ def all_languages_banner
56
+ infov 'Languages', all_languages.count
57
+ all_languages.each do |language|
58
+ infov ' * ', language.to_label
59
+ end
60
+ end
61
+
62
+ def files_uncached
63
+ @files = []
64
+ run_filesystem_traverser
65
+ @files
66
+ end
67
+
68
+ require_sub __FILE__
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -61,10 +61,6 @@ module Ehbrs
61
61
  end
62
62
 
63
63
  def data_uncached
64
- ::JSON.parse(raw_content)
65
- end
66
-
67
- def raw_content
68
64
  runner_context.call(:instance).http_request('/videos/files/export').body
69
65
  end
70
66
  end
@@ -24,7 +24,7 @@ module Ehbrs
24
24
  infom "Uploading \"#{type}\" files list..."
25
25
  files_list_path = send("#{type}_files_list")
26
26
  infov 'Path', files_list_path
27
- process_response(upload_request(files_list_path))
27
+ process_response(files_list_path)
28
28
  end
29
29
 
30
30
  def upload_request(files_list_path)
@@ -40,16 +40,11 @@ module Ehbrs
40
40
  )
41
41
  end
42
42
 
43
- def process_response(response)
44
- infov 'Response status', response.status
45
- if response.status == 200
46
- pp ::JSON.parse(response.body)
47
- else
48
- error_file = '/tmp/ehbrsutils.html'
49
- ::File.write(error_file, response.body)
50
- system('firefox', error_file)
51
- fatal_error('Retornou com status de erro: ' + error_file)
52
- end
43
+ def process_response(files_list_path)
44
+ upload_request(files_list_path).body
45
+ rescue ::EhbrsRubyUtils::WebUtils::RequestError => e
46
+ system('firefox', e.body_file_path.to_path)
47
+ fatal_error('Retornou com erro: ' + e.message)
53
48
  end
54
49
 
55
50
  def series_files_list_uncached
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ehbrs
4
4
  module Tools
5
- VERSION = '0.34.0'
5
+ VERSION = '0.35.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ehbrs-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.34.0
4
+ version: 0.35.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-01-30 00:00:00.000000000 Z
11
+ date: 2023-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avm-tools
@@ -70,14 +70,14 @@ dependencies:
70
70
  requirements:
71
71
  - - "~>"
72
72
  - !ruby/object:Gem::Version
73
- version: '0.20'
73
+ version: '0.22'
74
74
  type: :runtime
75
75
  prerelease: false
76
76
  version_requirements: !ruby/object:Gem::Requirement
77
77
  requirements:
78
78
  - - "~>"
79
79
  - !ruby/object:Gem::Version
80
- version: '0.20'
80
+ version: '0.22'
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: filesize
83
83
  requirement: !ruby/object:Gem::Requirement
@@ -220,6 +220,11 @@ files:
220
220
  - lib/ehbrs/tools/runner/vg/wii.rb
221
221
  - lib/ehbrs/tools/runner/videos.rb
222
222
  - lib/ehbrs/tools/runner/videos/extract.rb
223
+ - lib/ehbrs/tools/runner/videos/languages.rb
224
+ - lib/ehbrs/tools/runner/videos/languages/file_runner.rb
225
+ - lib/ehbrs/tools/runner/videos/languages/labelized.rb
226
+ - lib/ehbrs/tools/runner/videos/languages/language.rb
227
+ - lib/ehbrs/tools/runner/videos/languages/track.rb
223
228
  - lib/ehbrs/tools/runner/videos/opensubtitles.rb
224
229
  - lib/ehbrs/tools/runner/videos/probe.rb
225
230
  - lib/ehbrs/tools/runner/videos/series.rb