ehbrs-tools 0.12.0 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ehbrs/executables.rb +1 -1
  3. data/lib/ehbrs/runner.rb +9 -13
  4. data/lib/ehbrs/runner/finances.rb +19 -0
  5. data/lib/ehbrs/runner/finances/bb_browser.rb +40 -0
  6. data/lib/ehbrs/runner/fs/used_space.rb +4 -4
  7. data/lib/ehbrs/runner/videos.rb +6 -11
  8. data/lib/ehbrs/runner/videos/probe.rb +35 -0
  9. data/lib/ehbrs/runner/web_utils.rb +26 -0
  10. data/lib/ehbrs/runner/web_utils/videos.rb +20 -0
  11. data/lib/ehbrs/runner/web_utils/videos/download.rb +66 -0
  12. data/lib/ehbrs/runner/web_utils/videos/upload.rb +78 -0
  13. data/lib/ehbrs/tools/version.rb +1 -1
  14. data/lib/ehbrs/videos/file.rb +2 -1
  15. data/lib/ehbrs/videos/unsupported/fix_profile.rb +1 -0
  16. data/vendor/eac_cli/eac_cli.gemspec +3 -3
  17. data/vendor/eac_cli/lib/eac_cli/core_ext.rb +4 -0
  18. data/vendor/eac_cli/lib/eac_cli/default_runner.rb +6 -14
  19. data/vendor/eac_cli/lib/eac_cli/definition.rb +72 -0
  20. data/vendor/eac_cli/lib/eac_cli/definition/argument_option.rb +13 -0
  21. data/vendor/eac_cli/lib/eac_cli/{runner → definition}/base_option.rb +5 -1
  22. data/vendor/eac_cli/lib/eac_cli/definition/boolean_option.rb +13 -0
  23. data/vendor/eac_cli/lib/eac_cli/{runner → definition}/positional_argument.rb +5 -1
  24. data/vendor/eac_cli/lib/eac_cli/{runner/docopt_doc.rb → docopt/doc_builder.rb} +15 -8
  25. data/vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb +45 -0
  26. data/vendor/eac_cli/lib/eac_cli/parser.rb +14 -0
  27. data/vendor/eac_cli/lib/eac_cli/parser/collector.rb +56 -0
  28. data/vendor/eac_cli/lib/eac_cli/parser/error.rb +15 -0
  29. data/vendor/eac_cli/lib/eac_cli/parser/options_collection.rb +105 -0
  30. data/vendor/eac_cli/lib/eac_cli/parser/parse_result.rb +21 -0
  31. data/vendor/eac_cli/lib/eac_cli/parser/positional_collection.rb +49 -0
  32. data/vendor/eac_cli/lib/eac_cli/patches.rb +4 -0
  33. data/vendor/eac_cli/lib/eac_cli/patches/object.rb +5 -0
  34. data/vendor/eac_cli/lib/eac_cli/patches/object/runner_with.rb +24 -0
  35. data/vendor/eac_cli/lib/eac_cli/runner.rb +64 -7
  36. data/vendor/eac_cli/lib/eac_cli/runner/context.rb +18 -0
  37. data/vendor/eac_cli/lib/eac_cli/runner_with.rb +9 -0
  38. data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +19 -0
  39. data/vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb +26 -0
  40. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  41. data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +70 -0
  42. data/vendor/eac_docker/Gemfile +5 -0
  43. data/vendor/eac_docker/eac_docker.gemspec +18 -0
  44. data/vendor/eac_docker/lib/eac_docker.rb +7 -0
  45. data/vendor/eac_docker/lib/eac_docker/container.rb +50 -0
  46. data/vendor/eac_docker/lib/eac_docker/executables.rb +18 -0
  47. data/vendor/eac_docker/lib/eac_docker/images.rb +9 -0
  48. data/vendor/eac_docker/lib/eac_docker/images/base.rb +14 -0
  49. data/vendor/eac_docker/lib/eac_docker/images/named.rb +30 -0
  50. data/vendor/eac_docker/lib/eac_docker/rspec.rb +17 -0
  51. data/vendor/eac_docker/lib/eac_docker/version.rb +5 -0
  52. data/vendor/eac_docker/spec/lib/eac_docker/executables_spec.rb +9 -0
  53. data/vendor/eac_docker/spec/rubocop_spec.rb +7 -0
  54. data/vendor/eac_docker/spec/spec_helper.rb +103 -0
  55. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/boolean.rb +31 -0
  56. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern.rb +4 -4
  57. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner.rb +6 -0
  58. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_class_methods.rb +2 -2
  59. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_subcommands.rb +8 -2
  60. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command.rb +1 -0
  61. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/extra_options.rb +8 -0
  62. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env.rb +12 -9
  63. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/dasho_options.rb +53 -0
  64. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/identity_file.rb +25 -0
  65. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/quiet.rb +24 -0
  66. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/terminal.rb +34 -0
  67. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs_cache.rb +1 -0
  68. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/immutable.rb +15 -0
  69. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/immutable/array_accessor.rb +32 -0
  70. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/immutable/base_accessor.rb +23 -0
  71. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/immutable/boolean_accessor.rb +16 -0
  72. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/immutable/class_methods.rb +20 -0
  73. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/immutable/common_accessor.rb +30 -0
  74. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/immutable/hash_accessor.rb +46 -0
  75. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/immutable/instance_methods.rb +21 -0
  76. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/inflector.rb +18 -0
  77. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/list.rb +5 -0
  78. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb +3 -2
  79. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/immutable.rb +10 -0
  80. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/if_respond.rb +22 -0
  81. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/string.rb +4 -0
  82. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/string/inflector.rb +9 -0
  83. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/require_sub.rb +38 -11
  84. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/simple_cache.rb +6 -2
  85. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/struct.rb +53 -0
  86. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/directory.rb +7 -1
  87. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/file.rb +8 -59
  88. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_not_found_error.rb +7 -0
  89. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_providers.rb +25 -0
  90. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_providers/base.rb +23 -0
  91. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_providers/entries_reader.rb +25 -0
  92. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_providers/generic.rb +25 -0
  93. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_providers/hash.rb +29 -0
  94. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  95. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/inflector_spec.rb +15 -0
  96. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/ruby_spec.rb +22 -0
  97. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/struct_spec.rb +46 -0
  98. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb +1 -0
  99. data/vendor/ehbrs_ruby_utils/Gemfile +16 -0
  100. data/vendor/ehbrs_ruby_utils/ehbrs_ruby_utils.gemspec +20 -0
  101. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils.rb +7 -0
  102. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/executables.rb +28 -0
  103. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/version.rb +5 -0
  104. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos.rb +9 -0
  105. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container.rb +11 -0
  106. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container/file.rb +31 -0
  107. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container/info.rb +21 -0
  108. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/quality.rb +68 -0
  109. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/resolution.rb +68 -0
  110. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/web_utils.rb +9 -0
  111. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/web_utils/instance.rb +32 -0
  112. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/web_utils/videos.rb +11 -0
  113. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/web_utils/videos/file.rb +40 -0
  114. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/web_utils/videos/files_list.rb +76 -0
  115. data/vendor/ehbrs_ruby_utils/spec/lib/ehbrs_ruby_utils/videos/resolution_spec.rb +18 -0
  116. data/vendor/ehbrs_ruby_utils/spec/rubocop_check_spec.rb +7 -0
  117. data/vendor/ehbrs_ruby_utils/spec/spec_helper.rb +100 -0
  118. metadata +92 -10
  119. data/vendor/eac_cli/lib/eac_cli/runner/argument_option.rb +0 -13
  120. data/vendor/eac_cli/lib/eac_cli/runner/boolean_option.rb +0 -13
  121. data/vendor/eac_cli/lib/eac_cli/runner/definition.rb +0 -64
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 01424b2d17105c7694679a4deb6dda7d0ab4b98f6ee0b32ed5d183bfdac33583
4
- data.tar.gz: 271b08e6e6cf9a3868e06d1a13520030e6f1c55d167b86781f1250e92540dee7
3
+ metadata.gz: a87fd9ce05b53ed04fcdfdc72f50a9aee263e95816935bfdb796239c2a0312f6
4
+ data.tar.gz: 3b1374c1fdc8d761ac9a23632f16ba132bcab34f08541f5eab7a28d5138fedad
5
5
  SHA512:
