ehbrs-tools 0.38.0 → 0.39.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +5 -5
  3. data/Gemfile.lock +103 -81
  4. data/exe/ehbrs +1 -1
  5. data/lib/ehbrs/executables.rb +1 -8
  6. data/lib/ehbrs/observers/base.rb +2 -3
  7. data/lib/ehbrs/observers/with_persistence.rb +1 -1
  8. data/lib/ehbrs/tools/runner/finances/bb_browser.rb +2 -2
  9. data/lib/ehbrs/tools/runner/fs/used_space.rb +1 -1
  10. data/lib/ehbrs/tools/runner/google/translate.rb +1 -1
  11. data/lib/ehbrs/tools/runner/music/lyrics.rb +2 -2
  12. data/lib/ehbrs/tools/runner/music/lyrics_book.rb +1 -1
  13. data/lib/ehbrs/tools/runner/vg/ps2/rename.rb +34 -0
  14. data/lib/ehbrs/tools/runner/vg/ps2.rb +19 -0
  15. data/lib/ehbrs/tools/runner/videos/extract.rb +2 -2
  16. data/lib/ehbrs/tools/runner/videos/languages/file_runner.rb +3 -2
  17. data/lib/ehbrs/tools/runner/videos/languages.rb +2 -2
  18. data/lib/ehbrs/tools/runner/videos/probe.rb +2 -2
  19. data/lib/ehbrs/tools/runner/videos/unsupported.rb +7 -7
  20. data/lib/ehbrs/tools/runner/web_utils/videos/upload.rb +1 -1
  21. data/lib/ehbrs/tools/runner_with/filesystem_renamer.rb +103 -0
  22. data/lib/ehbrs/{videos/extract.rb → tools/runner_with.rb} +2 -2
  23. data/lib/ehbrs/tools/version.rb +1 -1
  24. data/lib/ehbrs/user_dirs.rb +1 -1
  25. metadata +16 -75
  26. data/lib/ehbrs/gems.rb +0 -37
  27. data/lib/ehbrs/videos/convert_job.rb +0 -99
  28. data/lib/ehbrs/videos/extract/package.rb +0 -75
  29. data/lib/ehbrs/videos/extract/package_file.rb +0 -53
  30. data/lib/ehbrs/videos/file.rb +0 -67
  31. data/lib/ehbrs/videos/profiles/base.rb +0 -35
  32. data/lib/ehbrs/videos/profiles/same_quality.rb +0 -21
  33. data/lib/ehbrs/videos/track.rb +0 -19
  34. data/lib/ehbrs/videos/unsupported/check_result.rb +0 -24
  35. data/lib/ehbrs/videos/unsupported/check_set.rb +0 -43
  36. data/lib/ehbrs/videos/unsupported/check_support.rb +0 -73
  37. data/lib/ehbrs/videos/unsupported/checks/codec_extra_unlisted.rb +0 -29
  38. data/lib/ehbrs/videos/unsupported/checks/codec_extra_unsupported.rb +0 -28
  39. data/lib/ehbrs/videos/unsupported/checks/codec_unlisted.rb +0 -25
  40. data/lib/ehbrs/videos/unsupported/checks/codec_unsupported.rb +0 -27
  41. data/lib/ehbrs/videos/unsupported/checks/invalid_extension.rb +0 -27
  42. data/lib/ehbrs/videos/unsupported/checks.rb +0 -13
  43. data/lib/ehbrs/videos/unsupported/file/fix.rb +0 -45
  44. data/lib/ehbrs/videos/unsupported/file.rb +0 -50
  45. data/lib/ehbrs/videos/unsupported/fix_profile.rb +0 -44
  46. data/lib/ehbrs/videos/unsupported/fixes/supported_codec.rb +0 -36
  47. data/lib/ehbrs/videos/unsupported/fixes/supported_container.rb +0 -17
  48. data/lib/ehbrs/videos/unsupported/profiles/aoc.rb +0 -27
  49. data/lib/ehbrs/videos/unsupported/profiles/base.rb +0 -116
  50. data/lib/ehbrs/videos/unsupported/profiles/philco.rb +0 -28
  51. data/lib/ehbrs/videos/unsupported/profiles/samsung.rb +0 -33
  52. data/lib/ehbrs/videos/unsupported/profiles.rb +0 -13
  53. data/lib/ehbrs/videos/unsupported/search.rb +0 -75
  54. data/lib/ehbrs/videos/unsupported/track.rb +0 -32
  55. data/lib/ehbrs/videos.rb +0 -9
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_cli/core_ext'
4
- require 'ehbrs/videos/unsupported/check_set'
5
- require 'ehbrs/videos/unsupported/search'
6
- require 'ehbrs/videos/unsupported/profiles'
4
+ require 'ehbrs_ruby_utils/videos2/unsupported/check_set'
5
+ require 'ehbrs_ruby_utils/videos2/unsupported/search'
6
+ require 'ehbrs_ruby_utils/videos2/unsupported/profiles'
7
7
 
