ehbrs_ruby_utils 0.40.0 → 0.41.0

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.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ehbrs_ruby_utils/bga/session/skip_trophies.rb +2 -2
  3. data/lib/ehbrs_ruby_utils/music/lyrics_book/song.rb +1 -1
  4. data/lib/ehbrs_ruby_utils/version.rb +1 -1
  5. data/lib/ehbrs_ruby_utils/videos/{container.rb → file.rb} +1 -1
  6. data/lib/ehbrs_ruby_utils/videos/stream.rb +33 -2
  7. data/lib/ehbrs_ruby_utils/videos2/convert_job.rb +99 -0
  8. data/lib/ehbrs_ruby_utils/videos2/extract/package.rb +75 -0
  9. data/lib/ehbrs_ruby_utils/videos2/extract/package_file.rb +53 -0
  10. data/lib/ehbrs_ruby_utils/videos2/extract.rb +11 -0
  11. data/lib/ehbrs_ruby_utils/videos2/profiles/base.rb +35 -0
  12. data/lib/ehbrs_ruby_utils/videos2/profiles/same_quality.rb +21 -0
  13. data/lib/ehbrs_ruby_utils/videos2/unsupported/check_result.rb +24 -0
  14. data/lib/ehbrs_ruby_utils/videos2/unsupported/check_set.rb +43 -0
  15. data/lib/ehbrs_ruby_utils/videos2/unsupported/check_support.rb +71 -0
  16. data/lib/ehbrs_ruby_utils/videos2/unsupported/checks/codec_extra_unlisted.rb +29 -0
  17. data/lib/ehbrs_ruby_utils/videos2/unsupported/checks/codec_extra_unsupported.rb +28 -0
  18. data/lib/ehbrs_ruby_utils/videos2/unsupported/checks/codec_unlisted.rb +25 -0
  19. data/lib/ehbrs_ruby_utils/videos2/unsupported/checks/codec_unsupported.rb +27 -0
  20. data/lib/ehbrs_ruby_utils/videos2/unsupported/checks/invalid_extension.rb +27 -0
  21. data/lib/ehbrs_ruby_utils/videos2/unsupported/checks.rb +13 -0
  22. data/lib/ehbrs_ruby_utils/videos2/unsupported/file/fix.rb +45 -0
  23. data/lib/ehbrs_ruby_utils/videos2/unsupported/file.rb +51 -0
  24. data/lib/ehbrs_ruby_utils/videos2/unsupported/fix_profile.rb +44 -0
  25. data/lib/ehbrs_ruby_utils/videos2/unsupported/fixes/supported_codec/ffmpeg_args.rb +68 -0
  26. data/lib/ehbrs_ruby_utils/videos2/unsupported/fixes/supported_codec.rb +15 -0
  27. data/lib/ehbrs_ruby_utils/videos2/unsupported/fixes/supported_container.rb +17 -0
  28. data/lib/ehbrs_ruby_utils/videos2/unsupported/profiles/aoc.rb +27 -0
  29. data/lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb +117 -0
  30. data/lib/ehbrs_ruby_utils/videos2/unsupported/profiles/philco.rb +28 -0
  31. data/lib/ehbrs_ruby_utils/videos2/unsupported/profiles/samsung.rb +33 -0
  32. data/lib/ehbrs_ruby_utils/videos2/unsupported/profiles.rb +13 -0
  33. data/lib/ehbrs_ruby_utils/videos2/unsupported/search.rb +75 -0
  34. data/lib/ehbrs_ruby_utils/videos2/unsupported/track.rb +32 -0
  35. data/lib/ehbrs_ruby_utils/videos2.rb +9 -0
  36. metadata +32 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86fcf26dbec53e9e7e2b04d2197849a7f17ad0850b07d4420e26a115841c3a32