6
- metadata.gz: bd53a0486dfec03c0d827ee8f759c5f28a490c93cb2320ea623f8a01ec5f9bdc106dd955f55114d098236b0418d96f62ab47cc2df8248b01da66bd87b3db52d8
7
- data.tar.gz: 31dc82bd83f87cb8ea9ab4f2e8d2eac8ceba2477bf2d200156b3c01ada3794ddb673bb1d9581fc72ed9da97c3771393b701ae65f1c3c0447b9aeb344afb11d6a
6
+ metadata.gz: 43c2621390f1c3cffff8f0bfe37f5a0569b0e4458558eedb7031a39274429f14e10a882be05d6abfbbc65c1eec776f3bf47be806b25ca649b650bc933a216f1a
7
+ data.tar.gz: 0df896b884307cbddddb8949e88c3f4125c8b4e4c2ddd88c42561e00bf632bb29a5308a94bdf5cff5a57abbce93339c8df36839940ee616d2e98c6b3de3f5862
@@ -17,7 +17,7 @@ module Ehbrs
17
17
  {
18
18
  '-?' => %w[rar],
19
19
  '-h' => %w[unzip],
20
- '-version' => %w[ffmpeg ffprobe],
20
+ '-version' => %w[ffmpeg],
21
21
  '--version' => %w[flips tar wit]
22
22
  }.each do |validate_arg, commands|