8
8
  module Ehbrs
9
9
  module Tools
@@ -23,18 +23,18 @@ module Ehbrs
23
23
  infov 'Profiles', profiles.join(', ')
24
24
  infov 'Paths', paths
25
25
  paths.each do |d|
26
- ::Ehbrs::Videos::Unsupported::Search.new(d, file_options)
26
+ ::EhbrsRubyUtils::Videos2::Unsupported::Search.new(d, file_options)
27
27
  end
28
28
  end
29
29
 
30
30
  private
31
31
 
32
32
  def file_check_set_uncached
33
- ::Ehbrs::Videos::Unsupported::CheckSet.build(profiles, :file)
33
+ ::EhbrsRubyUtils::Videos2::Unsupported::CheckSet.build(profiles, :file)
34
34
  end
35
35
 
36
36
  def track_check_set_uncached
37
- ::Ehbrs::Videos::Unsupported::CheckSet.build(profiles, :track)
37
+ ::EhbrsRubyUtils::Videos2::Unsupported::CheckSet.build(profiles, :track)
38
38
  end
39
39
 
40
40
  def paths
@@ -52,7 +52,7 @@ module Ehbrs
52
52
  end
53
53
 
54
54
  def profile_class(profile_name)
55
- ::Ehbrs::Videos::Unsupported::Profiles.const_get(profile_name.camelize)
55
+ ::EhbrsRubyUtils::Videos2::Unsupported::Profiles.const_get(profile_name.camelize)
56
56
  end
57
57
  end
58
58
  end
@@ -44,7 +44,7 @@ module Ehbrs
44
44
  upload_request(files_list_path).body
45
45
  rescue ::EhbrsRubyUtils::WebUtils::RequestError => e
46
46
  system('firefox', e.body_file_path.to_path)
47
- fatal_error('Retornou com erro: ' + e.message)
47
+ fatal_error("Retornou com erro: #{e.message}")
48
48
  end
49
49
 
50
50
  def series_files_list_uncached
@@ -0,0 +1,103 @@
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
@@ -3,8 +3,8 @@
3
3
  require 'eac_ruby_utils/core_ext'
4
4
 
5
5
  module Ehbrs
6
- module Videos
7
- module Extract
6
+ module Tools
7
+ module RunnerWith
8
8
  require_sub __FILE__
9
9
  end
10
10
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ehbrs
4
4
  module Tools
5
- VERSION = '0.38.0'
5
+ VERSION = '0.39.1'
6
6
  end
7
7
  end
@@ -15,7 +15,7 @@ module Ehbrs
15
15
  private
16
16
 
17
17
  def user_home_dir_uncached
18
- ::EacFs::StorageTree.new(ENV['HOME'])
18
+ ::EacFs::StorageTree.new(Dir.home)
19
19
  end
20
20
 
