Class: EhbrsRubyUtils::Videos2::Unsupported::Profiles::Base

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb

Direct Known Subclasses

Aoc, Philco, Samsung

Constant Summary collapse

CONSTANT_PREFIXES =
%w[video audio subtitle other].freeze

Instance Method Summary collapse

Instance Method Details

#add_check(name, *args) ⇒ Object



17
18
19
20
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 17

def add_check(name, *args)
  check_path = "ehbrs_ruby_utils/videos2/unsupported/checks/#{name}"
  added_checks << check_path.camelize.constantize.new(*args)
end

#added_checksObject



13
14
15
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 13

def added_checks
  @added_checks ||= []
end

#base_checksObject



22
23
24
25
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 22

def base_checks
  [unlisted_codec_check] + unsupported_codec_checks +
    supported_codecs.flat_map { |codec| codec_extra_checks(codec) }
end

#checksObject



27
28
29
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 27

def checks
  base_checks + added_checks
end

#codec_extra_checks(codec) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 39

def codec_extra_checks(codec)
  codec_unlisted_extra_check(codec).if_present([]) { |v| [v] } +
    codec_unsupported_extras(codec).map do |extra|
      EhbrsRubyUtils::Videos2::Unsupported::Checks::CodecExtraUnsupported.new(codec,
                                                                              extra)
    end
end

#codec_extras(codec, suffix) ⇒ Object



94
95
96
97
98
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 94

def codec_extras(codec, suffix)
  self.class.const_get("#{codec}_extra_#{suffix}".upcase)
rescue NameError
  []
end

#codec_supported_extras(codec) ⇒ Object



104
105
106
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 104

def codec_supported_extras(codec)
  codec_extras(codec, 'supported')
end

#codec_unlisted_extra_check(codec) ⇒ Object



47
48
49
50
51
52
53
54
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 47

def codec_unlisted_extra_check(codec)
  extras = codec_unsupported_extras(codec) + codec_supported_extras(codec)
  return nil unless extras.any?

  EhbrsRubyUtils::Videos2::Unsupported::Checks::CodecExtraUnlisted.new(
    codec, extras.sort.uniq
  )
end

#codec_unsupported_extras(codec) ⇒ Object



100
101
102
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 100

def codec_unsupported_extras(codec)
  codec_extras(codec, 'unsupported')
end

#codecs_by_constant(middle) ⇒ Object



84
85
86
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 84

def codecs_by_constant(middle)
  CONSTANT_PREFIXES.inject([]) { |a, e| a + codecs_by_prefix(e, middle) }
end

#codecs_by_prefix(prefix, middle) ⇒ Object



88
89
90
91
92
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 88

def codecs_by_prefix(prefix, middle)
  self.class.const_get("#{prefix}_#{middle}_codecs".upcase)
rescue NameError
  []
end

#file_checksObject



31
32
33
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 31

def file_checks
  checks.select { |c| check_type(c) == :container }
end

#nameObject



56
57
58
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 56

def name
  self.class.name.demodulize.underscore
end

#supported_codecs_uncachedObject



80
81
82
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 80

def supported_codecs_uncached
  codecs_by_constant('supported')
end

#to_sObject



60
61
62
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 60

def to_s
  name
end

#track_checksObject



35
36
37
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 35

def track_checks
  checks.select { |c| check_type(c) == :stream }
end

#unlisted_codec_checkObject



74
75
76
77
78
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 74

def unlisted_codec_check
  ::EhbrsRubyUtils::Videos2::Unsupported::Checks::CodecUnlisted.new(
    (supported_codecs + unsupported_codecs).sort.uniq
  )
end

#unsupported_codec_checksObject



64
65
66
67
68
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 64

def unsupported_codec_checks
  unsupported_codecs.map do |codec|
    EhbrsRubyUtils::Videos2::Unsupported::Checks::CodecUnsupported.new(codec)
  end
end

#unsupported_codecs_uncachedObject



70
71
72
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 70

def unsupported_codecs_uncached
  codecs_by_constant('unsupported')
end