23
23
  commands.each do |command|
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'eac_cli/default_runner'
3
4
  require 'eac_ruby_utils/core_ext'
4
5
  require 'eac_ruby_utils/console/docopt_runner'
5
6
  require 'ehbrs/tools/version'
@@ -7,20 +8,15 @@ require 'ehbrs/tools/version'
7
8
  module Ehbrs
8
9
  class Runner < ::EacRubyUtils::Console::DocoptRunner
9
10
  require_sub __FILE__
10
- enable_console_speaker
11
+ include ::EacCli::DefaultRunner
11
12
 
12
- DOC = <<~DOCOPT
13
- Tools for EHB/RS.
14
-
15
- Usage:
16
- __PROGRAM__ [options] __SUBCOMMANDS__
17
- __PROGRAM__ --version
18
- __PROGRAM__ -h | --help
19
-
20
- Options:
21
- -h --help Show this screen.
22
- -V --version Show version.
23
- DOCOPT
13
+ runner_definition do
14
+ desc 'Tools for EHB/RS.'
15
+ subcommands
16
+ alt do
17
+ bool_opt '-V', '--version', 'Show version.'
18
+ end
19
+ end
24
20
 
25
21
  def run
26
22
  if options.fetch('--version')
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/default_runner'
4
+ require 'eac_ruby_utils/core_ext'
5
+ require 'eac_ruby_utils/console/docopt_runner'
6
+
7
+ module Ehbrs
8
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
9
+ class Finances < ::EacRubyUtils::Console::DocoptRunner
10
+ include ::EacCli::DefaultRunner
11
+ require_sub __FILE__
12
+
13
+ runner_definition do
14
+ desc 'Utilidades financeiras.'
15
+ subcommands
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/default_runner'
4
+ require 'eac_ruby_utils/core_ext'
5
+ require 'eac_ruby_utils/console/docopt_runner'
6
+ require 'ehbrs/videos/extract/package'
7
+ require 'eac_docker/images/named'
8
+
9
+ module Ehbrs
10
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
11
+ class Finances < ::EacRubyUtils::Console::DocoptRunner
12
+ class BbBrowser < ::EacRubyUtils::Console::DocoptRunner
13
+ include ::EacCli::DefaultRunner
14
+ require_sub __FILE__
15
+
16
+ runner_definition do
17
+ desc 'Bankline para Banco do Brasil com módulo de segurança.'
18
+ end
19
+
20
+ def run
21
+ infov 'Docker run arguments', docker_container.run_command_args
22
+ infov 'System result', docker_container.run_command.system
23
+ end
24
+
25
+ private
26
+
27
+ def docker_image_uncached
28
+ ::EacDocker::Images::Named.new('lichti/warsaw-browser')
29
+ end
30
+
31
+ def docker_container_uncached
32
+ docker_image.container.env('DISPLAY', "unix#{ENV.fetch('DISPLAY')}")
33
+ .volume(::File.join(ENV['HOME'], 'Downloads'), '/home/bank/Downloads')
34
+ .volume('/tmp/.X11-unix', '/tmp/.X11-unix').command_arg('bb')
35
+ .temporary(true).interactive(true).tty(true)
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -6,7 +6,7 @@ require 'filesize'
6
6
  module Ehbrs
7
7
  class Runner < ::EacRubyUtils::Console::DocoptRunner
8
8
  class Fs < ::EacRubyUtils::Console::DocoptRunner
9
- class UsedSpace < ::EacRubyUtils::Console::DocoptRunner
9
+ class UsedSpace
10
10
  include ::EacCli::DefaultRunner
11
11
 
12
12
  runner_definition do
@@ -22,7 +22,7 @@ module Ehbrs
22
22
  end
23
23
 
24
24
  def check?
25
- options.fetch('--check')
25
+ parsed.check
26
26
  end
27
27
 
28
28
  private
@@ -40,11 +40,11 @@ module Ehbrs
40
40
  end
41
41
 
42
42
  def paths_uncached
