Class: Ehbrs::Videos::Unsupported::Profiles::Base

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/ehbrs/videos/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/videos/unsupported/profiles/base.rb', line 17

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

#added_checksObject



13
14
15
# File 'lib/ehbrs/videos/unsupported/profiles/base.rb', line 13

def added_checks
  @added_checks ||= []
end

#base_checksObject



22
23
24
25
# File 'lib/ehbrs/videos/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/videos/unsupported/profiles/base.rb', line 27

def checks
  base_checks + added_checks
end

#codec_extra_checks(codec) ⇒ Object



39
40
41
42
43
44
# File 'lib/ehbrs/videos/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|
      Ehbrs::Videos::Unsupported::Checks::CodecExtraUnsupported.new(codec, extra)
    end
end

#codec_extras(codec, suffix) ⇒ Object



93
94
95
96
97
# File 'lib/ehbrs/videos/unsupported/profiles/base.rb', line 93

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

#codec_supported_extras(codec) ⇒ Object



103
104
105
# File 'lib/ehbrs/videos/unsupported/profiles/base.rb', line 103

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

#codec_unlisted_extra_check(codec) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/ehbrs/videos/unsupported/profiles/base.rb', line 46

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

  Ehbrs::Videos::Unsupported::Checks::CodecExtraUnlisted.new(
    codec, extras.sort.uniq
  )
end

#codec_unsupported_extras(codec) ⇒ Object



99
100
101
# File 'lib/ehbrs/videos/unsupported/profiles/base.rb', line 99

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

#codecs_by_constant(middle) ⇒ Object



83
84
85
# File 'lib/ehbrs/videos/unsupported/profiles/base.rb', line 83

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

#codecs_by_prefix(prefix, middle) ⇒ Object



87
88
89
90
91
# File 'lib/ehbrs/videos/unsupported/profiles/base.rb', line 87

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/videos/unsupported/profiles/base.rb', line 31

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

#nameObject



55
56
57
# File 'lib/ehbrs/videos/unsupported/profiles/base.rb', line 55

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

#supported_codecs_uncachedObject



79
80
81
# File 'lib/ehbrs/videos/unsupported/profiles/base.rb', line 79

def supported_codecs_uncached
  codecs_by_constant('supported')
end

#to_sObject



59
60
61
# File 'lib/ehbrs/videos/unsupported/profiles/base.rb', line 59

def to_s
  name
end

#track_checksObject



35
36
37
# File 'lib/ehbrs/videos/unsupported/profiles/base.rb', line 35

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

#unlisted_codec_checkObject



73
74
75
76
77
# File 'lib/ehbrs/videos/unsupported/profiles/base.rb', line 73

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

#unsupported_codec_checksObject



63
64
65
66
67
# File 'lib/ehbrs/videos/unsupported/profiles/base.rb', line 63

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

#unsupported_codecs_uncachedObject



69
70
71
# File 'lib/ehbrs/videos/unsupported/profiles/base.rb', line 69

def unsupported_codecs_uncached
  codecs_by_constant('unsupported')
end