21
21
  def cache_uncached
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ehbrs-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.38.0
4
+ version: 0.39.1
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: 2023-10-31 00:00:00.000000000 Z
11
+ date: 2024-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avm-tools
@@ -16,68 +16,56 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.156'
19
+ version: '0.159'
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.156'
26
+ version: '0.159'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: eac_cli
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.38'
33
+ version: '0.40'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.38'
40
+ version: '0.40'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: eac_ruby_utils
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.119'
48
- - - ">="
49
- - !ruby/object:Gem::Version
50
- version: 0.119.2
47
+ version: '0.120'
51
48
  type: :runtime
52
49
  prerelease: false
53
50
  version_requirements: !ruby/object:Gem::Requirement
54
51
  requirements:
55
52
  - - "~>"
56
53
  - !ruby/object:Gem::Version
57
- version: '0.119'
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: 0.119.2
54
+ version: '0.120'
61
55
  - !ruby/object:Gem::Dependency
62
56
  name: ehbrs_ruby_utils
63
57
  requirement: !ruby/object:Gem::Requirement
64
58
  requirements:
65
59
  - - "~>"
66
60
  - !ruby/object:Gem::Version
67
- version: '0.36'
68
- - - ">="
69
- - !ruby/object:Gem::Version
70
- version: 0.36.1
61
+ version: '0.41'
71
62
  type: :runtime
72
63
  prerelease: false
73
64
  version_requirements: !ruby/object:Gem::Requirement
74
65
  requirements:
75
66
  - - "~>"
76
67
  - !ruby/object:Gem::Version
77
- version: '0.36'
78
- - - ">="
79
- - !ruby/object:Gem::Version
80
- version: 0.36.1
68
+ version: '0.41'
81
69
  - !ruby/object:Gem::Dependency
82
70
  name: filesize
83
71
  requirement: !ruby/object:Gem::Requirement
@@ -92,20 +80,6 @@ dependencies:
92
80
  - - "~>"
93
81
  - !ruby/object:Gem::Version
94
82
  version: '0.2'
95
- - !ruby/object:Gem::Dependency
96
- name: inifile
97
- requirement: !ruby/object:Gem::Requirement
98
- requirements:
99
- - - "~>"
100
- - !ruby/object:Gem::Version
101
- version: '3.0'
102
- type: :runtime
103
- prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- requirements:
106
- - - "~>"
107
- - !ruby/object:Gem::Version
108
- version: '3.0'
109
83
  - !ruby/object:Gem::Dependency
110
84
  name: os
111
85
  requirement: !ruby/object:Gem::Requirement
@@ -146,20 +120,14 @@ dependencies:
146
120
  requirements:
147
121
  - - "~>"
148
122
  - !ruby/object:Gem::Version
149
- version: '0.8'
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: 0.8.2
123
+ version: '0.9'
153
124
  type: :development
154
125
  prerelease: false
155
126
  version_requirements: !ruby/object:Gem::Requirement
156
127
  requirements:
157
128
  - - "~>"
158
129
  - !ruby/object:Gem::Version
159
- version: '0.8'
160
- - - ">="
161
- - !ruby/object:Gem::Version
162
- version: 0.8.2
130
+ version: '0.9'
163
131
  description:
164
132
  email:
165
133
  executables:
@@ -173,7 +141,6 @@ files:
173
141
  - exe/ehbrs
174
142
  - lib/ehbrs.rb
175
143
  - lib/ehbrs/executables.rb
176
- - lib/ehbrs/gems.rb
177
144
  - lib/ehbrs/google.rb
178
145
  - lib/ehbrs/google/translate.rb
179
146
  - lib/ehbrs/google/translate/session.rb
@@ -209,6 +176,8 @@ files:
209
176
  - lib/ehbrs/tools/runner/telegram/send_message.rb
210
177
  - lib/ehbrs/tools/runner/vg.rb
211
178
  - lib/ehbrs/tools/runner/vg/ips.rb
179
+ - lib/ehbrs/tools/runner/vg/ps2.rb
180
+ - lib/ehbrs/tools/runner/vg/ps2/rename.rb
212
181
  - lib/ehbrs/tools/runner/vg/wii.rb