43
- options.fetch('<paths>').map { |path| path_class.new(self, path) }
43
+ parsed.paths.map { |path| path_class.new(self, path) }
44
44
  end
45
45
 
46
46
  def verbose?
47
- options.fetch('--verbose')
47
+ parsed.verbose
48
48
  end
49
49
 
50
50
  class PathBase
@@ -1,23 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/core_ext'
3
+ require 'eac_cli/core_ext'
4
4
  require 'eac_ruby_utils/console/docopt_runner'
5
5
 
6
6
  module Ehbrs
7
7
  class Runner < ::EacRubyUtils::Console::DocoptRunner
8
8
  class Videos < ::EacRubyUtils::Console::DocoptRunner
9
+ runner_with :output_file
9
10
  require_sub __FILE__
10
11
 
11
- DOC = <<~DOCOPT
12
- Video tools for EHB/RS.
13
-
14
- Usage:
15
- __PROGRAM__ [options] __SUBCOMMANDS__
16
- __PROGRAM__ -h | --help
17
-
18
- Options:
19
- -h --help Show this screen.
20
- DOCOPT
12
+ runner_definition do
13
+ desc 'Video tools for EHB/RS.'
14
+ subcommands
15
+ end
21
16
  end
22
17
  end
23
18
  end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/core_ext'
