ehbrs-tools 0.16.1 → 0.16.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ehbrs/runner/videos/probe.rb +3 -3
  3. data/lib/ehbrs/tools/version.rb +1 -1
  4. data/lib/ehbrs/videos/file.rb +4 -8
  5. data/lib/ehbrs/videos/track.rb +20 -10
  6. data/lib/ehbrs/videos/unsupported/checks/codec_extra_unlisted.rb +2 -0
  7. data/lib/ehbrs/videos/unsupported/checks/codec_extra_unsupported.rb +2 -0
  8. data/lib/ehbrs/videos/unsupported/checks/codec_unlisted.rb +2 -0
  9. data/lib/ehbrs/videos/unsupported/checks/codec_unsupported.rb +2 -0
  10. data/lib/ehbrs/videos/unsupported/checks/invalid_extension.rb +2 -0
  11. data/lib/ehbrs/videos/unsupported/fixes/supported_codec.rb +1 -1
  12. data/lib/ehbrs/videos/unsupported/profiles/base.rb +17 -3
  13. data/lib/ehbrs/videos/unsupported/profiles/philco.rb +5 -4
  14. data/vendor/aranha-parsers/lib/aranha/parsers/spec/source_target_fixtures_example.rb +10 -2
  15. data/vendor/aranha-parsers/lib/aranha/parsers/version.rb +1 -1
  16. data/vendor/eac_cli/lib/eac_cli/definition.rb +34 -39
  17. data/vendor/eac_cli/lib/eac_cli/definition/alternative.rb +83 -0
  18. data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder.rb +18 -40
  19. data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder/alternative.rb +50 -0
  20. data/vendor/eac_cli/lib/eac_cli/parser.rb +21 -3
  21. data/vendor/eac_cli/lib/eac_cli/parser/alternative.rb +88 -0
  22. data/vendor/eac_cli/lib/eac_cli/parser/alternative/argv.rb +17 -0
  23. data/vendor/eac_cli/lib/eac_cli/parser/alternative/double_dash.rb +24 -0
  24. data/vendor/eac_cli/lib/eac_cli/parser/alternative/options.rb +58 -0
  25. data/vendor/eac_cli/lib/eac_cli/parser/alternative/positionals.rb +30 -0
  26. data/vendor/eac_cli/lib/eac_cli/runner.rb +2 -2
  27. data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +1 -1
  28. data/vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb +5 -1
  29. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  30. data/vendor/eac_cli/spec/lib/eac_cli/definition/alternative_spec.rb +14 -0
  31. data/vendor/eac_cli/spec/lib/eac_cli/docopt/runner_extension_spec.rb +10 -0
  32. data/vendor/eac_cli/spec/lib/eac_cli/parser/alternative_spec.rb +140 -0
  33. data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +14 -5
  34. data/vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb +53 -0
  35. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/abstract_methods.rb +60 -0
  36. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/abstract_methods.rb +10 -0
  37. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  38. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/yaml.rb +3 -2
  39. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/abstract_methods_spec.rb +28 -0
  40. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/version.rb +1 -1
  41. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container.rb +30 -2
  42. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/convert_job.rb +91 -0
  43. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/stream.rb +51 -0
  44. metadata +17 -7
  45. data/vendor/eac_cli/lib/eac_cli/parser/options_collection.rb +0 -68
  46. data/vendor/eac_cli/lib/eac_cli/parser/parse_result.rb +0 -38
  47. data/vendor/eac_cli/lib/eac_cli/parser/positional_collection.rb +0 -77
  48. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container/file.rb +0 -31
  49. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container/info.rb +0 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 802c81117166172af4ea59889f51ca8fa22e9619c3db5c3c6cea3facefd67816
4
- data.tar.gz: 524a0c12d36e164f7530653ace84b229d3c90b382bd148fc2dabdf51611881e4
3
+ metadata.gz: 8563bd63534580d6d7a099be6db131d899c4cd430ca5693f18578116d5c36b79
4
+ data.tar.gz: f7ec380ad444fc03ba43c906c09154294f0d685dda9a713fe77da78de3b4ded9
5
5
  SHA512:
