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.
- checksums.yaml +4 -4
- data/Gemfile.lock +106 -143
- data/lib/ehbrs/tools/runner/music/lyrics.rb +2 -2
- data/lib/ehbrs/tools/runner/music/lyrics_book.rb +1 -1
- data/lib/ehbrs/tools/runner/music/spread.rb +32 -7
- data/lib/ehbrs/tools/runner/videos/extract.rb +2 -2
- data/lib/ehbrs/tools/runner/videos/languages/file_runner.rb +1 -1
- data/lib/ehbrs/tools/runner/videos/languages.rb +1 -1
- data/lib/ehbrs/tools/runner/videos/probe.rb +2 -2
- data/lib/ehbrs/tools/runner/videos/unsupported.rb +7 -7
- data/lib/ehbrs/tools/version.rb +1 -1
- metadata +35 -41
- data/lib/ehbrs/tools/runner_with/filesystem_renamer.rb +0 -103
- data/lib/ehbrs/tools/runner_with.rb +0 -11
- data/lib/ehbrs/videos/convert_job.rb +0 -99
- data/lib/ehbrs/videos/extract/package.rb +0 -75
- data/lib/ehbrs/videos/extract/package_file.rb +0 -53
- data/lib/ehbrs/videos/extract.rb +0 -11
- data/lib/ehbrs/videos/file.rb +0 -67
- data/lib/ehbrs/videos/profiles/base.rb +0 -35
- data/lib/ehbrs/videos/profiles/same_quality.rb +0 -21
- data/lib/ehbrs/videos/track.rb +0 -20
- data/lib/ehbrs/videos/unsupported/check_result.rb +0 -24
- data/lib/ehbrs/videos/unsupported/check_set.rb +0 -43
- data/lib/ehbrs/videos/unsupported/check_support.rb +0 -71
- data/lib/ehbrs/videos/unsupported/checks/codec_extra_unlisted.rb +0 -29
- data/lib/ehbrs/videos/unsupported/checks/codec_extra_unsupported.rb +0 -28
- data/lib/ehbrs/videos/unsupported/checks/codec_unlisted.rb +0 -25
- data/lib/ehbrs/videos/unsupported/checks/codec_unsupported.rb +0 -27
- data/lib/ehbrs/videos/unsupported/checks/invalid_extension.rb +0 -27
- data/lib/ehbrs/videos/unsupported/checks.rb +0 -13
- data/lib/ehbrs/videos/unsupported/file/fix.rb +0 -45
- data/lib/ehbrs/videos/unsupported/file.rb +0 -50
- data/lib/ehbrs/videos/unsupported/fix_profile.rb +0 -44
- data/lib/ehbrs/videos/unsupported/fixes/supported_codec.rb +0 -36
- data/lib/ehbrs/videos/unsupported/fixes/supported_container.rb +0 -17
- data/lib/ehbrs/videos/unsupported/profiles/aoc.rb +0 -27
- data/lib/ehbrs/videos/unsupported/profiles/base.rb +0 -116
- data/lib/ehbrs/videos/unsupported/profiles/philco.rb +0 -28
- data/lib/ehbrs/videos/unsupported/profiles/samsung.rb +0 -33
- data/lib/ehbrs/videos/unsupported/profiles.rb +0 -13
- data/lib/ehbrs/videos/unsupported/search.rb +0 -75
- data/lib/ehbrs/videos/unsupported/track.rb +0 -32
- data/lib/ehbrs/videos.rb +0 -9
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ehbrs-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.40.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Esquilo Azul Company
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: avm-
|
14
|
+
name: avm-files
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.7'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
26
|
+
version: '0.7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: eac_cli
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -31,6 +31,9 @@ dependencies:
|
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0.40'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 0.40.1
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -38,34 +41,57 @@ dependencies:
|
|
38
41
|
- - "~>"
|
39
42
|
- !ruby/object:Gem::Version
|
40
43
|
version: '0.40'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.40.1
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: eac_ruby_base0
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0.19'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0.19'
|
41
61
|
- !ruby/object:Gem::Dependency
|
42
62
|
name: eac_ruby_utils
|
43
63
|
requirement: !ruby/object:Gem::Requirement
|
44
64
|
requirements:
|
45
65
|
- - "~>"
|
46
66
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0.
|
67
|
+
version: '0.121'
|
48
68
|
type: :runtime
|
49
69
|
prerelease: false
|
50
70
|
version_requirements: !ruby/object:Gem::Requirement
|
51
71
|
requirements:
|
52
72
|
- - "~>"
|
53
73
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0.
|
74
|
+
version: '0.121'
|
55
75
|
- !ruby/object:Gem::Dependency
|
56
76
|
name: ehbrs_ruby_utils
|
57
77
|
requirement: !ruby/object:Gem::Requirement
|
58
78
|
requirements:
|
59
79
|
- - "~>"
|
60
80
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0.
|
81
|
+
version: '0.41'
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: 0.41.2
|
62
85
|
type: :runtime
|
63
86
|
prerelease: false
|
64
87
|
version_requirements: !ruby/object:Gem::Requirement
|
65
88
|
requirements:
|
66
89
|
- - "~>"
|
67
90
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0.
|
91
|
+
version: '0.41'
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 0.41.2
|
69
95
|
- !ruby/object:Gem::Dependency
|
70
96
|
name: filesize
|
71
97
|
requirement: !ruby/object:Gem::Requirement
|
@@ -200,40 +226,8 @@ files:
|
|
200
226
|
- lib/ehbrs/tools/runner/web_utils/videos.rb
|
201
227
|
- lib/ehbrs/tools/runner/web_utils/videos/download.rb
|
202
228
|
- lib/ehbrs/tools/runner/web_utils/videos/upload.rb
|
203
|
-
- lib/ehbrs/tools/runner_with.rb
|
204
|
-
- lib/ehbrs/tools/runner_with/filesystem_renamer.rb
|
205
229
|
- lib/ehbrs/tools/version.rb
|
206
230
|
- lib/ehbrs/user_dirs.rb
|
207
|
-
- lib/ehbrs/videos.rb
|
208
|
-
- lib/ehbrs/videos/convert_job.rb
|
209
|
-
- lib/ehbrs/videos/extract.rb
|
210
|
-
- lib/ehbrs/videos/extract/package.rb
|
211
|
-
- lib/ehbrs/videos/extract/package_file.rb
|
212
|
-
- lib/ehbrs/videos/file.rb
|
213
|
-
- lib/ehbrs/videos/profiles/base.rb
|
214
|
-
- lib/ehbrs/videos/profiles/same_quality.rb
|
215
|
-
- lib/ehbrs/videos/track.rb
|
216
|
-
- lib/ehbrs/videos/unsupported/check_result.rb
|
217
|
-
- lib/ehbrs/videos/unsupported/check_set.rb
|
218
|
-
- lib/ehbrs/videos/unsupported/check_support.rb
|
219
|
-
- lib/ehbrs/videos/unsupported/checks.rb
|
220
|
-
- lib/ehbrs/videos/unsupported/checks/codec_extra_unlisted.rb
|
221
|
-
- lib/ehbrs/videos/unsupported/checks/codec_extra_unsupported.rb
|
222
|
-
- lib/ehbrs/videos/unsupported/checks/codec_unlisted.rb
|
223
|
-
- lib/ehbrs/videos/unsupported/checks/codec_unsupported.rb
|
224
|
-
- lib/ehbrs/videos/unsupported/checks/invalid_extension.rb
|
225
|
-
- lib/ehbrs/videos/unsupported/file.rb
|
226
|
-
- lib/ehbrs/videos/unsupported/file/fix.rb
|
227
|
-
- lib/ehbrs/videos/unsupported/fix_profile.rb
|
228
|
-
- lib/ehbrs/videos/unsupported/fixes/supported_codec.rb
|
229
|
-
- lib/ehbrs/videos/unsupported/fixes/supported_container.rb
|
230
|
-
- lib/ehbrs/videos/unsupported/profiles.rb
|
231
|
-
- lib/ehbrs/videos/unsupported/profiles/aoc.rb
|
232
|
-
- lib/ehbrs/videos/unsupported/profiles/base.rb
|
233
|
-
- lib/ehbrs/videos/unsupported/profiles/philco.rb
|
234
|
-
- lib/ehbrs/videos/unsupported/profiles/samsung.rb
|
235
|
-
- lib/ehbrs/videos/unsupported/search.rb
|
236
|
-
- lib/ehbrs/videos/unsupported/track.rb
|
237
231
|
- template/ehbrs/cooking_book/build/base_page/layout.html.erb
|
238
232
|
- template/ehbrs/cooking_book/build/index_page/inner.html.erb
|
239
233
|
- template/ehbrs/cooking_book/build/recipe_page/inner.html.erb
|
@@ -1,103 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_cli/core_ext'
|
4
|
-
|
5
|
-
module Ehbrs
|
6
|
-
module Tools
|
7
|
-
module RunnerWith
|
8
|
-
module FilesystemRenamer
|
9
|
-
common_concern do
|
10
|
-
runner_with :confirmation, :filesystem_traverser
|
11
|
-
prepend PrependMethods
|
12
|
-
end
|
13
|
-
|
14
|
-
class RenameFile
|
15
|
-
enable_speaker
|
16
|
-
common_constructor :runner, :file
|
17
|
-
delegate :path, :target_path, :valid?, to: :file
|
18
|
-
|
19
|
-
CONFIRM_MESSAGE = 'Rename?'
|
20
|
-
|
21
|
-
def show
|
22
|
-
if rename?
|
23
|
-
puts [target_path_to_s, '<='.green, path_to_s].join(' ')
|
24
|
-
else
|
25
|
-
puts path_to_s
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def rename
|
30
|
-
return unless rename?
|
31
|
-
|
32
|
-
show
|
33
|
-
do_rename if runner.confirm?(CONFIRM_MESSAGE)
|
34
|
-
end
|
35
|
-
|
36
|
-
# @return [Boolean]
|
37
|
-
def rename?
|
38
|
-
path.to_pathname != target_path.to_pathname
|
39
|
-
end
|
40
|
-
|
41
|
-
private
|
42
|
-
|
43
|
-
def do_rename
|
44
|
-
::FileUtils.mv(path, target_path)
|
45
|
-
end
|
46
|
-
|
47
|
-
# @return [String]
|
48
|
-
def path_to_s
|
49
|
-
path.basename.to_path.light_black
|
50
|
-
end
|
51
|
-
|
52
|
-
# @return [String]
|
53
|
-
def target_path_to_s
|
54
|
-
target_path.relative_path_from(path.dirname).to_path
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
module PrependMethods
|
59
|
-
# @param path [Pathname]
|
60
|
-
# @return [void]
|
61
|
-
def traverser_check_file(path)
|
62
|
-
file = RenameFile.new(self, file_class.new(path))
|
63
|
-
files << file if file.valid?
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
FILE_WRAPPER_CLASS_BASENAME = 'FileWrapper'
|
68
|
-
|
69
|
-
# @return [Class]
|
70
|
-
def file_class
|
71
|
-
self.class.const_get(FILE_WRAPPER_CLASS_BASENAME)
|
72
|
-
end
|
73
|
-
|
74
|
-
# @return [void]
|
75
|
-
def run_filesystem_renamer
|
76
|
-
self.files = []
|
77
|
-
run_filesystem_traverser
|
78
|
-
show_files
|
79
|
-
rename_files
|
80
|
-
success 'Done'
|
81
|
-
end
|
82
|
-
|
83
|
-
# @return [void]
|
84
|
-
def show_files
|
85
|
-
infov 'Files found', files.count
|
86
|
-
files.each(&:show)
|
87
|
-
end
|
88
|
-
|
89
|
-
# @return [void]
|
90
|
-
def rename_files
|
91
|
-
return if parsed.no? || files.none?(&:rename?)
|
92
|
-
|
93
|
-
infom 'Renaming files...'
|
94
|
-
files.each(&:rename)
|
95
|
-
end
|
96
|
-
|
97
|
-
private
|
98
|
-
|
99
|
-
attr_accessor :files
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
@@ -1,99 +0,0 @@
|
|
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 Ehbrs
|
8
|
-
module Videos
|
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
|
@@ -1,75 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_ruby_utils/core_ext'
|
4
|
-
require 'ehbrs_ruby_utils/fs/compressed_package'
|
5
|
-
require 'ehbrs/videos/extract/package_file'
|
6
|
-
|
7
|
-
module Ehbrs
|
8
|
-
module Videos
|
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
|
-
::Ehbrs::Videos::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 + [::Ehbrs::Videos::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
|
@@ -1,53 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_ruby_utils/core_ext'
|
4
|
-
|
5
|
-
module Ehbrs
|
6
|
-
module Videos
|
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
|
data/lib/ehbrs/videos/extract.rb
DELETED
data/lib/ehbrs/videos/file.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_ruby_utils/core_ext'
|
4
|
-
require 'ehbrs/videos/track'
|
5
|
-
require 'ehbrs_ruby_utils/executables'
|
6
|
-
require 'ehbrs_ruby_utils/videos/container'
|
7
|
-
|
8
|
-
module Ehbrs
|
9
|
-
module Videos
|
10
|
-
class File < ::EhbrsRubyUtils::Videos::Container
|
11
|
-
enable_simple_cache
|
12
|
-
|
13
|
-
TIME_PATTERN = /(\d+):(\d{2}):(\d{2})(?:\.(\d+))/.freeze
|
14
|
-
|
15
|
-
class << self
|
16
|
-
def seconds_to_time(seconds)
|
17
|
-
t = seconds.floor
|
18
|
-
hmsf_to_time((t / 3600), ((t / 60) % 60), (t % 60), (seconds - t).round(3))
|
19
|
-
end
|
20
|
-
|
21
|
-
def time_to_seconds(time)
|
22
|
-
m = TIME_PATTERN.match(time)
|
23
|
-
raise "Time pattern not find in \"#{time}\"" unless m
|
24
|
-
|
25
|
-
hmsf_to_seconds(m[1], m[2], m[3], m[4])
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def hmsf_to_time(hour, minute, second, float_part)
|
31
|
-
r = [hour, minute, second].map { |y| y.to_s.rjust(2, '0') }
|
32
|
-
r += float_part > 0.0 ? ".#{float_part.to_s.gsub(/\A(0|[^\d])+/, '')}" : '.0'
|
33
|
-
r
|
34
|
-
end
|
35
|
-
|
36
|
-
def hmsf_to_seconds(hour, minute, second, float_part)
|
37
|
-
r = (hour.to_f * 3600) + (minute.to_f * 60) + second.to_f
|
38
|
-
r += float_part.to_f / (10**float_part.length) if float_part
|
39
|
-
r
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
private
|
44
|
-
|
45
|
-
def tracks_uncached
|
46
|
-
streams.map { |stream| ::Ehbrs::Videos::Track.new(stream) }.reject do |t|
|
47
|
-
t.codec_type == ::EhbrsRubyUtils::Videos::Stream::CODEC_TYPE_DATA
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def content_uncached
|
52
|
-
::EhbrsRubyUtils::Executables.ffprobe.command(path).execute!(output: :stderr).scrub
|
53
|
-
end
|
54
|
-
|
55
|
-
def duration_uncached
|
56
|
-
m = /Duration:\s*(#{TIME_PATTERN})/.match(content)
|
57
|
-
raise 'Duration pattern not find in content' unless m
|
58
|
-
|
59
|
-
self.class.time_to_seconds(m[1])
|
60
|
-
end
|
61
|
-
|
62
|
-
def duration_s_uncached
|
63
|
-
self.class.seconds_to_time(duration)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Ehbrs
|
4
|
-
module Videos
|
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
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'ehbrs/videos/profiles/base'
|
4
|
-
|
5
|
-
module Ehbrs
|
6
|
-
module Videos
|
7
|
-
module Profiles
|
8
|
-
module SameQuality
|
9
|
-
extend ::ActiveSupport::Concern
|
10
|
-
|
11
|
-
included do
|
12
|
-
include ::Ehbrs::Videos::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
|
data/lib/ehbrs/videos/track.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_ruby_utils/core_ext'
|
4
|
-
require 'ehbrs_ruby_utils/videos/stream'
|
5
|
-
|
6
|
-
module Ehbrs
|
7
|
-
module Videos
|
8
|
-
class Track < ::SimpleDelegator
|
9
|
-
def extra
|
10
|
-
ffprobe_data.fetch(:codec_tag_string).to_s
|
11
|
-
end
|
12
|
-
|
13
|
-
def to_s
|
14
|
-
"[#{codec_type}(#{index}): #{codec_name}/#{language || '-'}#{extra.if_present('') do |v|
|
15
|
-
" | #{v}"
|
16
|
-
end}]"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,24 +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
|
-
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
|