4
+ require 'eac_ruby_utils/console/docopt_runner'
5
+ require 'ehbrs_ruby_utils/videos/container/file'
6
+ require 'eac_ruby_utils/yaml'
7
+
8
+ module Ehbrs
9
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
10
+ class Videos < ::EacRubyUtils::Console::DocoptRunner
11
+ class Probe
12
+ runner_with :output_file
13
+
14
+ runner_definition do
15
+ desc 'FFProbe em um arquivo de vídeo.'
16
+ pos_arg :file_path
17
+ end
18
+
19
+ def run
20
+ run_output
21
+ end
22
+
23
+ def output_content
24
+ ::EacRubyUtils::Yaml.dump(container_file.info.to_h)
25
+ end
26
+
27
+ private
28
+
29
+ def container_file_uncached
30
+ ::EhbrsRubyUtils::Videos::Container::File.new(parsed.file_path)
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/core_ext'
4
+ require 'eac_ruby_utils/console/docopt_runner'
5
+ require 'ehbrs_ruby_utils/web_utils/instance'
6
+
7
+ module Ehbrs
8
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
9
+ class WebUtils < ::EacRubyUtils::Console::DocoptRunner
10
+ runner_with
11
+ require_sub __FILE__
12
+
13
+ runner_definition do
14
+ desc 'Ferramentas para EHB/RS Utils.'
15
+ pos_arg :'instance-id'
16
+ subcommands
17
+ end
18
+
19
+ private
20
+
21
+ def instance_uncached
22
+ ::EhbrsRubyUtils::WebUtils::Instance.by_id(options.fetch('<instance-id>'))
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/core_ext'
4
+ require 'eac_ruby_utils/console/docopt_runner'
5
+
6
+ module Ehbrs
7
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
8
+ class WebUtils < ::EacRubyUtils::Console::DocoptRunner
9
+ class Videos < ::EacRubyUtils::Console::DocoptRunner
10
+ runner_with
11
+ require_sub __FILE__
12
+
13
+ runner_definition do
14
+ desc 'Ferramentas de vídeos para EHB/RS Utils.'
15
+ subcommands
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/core_ext'
4
+ require 'ehbrs_ruby_utils/web_utils/videos/file'
5
+ require 'eac_ruby_utils/console/docopt_runner'
6
+
7
+ module Ehbrs
8
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
9
+ class WebUtils < ::EacRubyUtils::Console::DocoptRunner
10
+ class Videos < ::EacRubyUtils::Console::DocoptRunner
11
+ class Download < ::EacRubyUtils::Console::DocoptRunner
12
+ runner_with
13
+
14
+ runner_definition do
15
+ desc 'Importa informações de arquivos de vídeo de uma instância EHB/RS Utils.'
16
+ bool_opt '-c', '--confirm', 'Confirma as mudanças'
17
+ end
18
+
19
+ def run
20
+ start_banner
21
+ to_rename.each { |file| process_rename_file(file) }
22
+ to_delete.each { |file| process_delete_file(file) }
23
+ end
24
+
25
+ private
26
+
27
+ def start_banner
28
+ infov 'Files downloaded', files.count
29
+ infov 'To rename', to_rename.count
30
+ infov 'To delete', to_delete.count
31
+ end
32
+
33
+ def process_rename_file(file)
34
+ infov " * #{file.new_path}", file.original_path
35
+ file.rename if options.fetch('--confirm')
36
+ end
37
+
38
+ def process_delete_file(file)
39
+ infov " * #{file.new_path}", 'REMOVE'
40
+ file.remove if options.fetch('--confirm')
41
+ end
42
+
43
+ def files_uncached
44
+ data.map { |file_data| ::EhbrsRubyUtils::WebUtils::Videos::File.new(file_data) }
45
+ end
46
+
47
+ def to_rename_uncached
48
+ files.select(&:path_changed?)
49
+ end
50
+
51
+ def to_delete_uncached
52
+ files.reject { |f| f.type == 'Videos::SeriesDirectory' }.select(&:unwanted)
53
+ end
54
+
55
+ def data_uncached
56
+ ::JSON.parse(raw_content)
57
+ end
58
+
59
+ def raw_content
60
+ context(:instance).http_request('/videos/files/export').body
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/core_ext'
4
+ require 'eac_ruby_utils/console/docopt_runner'
5
+ require 'ehbrs_ruby_utils/web_utils/videos/files_list'
6
+ require 'json'
7
+ require 'yaml'
8
+
9
+ module Ehbrs
10
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
11
+ class WebUtils < ::EacRubyUtils::Console::DocoptRunner
12
+ class Videos < ::EacRubyUtils::Console::DocoptRunner
13
+ class Upload < ::EacRubyUtils::Console::DocoptRunner
14
+ runner_with
15
+
16
+ runner_definition do
17
+ desc 'Exporta informações de arquivos de vídeo para uma instância EHB/RS Utils.'
18
+ bool_opt '-P', '--no-ffprobe', 'Não recupera dados com "ffprobe".'
19
+ end
20
+
21
+ def run
22
+ %w[movies series].each { |type| upload_files_list(type) }
23
+ end
24
+
25
+ def upload_files_list(type)
26
+ infom "Uploading \"#{type}\" files list..."
27
+ files_list_path = send("#{type}_files_list")
28
+ infov 'Path', files_list_path
29
+ process_response(upload_request(files_list_path))
30
+ end
31
+
32
+ def upload_request(files_list_path)
33
+ context(:instance).http_request(
34
+ '/videos/files/import',
35
+ method: :put,
36
+ body: {
37
+ 'videos_tableless_local_import_list[list_file]' => ::File.new(files_list_path)
38
+ },
39
+ header: {
40
+ 'Accept' => 'application/json'
41
+ }
42
+ )
43
+ end
44
+
45
+ def process_response(response)
46
+ infov 'Response status', response.status
47
+ if response.status == 200
48
+ pp ::JSON.parse(response.body) # rubocop:disable Rails/Output
49
+ else
50
+ error_file = '/tmp/ehbrsutils.html'
51
+ ::File.write(error_file, response.body)
52
+ system('firefox', error_file)
53
+ fatal_error('Retornou com status de erro: ' + error_file)
54
+ end
55
+ end
56
+
57
+ def series_files_list_uncached
58
+ write_files_list('Videos::SeriesDirectory', :series_directory)
59
+ end
60
+
61
+ def movies_files_list_uncached
62
+ write_files_list('Videos::MovieFile', :movies_directory)
63
+ end
64
+
65
+ def write_files_list(file_class, read_entry)
66
+ files_list = ::EhbrsRubyUtils::WebUtils::Videos::FilesList.new(
67
+ file_class,
68
+ context(:instance).read_entry(read_entry),
69
+ ffprobe: !options.fetch('--no-ffprobe')
70
+ )
71
+ infov 'Files found', files_list.data.fetch(:files).count
72
+ files_list.write_to
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ehbrs
4
4
  module Tools
5
- VERSION = '0.12.0'
5
+ VERSION = '0.15.0'
6
6
  end
7
7
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'eac_ruby_utils/core_ext'
4
4
  require 'ehbrs/videos/track'
5
+ require 'ehbrs_ruby_utils/executables'
5
6
 
6
7
  module Ehbrs
7
8
  module Videos
@@ -52,7 +53,7 @@ module Ehbrs
52
53
  end
53
54
 
54
55
  def content_uncached
55
- EacRubyUtils::Envs.local.command('ffprobe', path).execute!(output: :stderr).scrub
56
+ ::EhbrsRubyUtils::Executables.ffprobe.command(path).execute!(output: :stderr).scrub
56
57
  end
57
58
 
58
59
  def duration_uncached
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'ehbrs/videos/profiles/same_quality'
4
+ require 'ehbrs/videos/unsupported/fixes/supported_container'
4
5
 
5
6
  module Ehbrs
6
7
  module Videos