ehbrs-tools 0.39.0 → 0.40.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +106 -143
  3. data/lib/ehbrs/tools/runner/music/lyrics.rb +2 -2
  4. data/lib/ehbrs/tools/runner/music/lyrics_book.rb +1 -1
  5. data/lib/ehbrs/tools/runner/music/spread.rb +32 -7
  6. data/lib/ehbrs/tools/runner/videos/extract.rb +2 -2
  7. data/lib/ehbrs/tools/runner/videos/languages/file_runner.rb +1 -1
  8. data/lib/ehbrs/tools/runner/videos/languages.rb +1 -1
  9. data/lib/ehbrs/tools/runner/videos/probe.rb +2 -2
  10. data/lib/ehbrs/tools/runner/videos/unsupported.rb +7 -7
  11. data/lib/ehbrs/tools/version.rb +1 -1
  12. metadata +35 -41
  13. data/lib/ehbrs/tools/runner_with/filesystem_renamer.rb +0 -103
  14. data/lib/ehbrs/tools/runner_with.rb +0 -11
  15. data/lib/ehbrs/videos/convert_job.rb +0 -99
  16. data/lib/ehbrs/videos/extract/package.rb +0 -75
  17. data/lib/ehbrs/videos/extract/package_file.rb +0 -53
  18. data/lib/ehbrs/videos/extract.rb +0 -11
  19. data/lib/ehbrs/videos/file.rb +0 -67
  20. data/lib/ehbrs/videos/profiles/base.rb +0 -35
  21. data/lib/ehbrs/videos/profiles/same_quality.rb +0 -21
  22. data/lib/ehbrs/videos/track.rb +0 -20
  23. data/lib/ehbrs/videos/unsupported/check_result.rb +0 -24
  24. data/lib/ehbrs/videos/unsupported/check_set.rb +0 -43
  25. data/lib/ehbrs/videos/unsupported/check_support.rb +0 -71
  26. data/lib/ehbrs/videos/unsupported/checks/codec_extra_unlisted.rb +0 -29
  27. data/lib/ehbrs/videos/unsupported/checks/codec_extra_unsupported.rb +0 -28
  28. data/lib/ehbrs/videos/unsupported/checks/codec_unlisted.rb +0 -25
  29. data/lib/ehbrs/videos/unsupported/checks/codec_unsupported.rb +0 -27
  30. data/lib/ehbrs/videos/unsupported/checks/invalid_extension.rb +0 -27
  31. data/lib/ehbrs/videos/unsupported/checks.rb +0 -13
  32. data/lib/ehbrs/videos/unsupported/file/fix.rb +0 -45
  33. data/lib/ehbrs/videos/unsupported/file.rb +0 -50
  34. data/lib/ehbrs/videos/unsupported/fix_profile.rb +0 -44
  35. data/lib/ehbrs/videos/unsupported/fixes/supported_codec.rb +0 -36
  36. data/lib/ehbrs/videos/unsupported/fixes/supported_container.rb +0 -17
  37. data/lib/ehbrs/videos/unsupported/profiles/aoc.rb +0 -27
  38. data/lib/ehbrs/videos/unsupported/profiles/base.rb +0 -116
  39. data/lib/ehbrs/videos/unsupported/profiles/philco.rb +0 -28
  40. data/lib/ehbrs/videos/unsupported/profiles/samsung.rb +0 -33
  41. data/lib/ehbrs/videos/unsupported/profiles.rb +0 -13
  42. data/lib/ehbrs/videos/unsupported/search.rb +0 -75
  43. data/lib/ehbrs/videos/unsupported/track.rb +0 -32
  44. data/lib/ehbrs/videos.rb +0 -9