213
182
  - lib/ehbrs/tools/runner/videos.rb
214
183
  - lib/ehbrs/tools/runner/videos/extract.rb
@@ -231,38 +200,10 @@ files:
231
200
  - lib/ehbrs/tools/runner/web_utils/videos.rb
232
201
  - lib/ehbrs/tools/runner/web_utils/videos/download.rb
233
202
  - 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
234
205
  - lib/ehbrs/tools/version.rb
235
206
  - lib/ehbrs/user_dirs.rb
236
- - lib/ehbrs/videos.rb
237
- - lib/ehbrs/videos/convert_job.rb
238
- - lib/ehbrs/videos/extract.rb
239
- - lib/ehbrs/videos/extract/package.rb
240
- - lib/ehbrs/videos/extract/package_file.rb
241
- - lib/ehbrs/videos/file.rb
242
- - lib/ehbrs/videos/profiles/base.rb
243
- - lib/ehbrs/videos/profiles/same_quality.rb
244
- - lib/ehbrs/videos/track.rb
245
- - lib/ehbrs/videos/unsupported/check_result.rb
246
- - lib/ehbrs/videos/unsupported/check_set.rb
247
- - lib/ehbrs/videos/unsupported/check_support.rb
248
- - lib/ehbrs/videos/unsupported/checks.rb
249
- - lib/ehbrs/videos/unsupported/checks/codec_extra_unlisted.rb
250
- - lib/ehbrs/videos/unsupported/checks/codec_extra_unsupported.rb
251
- - lib/ehbrs/videos/unsupported/checks/codec_unlisted.rb
252
- - lib/ehbrs/videos/unsupported/checks/codec_unsupported.rb
253
- - lib/ehbrs/videos/unsupported/checks/invalid_extension.rb
254
- - lib/ehbrs/videos/unsupported/file.rb
255
- - lib/ehbrs/videos/unsupported/file/fix.rb
256
- - lib/ehbrs/videos/unsupported/fix_profile.rb
257
- - lib/ehbrs/videos/unsupported/fixes/supported_codec.rb
258
- - lib/ehbrs/videos/unsupported/fixes/supported_container.rb
259
- - lib/ehbrs/videos/unsupported/profiles.rb
260
- - lib/ehbrs/videos/unsupported/profiles/aoc.rb
261
- - lib/ehbrs/videos/unsupported/profiles/base.rb
262
- - lib/ehbrs/videos/unsupported/profiles/philco.rb
263
- - lib/ehbrs/videos/unsupported/profiles/samsung.rb
264
- - lib/ehbrs/videos/unsupported/search.rb
265
- - lib/ehbrs/videos/unsupported/track.rb
266
207
  - template/ehbrs/cooking_book/build/base_page/layout.html.erb
267
208
  - template/ehbrs/cooking_book/build/index_page/inner.html.erb
268
209
  - template/ehbrs/cooking_book/build/recipe_page/inner.html.erb
data/lib/ehbrs/gems.rb DELETED
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/eac_ruby_base1/sources/base'
4
-
5
- module Ehbrs
6
- module Gems
7
- class << self
8
- enable_simple_cache
9
-
10
- def app_path
11
- ::Pathname.new('../..').expand_path(__dir__)
12
- end
13
-
14
- def vendor_gems_root
15
- app_path.join('vendor')
16
- end
17
-
18
- private
19
-
20
- def app_uncached
21
- ::Avm::EacRubyBase1::Sources::Base.new(app_path)
22
- end
23
-
24
- def all_uncached
25
- vendor_gems + [app]
26
- end
27
-
28
- def vendor_gems_uncached
29
- r = []
30
- vendor_gems_root.each_child.each do |child|
31
- r << ::EacRubyGemsUtils::Gem.new(child) if child.directory?
32
- end
33
- r
34
- end
35
- end
36
- end
37
- end
@@ -1,99 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'ehbrs/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
- ::Ehbrs::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