6
- metadata.gz: 8704fd788c833ebd36f2c3bab048855993cba2fbe29555040027965195d698eba76d2e36d77ded10672bf50027b441af11d9732ce8bf8dde6fb821623155ea1e
7
- data.tar.gz: 45fa1972f370a98e24424a55ff81b964525799512e6d288fbde84996c5d36540cf368491de00423036f327cc5470889fae2ea0fcf52f40eb29fdfc736275a797
6
+ metadata.gz: dc550a52d559e31d2ce7455543b0c9024c133bcab23af4a78df484141a54c70f6e76b97b339f7257e9a879ae0043e6b97f063bd0d36a28afa501cc96a27f53a6
7
+ data.tar.gz: 4e24dc4ea1d43c39cba77906c2c61f1bc1a946f0bc550f9a4516269d2d0498b68cf4342d4fb230094920c4f6d8e3c1c604e2c1d47d12087e8f98d27e101cb473
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_cli/core_ext'
4
- require 'ehbrs_ruby_utils/videos/container/file'
4
+ require 'ehbrs_ruby_utils/videos/container'
5
5
  require 'eac_ruby_utils/yaml'
6
6
 
7
7
  module Ehbrs
@@ -18,13 +18,13 @@ module Ehbrs
18
18
  end
19
19
 
20
20
  def output_content
21
- ::EacRubyUtils::Yaml.dump(container_file.info.to_h)
21
+ ::EacRubyUtils::Yaml.dump(container_file.probe_data)
22
22
  end
23
23
 
24
24
  private
25
25
 
26
26
  def container_file_uncached
27
- ::EhbrsRubyUtils::Videos::Container::File.new(parsed.file_path)
27
+ ::EhbrsRubyUtils::Videos::Container.new(parsed.file_path)
28
28
  end
29
29
  end
30
30
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ehbrs
4
4
  module Tools
5
- VERSION = '0.16.1'
5
+ VERSION = '0.16.2'
6
6
  end
7
7
  end
@@ -3,10 +3,11 @@
3
3
  require 'eac_ruby_utils/core_ext'
4
4
  require 'ehbrs/videos/track'
5
5
  require 'ehbrs_ruby_utils/executables'
6
+ require 'ehbrs_ruby_utils/videos/container'
6
7
 
7
8
  module Ehbrs
8
9
  module Videos
9
- class File
10
+ class File < ::EhbrsRubyUtils::Videos::Container
10
11
  enable_simple_cache
11
12
 
12
13
  TIME_PATTERN = /(\d+):(\d{2}):(\d{2})(?:\.(\d+))/.freeze
@@ -39,17 +40,12 @@ module Ehbrs
39
40
  end
40
41
  end
41
42
 
42
- common_constructor :path
43
-
44
43
  private
45
44
 
46
45
  def tracks_uncached
47
- r = []
48
- content.each_line do |line|
49
- t = ::Ehbrs::Videos::Track.create_from_string(line)
50
- r << t if t && t.type != 'Data'
46
+ streams.map { |stream| ::Ehbrs::Videos::Track.new(stream) }.reject do |t|
47
+ t.codec_type == ::EhbrsRubyUtils::Videos::Stream::CODEC_TYPE_DATA
51
48
  end
52
- r
53
49
  end
54
50
 
55
51
  def content_uncached
@@ -1,22 +1,32 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_ruby_utils/core_ext'
4
+ require 'ehbrs_ruby_utils/videos/stream'
4
5
 
5
6
  module Ehbrs
6
7
  module Videos
7
- class Track
8
- FFPROBE_PATTERN = /\A\s*Stream\s\#(\d+:\d+)(?:\(([^\)]+)\))?:\s*([^:]+):\s*([a-z0-9]+)(.*)/
9
- .freeze
10
- class << self
11
- def create_from_string(string)
12
- m = FFPROBE_PATTERN.match(string)
13
- return nil unless m
8
+ class Track < ::SimpleDelegator
9
+ TYPE_MAPPING = {
10
+ audio: 'Audio',
11
+ video: 'Video',
12
+ subtitle: 'Subtitle'
13
+ }.freeze
14
14
 
15
- new(m[1].to_i, m[3], m[2], m[4], m[5].strip)
16
- end
15
+ def codec
16
+ codec_name
17
17
  end
18
18
 
19
- common_constructor :number, :type, :language, :codec, :extra
19
+ def type
20
+ TYPE_MAPPING.fetch(codec_type)
21
+ end
22
+
23
+ def number
24
+ index
25
+ end
26
+
27
+ def extra
28
+ ffprobe_data.fetch(:codec_tag_string).to_s
29
+ end
20
30
 