4
- data.tar.gz: 3a62e456a9d8965f914b47ccd483a92656058cc0a59f99aef595c772fdfeb05e
3
+ metadata.gz: a44e90ef4da84b99b3b0f0ec915528e06feef36f88ac6e1a89d7b6cd2dfa4a85
4
+ data.tar.gz: 236d80b4491da318c1f5bc6ff6336ca9db5ddbb47b36e0222f817f906796e518
5
5
  SHA512:
6
- metadata.gz: 171835d362844886ba8032527dd298a8da9913b9a699570686252a35209c8976e77e658ef9ca22a2e386313386a68a1dfc064298832bc9e4a8c622be6a06f89a
7
- data.tar.gz: 1b03d32256cbf9e3e27dafd52acaac5ae977a0911d014da72ef97b9ef3ba3ff10e66b62208b139d60a42efc0626b320ba226c6b24dfd1cdbab3310b0eeb3cce6
6
+ metadata.gz: 3d2ef32002c18d1a907989c1cd11f423bd010e4f03af74a857a4ee9c046bbd9ca5f22015f82f1711191918da22da320ace42e70f49de6f14b36cd1d624cb9d48
7
+ data.tar.gz: 6f9eef1ee52d3f97517448a03a346d6b392fecd4e26d064b7afa2b1eeddb0e530afffa6d3f25118752004c48d1be1ee382c11426156ae39ffec507ada037cb6d
@@ -19,8 +19,8 @@ module EhbrsRubyUtils
19
19
  e
20
20
  end
21
21
 
22
- def on_skip_trophies(&block)
23
- error = on_rescue_timeout(&block)
22
+ def on_skip_trophies(...)
23
+ error = on_rescue_timeout(...)
24
24
  return unless error
25
25
  raise error unless skip_trophy_overlay?
26
26
 
@@ -51,7 +51,7 @@ module EhbrsRubyUtils
51
51
  private
52
52
 
53
53
  def container_uncached
54
- ::EhbrsRubyUtils::Videos::Container.new(path)
54
+ ::EhbrsRubyUtils::Videos::File.new(path)
55
55
  end
56
56
 
57
57
  def fetch_lyrics
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EhbrsRubyUtils
4
- VERSION = '0.40.0'
4
+ VERSION = '0.41.0'
5
5
  end
@@ -10,7 +10,7 @@ require 'ultimate_lyrics/song_metadata'
10
10
 
11
11
  module EhbrsRubyUtils
12
12
  module Videos
13
- class Container
13
+ class File
14
14
  class << self
15
15
  def from_file(path)
16
16
  new(path)
@@ -10,6 +10,10 @@ module EhbrsRubyUtils
10
10
 
11
11
  lists.add_symbol :codec_type, :audio, :video, :subtitle, :data, :attachment
12
12
 
13
+ DURATION_TAG_TO_SECONDS_PARSER = /\A(\d{2}):(\d{2}):(\d{2}.\d+)\z/.to_parser do |m|
14
+ (m[1].to_i * 3600) + (m[2].to_i * 60) + m[3].to_f
15
+ end
16
+
13
17
  common_constructor :ffprobe_data do
14
18
  self.ffprobe_data = ffprobe_data.symbolize_keys.freeze
15
19
  self.class.lists.codec_type.value_validate!(codec_type)
@@ -21,8 +25,19 @@ module EhbrsRubyUtils
21
25
  end
22
26
  end
23
27
 
28
+ # @return [Integer]
29
+ def codec_tag
30
+ ffprobe_data.fetch(:codec_tag).to_i(16)
31
+ end
32
+
33
+ # @return [ActiveSupport::Duration, nil]
34
+ def duration
35
+ duration_from_root || duration_from_tags
36
+ end
37
+
38
+ # @return [String]
24
39
  def to_s
25
- "#{index}|#{codec_type}|#{codec_name}|#{language}"
40
+ [index, codec_type, codec_name, language, codec_tag_string].join('|')
26
41
  end
27
42
 
28
43
  def to_h
@@ -35,7 +50,7 @@ module EhbrsRubyUtils
35
50
  end
36
51
  end
37
52
 