@@ -1,43 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'ehbrs/videos/unsupported/checks'
4
-
5
- module Ehbrs
6
- module Videos
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
@@ -1,71 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'ehbrs/videos/unsupported/check_result'
5
-
6
- module Ehbrs
7
- module Videos
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
- ::Ehbrs::Videos::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
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ehbrs
4
- module Videos
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.extra.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
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'ehbrs/videos/unsupported/fixes/supported_codec'
4
-
5
- module Ehbrs
6
- module Videos
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.extra.downcase.include?(extra.downcase)
17
-
18
- "Unsupported extra \"#{extra}\" for codec \"#{codec}\" and track #{track}"
19
- end
20
-
21
- def fix
22
- ::Ehbrs::Videos::Unsupported::Fixes::SupportedCodec.new
23
- end
24
- end
25
- end
26
- end
27
- end
28
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ehbrs
4
- module Videos
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
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'ehbrs/videos/unsupported/fixes/supported_codec'
4
-
5
- module Ehbrs
6
- module Videos
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
- ::Ehbrs::Videos::Unsupported::Fixes::SupportedCodec.new
22
- end
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'ehbrs/videos/unsupported/fixes/supported_container'
4
-
5
- module Ehbrs
6
- module Videos
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
- ::Ehbrs::Videos::Unsupported::Fixes::SupportedContainer.new
22
- end
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
-
5
- module Ehbrs
6
- module Videos
7
- module Unsupported
8
- module Checks
9
- require_sub __FILE__
10
- end
11
- end
12
- end
13
- end
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'ehbrs/videos/convert_job'
4
- require 'ehbrs/videos/file'
5
- require 'ehbrs/videos/unsupported/fix_profile'
6
-
7
- module Ehbrs
8
- module Videos
9
- module Unsupported
10
- class File < ::Ehbrs::Videos::File
11
- module Fix
12
- def check_fix
13
- return unless options.fetch(:fix)
14
-
15
- if fix_blocks.any?
16
- infom ' * Cannot fix:'
17
- fix_blocks.each do |fb|
18
- infom " * #{fb.check.check_name}"
19
- end
20
- else
21
- infom ' * Fixing...'
22
- infom " * Fixed in: \"#{fix}\""
23
- end
24
- end
25
-
26
- private
27
-
28
- def all_fix_blocks_uncached
29
- fix_blocks + tracks.flat_map(&:fix_blocks)
30
- end
31
-
32
- def fix_profile_uncached
33
- ::Ehbrs::Videos::Unsupported::FixProfile.new(self)
34
- end
35
-
36
- def fix
37
- job = ::Ehbrs::Videos::ConvertJob.new(path, fix_profile)
38
- job.run
39
- job.target
40
- end
41
- end
42
- end
43
- end
44
- end
45
- end
@@ -1,50 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'ehbrs/videos/file'
4
- require 'ehbrs/videos/unsupported/file/fix'
5
- require 'ehbrs/videos/unsupported/check_support'
6
- require 'ehbrs/videos/unsupported/track'
7
-
8
- module Ehbrs
9
- module Videos
10
- module Unsupported
11
- class File < ::Ehbrs::Videos::File
12
- include ::Ehbrs::Videos::Unsupported::CheckSupport
13
- include ::Ehbrs::Videos::Unsupported::File::Fix
14
-
15
- attr_reader :options
16
-
17
- def initialize(file, options)
18
- super file
19
- @options = options
20
- end
21
-
22
- def banner
23
- infov 'File', path
24
- pad_speaker do
25
- aggressions_banner('Self')
26
- tracks.each(&:banner)
27
- end
28
- end
29
-
30
- def all_passed?
31
- passed? && tracks.all?(&:passed?)
32
- end
33
-
34
- def all_fixes
35
- fixes + tracks.flat_map(&:fixes)
36
- end
37
-
38
- def check_set_key
39
- :file_check_set
40
- end
41
-
42
- private
43
-
44
- def tracks_uncached
45
- super.map { |t| ::Ehbrs::Videos::Unsupported::Track.new(self, t) }
46
- end
47
- end
48
- end
49
- end
50
- end
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'ehbrs/videos/profiles/same_quality'
4
- require 'ehbrs/videos/unsupported/fixes/supported_container'
5
-
6
- module Ehbrs
7
- module Videos
8
- module Unsupported
9
- class FixProfile
10
- include ::Ehbrs::Videos::Profiles::SameQuality
11
-
12
- common_constructor :video
13
- set_callback :swap, :after do
14
- video.all_fixes.each do |fix|
15
- next unless fix.respond_to?(:after_swap)
16
-
17
- fix.after_swap(self)
18
- end
19
- end
20
-
21
- def name
22
- "fix_for_#{::File.basename(video.file)}"
23
- end
24
-
25
- def ffmpeg_args
26
- r = fix_args
27
- r += container_fix_args unless r.include?('-f')
28
- r + super
29
- end
30
-
31
- private
32
-
33
- def fix_args
34
- ['-c', 'copy'] + video.ffmpeg_fix_args +
35
- video.tracks.flat_map(&:ffmpeg_fix_args)
36
- end
37
-
38
- def container_fix_args
39
- ['-f', ::Ehbrs::Videos::Unsupported::Fixes::SupportedContainer::FIX_FORMAT]
40
- end
41
- end
42
- end
43
- end
44
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ehbrs
4
- module Videos
5
- module Unsupported
6
- module Fixes
7
- class SupportedCodec
8
- TRACK_TYPE_OPTIONS = {
9
- audio: '-acodec',
10
- video: '-vcodec',
11
- subtitle: '-scodec'
12
- }.freeze
13
-
14
- TRACK_TYPE_FIX_CODECS = {
15
- audio: 'aac',
16
- video: 'libx264',
17
- subtitle: 'ass'
18
- }.freeze
19
-
20
- def ffmpeg_args(track)
21
- ["#{track_codec_option_by_type(track.codec_type)}:#{track.index}",
22
- track_codec_fix_by_type(track.codec_type)]
23
- end
24
-
25
- def track_codec_option_by_type(track_type)
26
- TRACK_TYPE_OPTIONS.fetch(track_type.to_s.underscore.to_sym)
27
- end
28
-
29
- def track_codec_fix_by_type(track_type)
30
- TRACK_TYPE_FIX_CODECS.fetch(track_type.to_s.underscore.to_sym)
31
- end
32
- end
33
- end
34
- end
35
- end
36
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ehbrs
4
- module Videos
5
- module Unsupported
6
- module Fixes
7
- class SupportedContainer
8
- FIX_FORMAT = 'matroska'
9
-
10
- def ffmpeg_args(_video)
11
- ['-f', FIX_FORMAT]
12
- end
13
- end
14
- end
15
- end
16
- end
17
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'ehbrs/videos/unsupported/profiles/base'
4
-
5
- module Ehbrs
6
- module Videos
7
- module Unsupported
8
- module Profiles
9
- class Aoc < ::Ehbrs::Videos::Unsupported::Profiles::Base
10
- AUDIO_SUPPORTED_CODECS = %w[aac ac3 mp2 mp3].freeze
11
- AUDIO_UNSUPPORTED_CODECS = %w[eac3 vorbis].freeze
12
-
13
- VIDEO_SUPPORTED_CODECS = %w[h264 mpeg4].freeze
14
- VIDEO_UNSUPPORTED_CODECS = %w[hevc].freeze
15
-
16
- SUBTITLE_SUPPORTED_CODECS = %w[ass dvd_subtitle hdmv_pgs_subtitle subrip].freeze
17
- SUBTITLE_UNSUPPORTED_CODECS = %w[mov_text].freeze
18
-
19
- OTHER_SUPPORTED_CODECS = %w[].freeze
20
-
21
- MPEG4_EXTRA_SUPPORTED = %w[xvid].freeze
22
- MPEG4_EXTRA_UNSUPPORTED = %w[].freeze
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,116 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ehbrs
4
- module Videos
5
- module Unsupported
6
- module Profiles
7
- class Base
8
- enable_simple_cache
9
- include ::Singleton
10
-
11
- CONSTANT_PREFIXES = %w[video audio subtitle other].freeze
12
-
13
- def added_checks
14
- @added_checks ||= []
15
- end
16
-
17
- def add_check(name, *args)
18
- check_path = "ehbrs/videos/unsupported/checks/#{name}"
19
- added_checks << check_path.camelize.constantize.new(*args)
20
- end
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
-
31
- def file_checks
32
- checks.select { |c| check_type(c) == :container }
33
- end
34
-
35
- def track_checks
36
- checks.select { |c| check_type(c) == :stream }
37
- end
38
-
39
- def codec_extra_checks(codec)
40
- codec_unlisted_extra_check(codec).if_present([]) { |v| [v] } +
41
- codec_unsupported_extras(codec).map do |extra|
42
- Ehbrs::Videos::Unsupported::Checks::CodecExtraUnsupported.new(codec, extra)
43
- end
44
- end
45
-
46
- def codec_unlisted_extra_check(codec)
47
- extras = codec_unsupported_extras(codec) + codec_supported_extras(codec)
48
- return nil unless extras.any?
49
-
50
- Ehbrs::Videos::Unsupported::Checks::CodecExtraUnlisted.new(
51
- codec, extras.sort.uniq
52
- )
53
- end
54
-
55
- def name
56
- self.class.name.demodulize.underscore
57
- end
58
-
59
- def to_s
60
- name
61
- end
62
-
63
- def unsupported_codec_checks
64
- unsupported_codecs.map do |codec|
65
- Ehbrs::Videos::Unsupported::Checks::CodecUnsupported.new(codec)
66
- end
67
- end
68
-
69
- def unsupported_codecs_uncached
70
- codecs_by_constant('unsupported')
71
- end
72
-
73
- def unlisted_codec_check
74
- ::Ehbrs::Videos::Unsupported::Checks::CodecUnlisted.new(
75
- (supported_codecs + unsupported_codecs).sort.uniq
76
- )
77
- end
78
-
79
- def supported_codecs_uncached
80
- codecs_by_constant('supported')
81
- end
82
-
83
- def codecs_by_constant(middle)
84
- CONSTANT_PREFIXES.inject([]) { |a, e| a + codecs_by_prefix(e, middle) }
85
- end
86
-
87
- def codecs_by_prefix(prefix, middle)
88
- self.class.const_get("#{prefix}_#{middle}_codecs".upcase)
89
- rescue NameError
90
- []
91
- end
92
-
93
- def codec_extras(codec, suffix)
94
- self.class.const_get("#{codec}_extra_#{suffix}".upcase)
95
- rescue NameError
96
- []
97
- end
98
-
99
- def codec_unsupported_extras(codec)
100
- codec_extras(codec, 'unsupported')
101
- end
102
-
103
- def codec_supported_extras(codec)
104
- codec_extras(codec, 'supported')
105
- end
106
-
107
- private
108
-
109
- def check_type(check)
110
- check.class.const_get(:TYPE)
111
- end
112
- end
113
- end
114
- end
115
- end
116
- end
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'ehbrs/videos/unsupported/profiles/base'
4
-
5
- module Ehbrs
6
- module Videos
7
- module Unsupported
8
- module Profiles
9
- class Philco < ::Ehbrs::Videos::Unsupported::Profiles::Base
10
- AUDIO_SUPPORTED_CODECS = %w[aac ac3 eac3 mp3 vorbis wmav2].freeze
11
- AUDIO_UNSUPPORTED_CODECS = %w[dts opus].freeze
12
-
13
- VIDEO_SUPPORTED_CODECS = %w[h264 mpeg4].freeze
14
- VIDEO_UNSUPPORTED_CODECS = %w[hevc msmpeg4v3].freeze
15
-
16
- SUBTITLE_SUPPORTED_CODECS = %w[ass dvd dvd_subtitle hdmv_pgs_subtitle mov_text
17
- subrip].freeze
18
- SUBTITLE_UNSUPPORTED_CODECS = %w[mov].freeze
19
-
20
- OTHER_SUPPORTED_CODECS = %w[png ttf].freeze
21
-
22
- MPEG4_EXTRA_SUPPORTED = %w[xvid].freeze
23
- MPEG4_EXTRA_UNSUPPORTED = %w[divx dx50].freeze
24
- end
25
- end
26
- end
27
- end
28
- end
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'ehbrs/videos/unsupported/checks/invalid_extension'
4
- require 'ehbrs/videos/unsupported/profiles/base'
5
-
6
- module Ehbrs
7
- module Videos
8
- module Unsupported
9
- module Profiles
10
- class Samsung < ::Ehbrs::Videos::Unsupported::Profiles::Base
11
- AUDIO_SUPPORTED_CODECS = %w[aac ac3 eac3 mp3 vorbis].freeze
12
- AUDIO_UNSUPPORTED_CODECS = %w[dts].freeze
13
-
14
- VIDEO_SUPPORTED_CODECS = %w[h264 mpeg4 hevc mjpeg].freeze
15
- VIDEO_UNSUPPORTED_CODECS = %w[].freeze
16
-
17
- SUBTITLE_SUPPORTED_CODECS = %w[ass dvd dvd_subtitle hdmv_pgs_subtitle subrip].freeze
18
- SUBTITLE_UNSUPPORTED_CODECS = %w[mov mov_text].freeze
19
-
20
- OTHER_SUPPORTED_CODECS = %w[png ttf].freeze
21
-
22
- MPEG4_EXTRA_SUPPORTED = %w[].freeze
23
- MPEG4_EXTRA_UNSUPPORTED = %w[dx50 xvid].freeze
24
-
25
- def initialize
26
- super()
27
- add_check('invalid_extension', '.m4v')
28
- end
29
- end
30
- end
31
- end
32
- end
33
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
-
5
- module Ehbrs
6
- module Videos
7
- module Unsupported
8
- module Profiles
9
- require_sub __FILE__
10
- end
11
- end
12
- end
13
- end