21
31
  def to_s
22
32
  "[#{type}(#{number}): #{codec}/#{language || '-'}" +
@@ -5,6 +5,8 @@ module Ehbrs
5
5
  module Unsupported
6
6
  module Checks
7
7
  class CodecExtraUnlisted
8
+ TYPE = :stream
9
+
8
10
  common_constructor :codec, :listed_extras
9
11
 
10
12
  def check(track)
@@ -7,6 +7,8 @@ module Ehbrs
7
7
  module Unsupported
8
8
  module Checks
9
9
  class CodecExtraUnsupported
10
+ TYPE = :stream
11
+
10
12
  common_constructor :codec, :extra
11
13
 
12
14
  def check(track)
@@ -5,6 +5,8 @@ module Ehbrs
5
5
  module Unsupported
6
6
  module Checks
7
7
  class CodecUnlisted
8
+ TYPE = :stream
9
+
8
10
  common_constructor :listed_codecs
9
11
 
10
12
  def check(track)
@@ -7,6 +7,8 @@ module Ehbrs
7
7
  module Unsupported
8
8
  module Checks
9
9
  class CodecUnsupported
10
+ TYPE = :stream
11
+
10
12
  common_constructor :codec
11
13
 
12
14
  def check(track)
@@ -7,6 +7,8 @@ module Ehbrs
7
7
  module Unsupported
8
8
  module Checks
9
9
  class InvalidExtension
10
+ TYPE = :container
11
+
10
12
  common_constructor :extension
11
13
 
12
14
  def check(video)
@@ -12,7 +12,7 @@ module Ehbrs
12
12
  }.freeze
13
13
 
14
14
  TRACK_TYPE_FIX_CODECS = {
15
- 'Audio' => 'aac',
15
+ 'Audio' => 'libvorbis',
16
16
  'Video' => 'libx264',
17
17
  'Subtitle' => 'ass'
18
18
  }.freeze
@@ -19,13 +19,21 @@ module Ehbrs
19
19
  added_checks << check_path.camelize.constantize.new(*args)
20
20
  end
21
21
 
22
+ def base_checks
23
+ [unlisted_codec_check] + unsupported_codec_checks +
24
+ supported_codecs.flat_map { |codec| codec_extra_checks(codec) }
25
+ end
26
+
27
+ def checks
28
+ base_checks + added_checks
29
+ end
30
+
22
31
  def file_checks
23
- added_checks
32
+ checks.select { |c| check_type(c) == :container }
24
33
  end
25
34
 
26
35
  def track_checks
27
- [unlisted_codec_check] + unsupported_codec_checks +
28
- supported_codecs.flat_map { |codec| codec_extra_checks(codec) }
36
+ checks.select { |c| check_type(c) == :stream }
29
37
  end
30
38
 
31
39
  def codec_extra_checks(codec)
@@ -95,6 +103,12 @@ module Ehbrs
95
103
  def codec_supported_extras(codec)
96
104
  codec_extras(codec, 'supported')
97
105
  end
106
+
107
+ private
108
+
109
+ def check_type(check)
110
+ check.class.const_get(:TYPE)
111
+ end
98
112
  end
99
113
  end
100
114
  end
@@ -7,19 +7,20 @@ module Ehbrs
7
7
  module Unsupported
8
8
  module Profiles
9
9
  class Philco < ::Ehbrs::Videos::Unsupported::Profiles::Base
10
- AUDIO_SUPPORTED_CODECS = %w[aac ac3 eac3 mp3].freeze
11
- AUDIO_UNSUPPORTED_CODECS = %w[dts].freeze
10
+ AUDIO_SUPPORTED_CODECS = %w[aac ac3 eac3 mp3 vorbis wmav2].freeze
11
+ AUDIO_UNSUPPORTED_CODECS = %w[dts opus].freeze
12
12
 
13
13
  VIDEO_SUPPORTED_CODECS = %w[h264 mpeg4].freeze
14
14
  VIDEO_UNSUPPORTED_CODECS = %w[hevc msmpeg4v3].freeze
15
15
 
16
- SUBTITLE_SUPPORTED_CODECS = %w[ass dvd subrip].freeze
16
+ SUBTITLE_SUPPORTED_CODECS = %w[ass dvd dvd_subtitle hdmv_pgs_subtitle mov_text
17
+ subrip].freeze
17
18
  SUBTITLE_UNSUPPORTED_CODECS = %w[mov].freeze