38
- %i[codec_name codec_long_name height width].each do |method_name|
53
+ %i[codec_name codec_long_name codec_tag_string height width].each do |method_name|
39
54
  define_method method_name do
40
55
  ffprobe_data[method_name]
41
56
  end
@@ -60,6 +75,22 @@ module EhbrsRubyUtils
60
75
  def title
61
76
  tags[:title]
62
77
  end
78
+
79
+ private
80
+
81
+ # @return [ActiveSupport::Duration, nil]
82
+ def duration_from_root
83
+ ffprobe_data[:duration].if_present do |v|
84
+ ::ActiveSupport::Duration.build(v.to_f)
85
+ end
86
+ end
87
+
88
+ # @return [ActiveSupport::Duration, nil]
89
+ def duration_from_tags
90
+ tags[:DURATION].if_present do |v|
91
+ ::ActiveSupport::Duration.build(DURATION_TAG_TO_SECONDS_PARSER.parse!(v))
92
+ end
93
+ end
63
94
  end
64
95
  end
65
96
  end
@@ -0,0 +1,99 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'ehbrs_ruby_utils/executables'
5
+ require 'fileutils'
6
+
7
+ module EhbrsRubyUtils
8
+ module Videos2
9
+ class ConvertJob
10
+ enable_speaker
11
+ enable_simple_cache
12
+
13
+ FORMATS_TO_EXTENSIONS = {
14
+ 'matroska' => '.mkv'
15
+ }.freeze
16
+
17
+ attr_reader :input, :profile
18
+
19
+ def initialize(input, profile)
20
+ raise "Input file \"#{input}\" does not exist" unless ::File.exist?(input.to_s)
21
+
22
+ @input = input
23
+ @profile = profile
24
+ end
25
+
26
+ def run
27
+ if ::File.exist?(converted)
28
+ warn("Converted file already exist: \"#{converted}\"")
29
+ else
30
+ profile.run_callbacks(:convert) { convert }
31
+ profile.run_callbacks(:swap) { swap }
32
+ end
33
+ end
34
+
35
+ def target
36
+ ::File.join(::File.dirname(input), "#{::File.basename(input, '.*')}#{target_extension}")
37
+ end
38
+
39
+ private
40
+
41
+ def command_args_uncached
42
+ r = ['-i', input] + profile_ffmpeg_args
43
+ r += ['-f', format_by_input] if format_by_args.blank?
44
+ r + [converting]
45
+ end
46
+
47
+ def convert
48
+ infov 'Convert args', command_args.shelljoin
49
+ ::EhbrsRubyUtils::Executables.ffmpeg.command.append(command_args).system!
50
+ end
51
+
52
+ def format_by_args_uncached
53
+ profile_ffmpeg_args.rindex('-f').if_present do |option_index|
54
+ profile_ffmpeg_args[option_index + 1]
55
+ end
56
+ end
57
+
58
+ def format_by_input
59
+ r = FORMATS_TO_EXTENSIONS.invert[target_extension_by_input]
60
+ return if r.present?
61
+
62
+ target_extension_by_input.gsub(/\A\./, '')
63
+ end
64
+
65
+ def format_to_extension(format)
66
+ FORMATS_TO_EXTENSIONS[format].if_present(".#{format}")
67
+ end
68
+
69
+ def profile_ffmpeg_args_uncached
70
+ profile.ffmpeg_args
71
+ end
72
+
73
+ def swap
74
+ ::FileUtils.mv(input, converted)
75
+ ::FileUtils.mv(converting, target)
76
+ end
77
+
78
+ def converting
79
+ "#{target}.converting"
80
+ end
81
+
82
+ def converted
83
+ input.basename_sub { |b| "#{b}.converted" }
84
+ end
85
+
86
+ def target_extension
87
+ target_extension_by_args || target_extension_by_input
88
+ end
89
+
90
+ def target_extension_by_args
91
+ format_by_args.if_present { |v| format_to_extension(v) }
92
+ end
93
+
94
+ def target_extension_by_input
95
+ ::File.extname(input)
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'ehbrs_ruby_utils/fs/compressed_package'
5
+ require 'ehbrs_ruby_utils/videos2/extract/package_file'
6
+
7
+ module EhbrsRubyUtils
8
+ module Videos2
9
+ module Extract
10
+ class Package
11
+ enable_simple_cache
12
+
13
+ common_constructor :path, :target_dir, :qualities do
14
+ self.path = path.to_pathname
15
+ self.target_dir = target_dir.to_pathname
16
+ end
17
+
18
+ delegate :to_s, to: :path
19
+
20
+ def run(delete)
21
+ selected_files.each(&:copy_to_selected_dir)
22
+ files.each(&:move_to_quality_dir)
23
+ extract_dir.rmdir
24
+ path.unlink if delete
25
+ end
26
+
27
+ private
28
+
29
+ def files_uncached
30
+ ::Pathname.glob("#{extract_dir}/**/*").map do |file|
31
+ ::EhbrsRubyUtils::Videos2::Extract::PackageFile.new(self, file)
32
+ end
33
+ end
34
+
35
+ def extract_dir_uncached
36
+ r = target_dir / path.basename
37
+ raise "Extract directory \"#{r}\" is a file" if r.file?
38
+
39
+ r.rmtree if r.directory?
40
+ ::EhbrsRubyUtils::Fs::CompressedPackage.new(path).extract_to(r)
41
+ r
42
+ end
43
+
44
+ def files_qualities_uncached
45
+ qualities_with_default.select { |q| grouped_files.keys.include?(q) }
46
+ end
47
+
48
+ def grouped_files_uncached
49
+ r = {}
50
+ files.each do |file|
51
+ r[file.quality] ||= []
52
+ r[file.quality] << file
53
+ end
54
+ r
55
+ end
56
+
57
+ def qualities_with_default
58
+ qualities + [::EhbrsRubyUtils::Videos2::Extract::PackageFile::DEFAULT_QUALITY]
59
+ end
60
+
61
+ def selected_dir_uncached
62
+ target_dir / 'selected'
63
+ end
64
+
65
+ def selected_files
66
+ files.select { |f| f.quality == selected_quality }
67
+ end
68
+
69
+ def selected_quality_uncached
70
+ files_qualities.first
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EhbrsRubyUtils
6
+ module Videos2
7
+ module Extract
8
+ class PackageFile
9
+ DEFAULT_QUALITY = '__default__'
10
+
11
+ enable_simple_cache
12
+ common_constructor :package, :path do
13
+ self.path = path.to_pathname
14
+ end
15
+
16
+ def copy_to_selected_dir
17
+ ::FileUtils.cp(path.to_path, selected_dir.to_path)
18
+ end
19
+
20
+ def match_quality?(quality)
21
+ path.basename_sub { |b| b.to_s.downcase }.basename
22
+ .fnmatch?("*#{quality.downcase}*".gsub(/\A\*+/, '*').gsub(/\*+\z/, '*'))
23
+ end
24
+
25
+ def move_to_quality_dir
26
+ ::FileUtils.mv(path.to_path, quality_dir.to_path)
27
+ end
28
+
29
+ private
30
+
31
+ def quality_uncached
32
+ package.qualities.find { |q| match_quality?(q) } || DEFAULT_QUALITY
33
+ end
34
+
35
+ def quality_dir
36
+ r = package.target_dir / quality
37
+ r.mkpath
38
+ r
39
+ end
40
+
41
+ def selected_dir
42
+ r = nil
43
+ r = package.target_dir / 'source' if /\.torrent/ =~ path.to_path
44
+ r = package.target_dir / 'subtitle' if /\.srt/ =~ path.to_path
45
+ raise "Destination unknown: #{path}" unless r
46
+
47
+ r.mkpath
48
+ r
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EhbrsRubyUtils
6
+ module Videos2
7
+ module Extract
8
+ require_sub __FILE__
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EhbrsRubyUtils
4
+ module Videos2
5
+ module Profiles
6
+ module Base
7
+ extend ::ActiveSupport::Concern
8
+
9
+ attr_reader :convert_job
10
+
11
+ included do
12
+ include ActiveSupport::Callbacks
13
+ define_callbacks :convert, :swap
14
+ end
15
+
16
+ def ffmpeg_args
17
+ []
18
+ end
19
+
20
+ def on_convert_job
21
+ old_value = convert_job
22
+ begin
23
+ yield
24
+ ensure
25
+ self.convert_job = old_value
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ attr_writer :convert_job
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ehbrs_ruby_utils/videos2/profiles/base'
4
+
5
+ module EhbrsRubyUtils
6
+ module Videos2
7
+ module Profiles
8
+ module SameQuality
9
+ extend ::ActiveSupport::Concern
10
+
11
+ included do
12
+ include ::EhbrsRubyUtils::Videos2::Profiles::Base
13
+ end
14
+
15
+ def ffmpeg_args
16
+ super + ['-q:a', '0', '-q:v', '0']
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EhbrsRubyUtils
6
+ module Videos2
7
+ module Unsupported
8
+ class CheckResult
9
+ enable_simple_cache
10
+ common_constructor :source, :check
11
+
12
+ def passed?
13
+ message.blank?
14
+ end
15
+
16
+ private
17
+
18
+ def message_uncached
19
+ check.check(source)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ehbrs_ruby_utils/videos2/unsupported/checks'
4
+
5
+ module EhbrsRubyUtils
6
+ module Videos2
7
+ module Unsupported
8
+ class CheckSet
9
+ enable_simple_cache
10
+ common_constructor :checks
11
+
12
+ class << self
13
+ # type: "file" or "track"
14
+ def build(profiles, type)
15
+ r = {}
16
+ profiles.each do |profile|
17
+ profile.send("#{type}_checks").each do |check|
18
+ r[check] ||= CheckWithProfiles.new(check)
19
+ r[check].add_profile(profile)
20
+ end
21
+ end
22
+ new(r.values)
23
+ end
24
+ end
25
+
26
+ class CheckWithProfiles < ::SimpleDelegator
27
+ def initialize(check)
28
+ super(check)
29
+ @profiles = []
30
+ end
31
+
32
+ def check_name
33
+ __getobj__.class.name.demodulize
34
+ end
35
+
36
+ def add_profile(profile)
37
+ @profiles << profile
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'ehbrs_ruby_utils/videos2/unsupported/check_result'
5
+
6
+ module EhbrsRubyUtils
7
+ module Videos2
8
+ module Unsupported
9
+ module CheckSupport
10
+ common_concern do
11
+ enable_simple_cache
12
+ enable_speaker
13
+ end
14
+
15
+ def aggressions_banner(title)
16
+ return if passed?
17
+
18
+ info title
19
+ pad_speaker do
20
+ unpassed_checks.each do |u|
21
+ info "* #{u.message}"
22
+ end
23
+ end
24
+ end
25
+
26
+ def ffmpeg_fix_args
27
+ unpassed_checks.flat_map do |check|
28
+ check.check.fix.if_present([]) { |v| v.ffmpeg_args(self) }
29
+ end
30
+ end
31
+
32
+ def passed?
33
+ unpassed_checks.none?
34
+ end
35
+
36
+ private
37
+
38
+ def unpassed_checks_uncached
39
+ checks.reject(&:passed?)
40
+ end
41
+
42
+ def checks_uncached
43
+ options.fetch(check_set_key).checks.map do |check|
44
+ ::EhbrsRubyUtils::Videos2::Unsupported::CheckResult.new(self, check)
45
+ end
46
+ rescue StandardError => e
47
+ raise "#{e.message} (Source: #{self})"
48
+ end
49
+
50
+ def fix_blocks_uncached
51
+ checks.reject(&:passed?).select { |c| c.check.fix.blank? }
52
+ end
53
+
54
+ def fixes_uncached
55
+ checks.reject(&:passed?).map { |c| c.check.fix }.compact_blank
56
+ end
57
+
58
+ def pad_speaker(&block)
59
+ ::EacRubyUtils::Speaker.context.on(::EacCli::Speaker.new(err_line_prefix: ' '), &block)
60
+ end
61
+
62
+ def new_padded_cli_speaker
63
+ ::EacCli::Speaker.new(
64
+ err_line_prefix("#{::EacRubyUtils::Speaker.context.optional_current
65
+ .if_present('') { |v| v.is_a?(::EacCli::Speaker) ? v.err_line_prefix : '' }} ")
66
+ )
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EhbrsRubyUtils
4
+ module Videos2
5
+ module Unsupported
6
+ module Checks
7
+ class CodecExtraUnlisted
8
+ TYPE = :stream
9
+
10
+ common_constructor :codec, :listed_extras
11
+
12
+ def check(track)
13
+ return nil unless track.codec_name == codec
14
+ return nil if listed_extras.any? do |extra|
15
+ track.codec_tag_string.downcase.include?(extra.downcase)
16
+ end
17
+
18
+ "Not listed extra for codec \"#{codec}\" (Track: #{track}" \
19
+ ", listed extra: #{listed_extras})"
20
+ end
21
+
22
+ def fix
23
+ nil
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ehbrs_ruby_utils/videos2/unsupported/fixes/supported_codec'
4
+
5
+ module EhbrsRubyUtils
6
+ module Videos2
7
+ module Unsupported
8
+ module Checks
9
+ class CodecExtraUnsupported
10
+ TYPE = :stream
11
+
12
+ common_constructor :codec, :extra
13
+
14
+ def check(track)
15
+ return nil unless track.codec_name == codec
16
+ return nil unless track.codec_tag_string.downcase.include?(extra.downcase)
17
+
18
+ "Unsupported extra \"#{extra}\" for codec \"#{codec}\" and track #{track}"
19
+ end
20
+
21
+ def fix
22
+ ::EhbrsRubyUtils::Videos2::Unsupported::Fixes::SupportedCodec.new
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EhbrsRubyUtils
4
+ module Videos2
5
+ module Unsupported
6
+ module Checks
7
+ class CodecUnlisted
8
+ TYPE = :stream
9
+
10
+ common_constructor :listed_codecs
11
+
12
+ def check(track)
13
+ return nil if listed_codecs.include?(track.codec_name)
14
+
15
+ "Not listed codec \"#{track.codec_name}\" (Track: #{track}, listed: #{listed_codecs})"
16
+ end
17
+
18
+ def fix
19
+ nil
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ehbrs_ruby_utils/videos2/unsupported/fixes/supported_codec'
4
+
5
+ module EhbrsRubyUtils
6
+ module Videos2
7
+ module Unsupported
8
+ module Checks
9
+ class CodecUnsupported
10
+ TYPE = :stream
11
+
12
+ common_constructor :codec
13
+
14
+ def check(track)
15
+ return nil unless track.codec_name == codec
16
+
17
+ "Unsupported codec \"#{codec}\" for track #{track}"
18
+ end
19
+
20
+ def fix
21
+ ::EhbrsRubyUtils::Videos2::Unsupported::Fixes::SupportedCodec.new
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ehbrs_ruby_utils/videos2/unsupported/fixes/supported_container'
4
+
5
+ module EhbrsRubyUtils
6
+ module Videos2
7
+ module Unsupported
8
+ module Checks
9
+ class InvalidExtension
10
+ TYPE = :container
11
+
12
+ common_constructor :extension
13
+
14
+ def check(video)
15
+ return nil unless ::File.extname(video.path) == extension
16
+
17
+ "File has invalid extension: #{extension}"
18
+ end
19
+
20
+ def fix
21
+ ::EhbrsRubyUtils::Videos2::Unsupported::Fixes::SupportedContainer.new
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end