18
19
 
19
20
  OTHER_SUPPORTED_CODECS = %w[png ttf].freeze
20
21
 
21
22
  MPEG4_EXTRA_SUPPORTED = %w[xvid].freeze
22
- MPEG4_EXTRA_UNSUPPORTED = %w[dx50].freeze
23
+ MPEG4_EXTRA_UNSUPPORTED = %w[divx dx50].freeze
23
24
  end
24
25
  end
25
26
  end
@@ -20,8 +20,8 @@ RSpec.shared_examples 'source_target_fixtures' do |spec_file| # rubocop:disable
20
20
  source_target_fixtures.source_files.each do |source_file|
21
21
  sd = sort_results(source_data(source_file))
22
22
  basename = ::Aranha::Parsers::SourceTargetFixtures.source_target_basename(source_file)
23
- target_file = File.expand_path("../#{basename}.target.yaml", source_file)
24
- File.write(target_file, sd.to_yaml)
23
+ target_file = File.expand_path("../#{basename}.target#{target_file_extname}", source_file)
24
+ File.write(target_file, target_content(sd))
25
25
  end
26
26
  end
27
27
  else
@@ -67,4 +67,12 @@ RSpec.shared_examples 'source_target_fixtures' do |spec_file| # rubocop:disable
67
67
  def target_data(target_file)
68
68
  ::YAML.load_file(target_file)
69
69
  end
70
+
71
+ def target_content(data)
72
+ data.to_yaml
73
+ end
74
+
75
+ def target_file_extname
76
+ '.yaml'
77
+ end
70
78
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Aranha
4
4
  module Parsers
5
- VERSION = '0.6.1'
5
+ VERSION = '0.7.0'
6
6
  end
7
7
  end
@@ -9,36 +9,30 @@ module EacCli
9
9
  class Definition
10
10
  require_sub __FILE__
11
11
 
12
+ MAIN_ALTERNATIVE_KEY = :main
12
13
  SUBCOMMAND_NAME_ARG = 'subcommand'
13
14
  SUBCOMMAND_ARGS_ARG = 'subcommand_args'
14
15
 
15
16
  attr_accessor :description
16
- attr_accessor :options_argument
17
17
 
18
18
  def initialize
19
19
  self.description = '-- NO DESCRIPTION SET --'
20
- self.options_argument = true
20
+ alternatives_set[MAIN_ALTERNATIVE_KEY] = main_alternative
21
21
  end
22
22
 
23
23
  def alt(&block)
24
- r = ::EacCli::Definition.new
24
+ r = ::EacCli::Definition::Alternative.new
25
25
  r.instance_eval(&block)
26
- alternatives << r
26
+ alternatives_set[new_alternative_key] = r
27
27
  r
28
28
  end
29
29
 
30
30
  def alternatives
31
- @alternatives ||= []
31
+ alternatives_set.values
32
32
  end
33
33
 
34
- def arg_opt(short, long, description, option_options = {})
35
- options << ::EacCli::Definition::ArgumentOption.new(
36
- short, long, description, option_options
37
- )
38
- end
39
-
40
- def bool_opt(short, long, description, option_options = {})
41
- options << ::EacCli::Definition::BooleanOption.new(short, long, description, option_options)
34
+ def alternative(key)
35
+ alternatives_set.fetch(key)
42
36
  end
43
37
 
44
38
  def desc(description)
@@ -49,42 +43,31 @@ module EacCli
49
43
  @help_formatter ||= ::EacCli::Definition::HelpFormatter.new(self)
50
44
  end
51
45
 
52
- def options_arg(options_argument)
53
- self.options_argument = options_argument
54
- end
55
-
56
- def options
57
- @options ||= []
46
+ def main_alternative
47
+ @main_alternative ||= begin
48
+ r = ::EacCli::Definition::Alternative.new
49
+ r.options_argument(true)
50
+ r
51
+ end
58
52
  end
59
53
 
60
- def pos_arg(name, arg_options = {})
61
- new_pos_arg = ::EacCli::Definition::PositionalArgument.new(name, arg_options)
62
- raise 'Positional arguments are blocked' if positional_arguments_blocked?(new_pos_arg)
63
-
64
- pos_set << new_pos_arg
54
+ def options_arg(options_argument)
55
+ self.options_argument = options_argument
65
56
  end
66
57
 
67
- def positional
68
- pos_set.to_a
58
+ def options_argument
59
+ main_alternative.options_argument?
69
60
  end
70
61
 
71
- def positional_arguments_blocked?(new_pos_arg)
72
- last = pos_set.last
73
- return false unless last
74
- return true if last.repeat?
75
- return true if last.optional? && new_pos_arg.required?
76
-
77
- false
62
+ def options_argument=(enable)
63
+ main_alternative.options_argument(enable)
78
64
  end
79
65
 
80
- def subcommands
81
- pos_arg(SUBCOMMAND_NAME_ARG, subcommand: true)
82
- pos_set << ::EacCli::Definition::PositionalArgument.new(SUBCOMMAND_ARGS_ARG,
83
- optional: true, repeat: true)
84
- end
66
+ delegate :arg_opt, :bool_opt, :options, :pos_arg,
67
+ :positional, :subcommands, to: :main_alternative
85
68
 
86
69
  def subcommands?
87
- pos_set.any?(&:subcommand?)
70
+ alternatives.any?(&:subcommands?)
88
71
  end
89
72
 
90
73
  def options_first(enable = true)
@@ -97,6 +80,18 @@ module EacCli
97
80
 
98
81
  private
99
82
 
83
+ def alternatives_set
84
+ @alternatives_set ||= ::ActiveSupport::HashWithIndifferentAccess.new
85
+ end
86
+
87
+ def new_alternative_key
88
+ @last_key ||= 0
89
+ loop do
90
+ @last_key += 1
91
+ break @last_key unless alternatives_set.key?(@last_key)
92
+ end
93
+ end
94
+
100
95
  def pos_set
101
96
  @pos_set ||= []
102
97
  end
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/definition/argument_option'
4
+ require 'eac_cli/definition/boolean_option'
5
+ require 'eac_cli/definition/positional_argument'
6
+
7
+ module EacCli
8
+ class Definition
9
+ class Alternative
10
+ SUBCOMMAND_NAME_ARG = :subcommand
11
+ SUBCOMMAND_ARGS_ARG = :subcommand_args
12
+
13
+ def arg_opt(short, long, description, option_options = {})
14
+ options_set << ::EacCli::Definition::ArgumentOption.new(
15
+ short, long, description, option_options
16
+ )
17
+ end
18
+
19
+ def bool_opt(short, long, description, option_options = {})
20
+ options_set << ::EacCli::Definition::BooleanOption.new(short, long, description,
21
+ option_options)
22
+ end
23
+
24
+ def options
25
+ options_set.to_a
26
+ end
27
+
28
+ def options_argument?
29
+ @options_argument ? true : false
30
+ end
31
+
32
+ def options_argument(enable)
33
+ @options_argument = enable
34
+
35
+ self
36
+ end
37
+
38
+ def pos_arg(name, arg_options = {})
39
+ new_pos_arg = ::EacCli::Definition::PositionalArgument.new(name, arg_options)
40
+ check_positional_blocked(new_pos_arg)
41
+ pos_set << new_pos_arg
42
+ end
43
+
44
+ def positional
45
+ pos_set.to_a
46
+ end
47
+
48
+ def positional_arguments_blocked?(new_pos_arg)
49
+ last = pos_set.last
50
+ return false unless last
51
+ return true if subcommands?
52
+ return true if last.repeat?
53
+ return true if last.optional? && new_pos_arg.if_present(&:required?)
54
+
55
+ false
56
+ end
57
+
58
+ def subcommands
59
+ pos_arg(SUBCOMMAND_NAME_ARG, subcommand: true)
60
+ pos_set << ::EacCli::Definition::PositionalArgument.new(SUBCOMMAND_ARGS_ARG,
61
+ optional: true, repeat: true)
62
+ end
63
+
64
+ def subcommands?
65
+ pos_set.any?(&:subcommand?)
66
+ end
67
+
68
+ private
69
+
70
+ def check_positional_blocked(new_pos_arg)
71
+ raise 'Positional arguments are blocked' if positional_arguments_blocked?(new_pos_arg)
72
+ end
73
+
74
+ def pos_set
75
+ @pos_set ||= []
76
+ end
77
+
78
+ def options_set
79
+ @options_set ||= []
80
+ end
81
+ end
82
+ end
83
+ end