ehbrs-tools 0.30.0 → 0.31.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.
- checksums.yaml +4 -4
- data/Gemfile.lock +27 -27
- data/lib/ehbrs/tools/runner/videos/series/rename.rb +7 -6
- data/lib/ehbrs/tools/version.rb +1 -1
- data/lib/ehbrs/user_dirs.rb +2 -2
- data/lib/ehbrs/videos/unsupported/profiles/samsung.rb +3 -3
- data/spec/lib/ehbrs/tools/runner/fs/used_space_spec.rb +2 -2
- metadata +4 -20
- data/lib/ehbrs/videos/series/rename/directory_group.rb +0 -28
- data/lib/ehbrs/videos/series/rename/file/basename_parser.rb +0 -44
- data/lib/ehbrs/videos/series/rename/file/options.rb +0 -20
- data/lib/ehbrs/videos/series/rename/file.rb +0 -114
- data/lib/ehbrs/videos/series/rename/line_result.rb +0 -26
- data/lib/ehbrs/videos/series/rename/line_result_group.rb +0 -39
- data/lib/ehbrs/videos/series/rename/results_builder.rb +0 -32
- data/lib/ehbrs/videos/series/rename/season_group.rb +0 -39
- data/lib/ehbrs/videos/series/rename.rb +0 -13
- data/lib/ehbrs/videos/series.rb +0 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 589c932bbcf85353d65fe4765634dc887e100962c0c7dfed26d76cf48ffbdc81
|
|
4
|
+
data.tar.gz: f9b16e308f0839eaf966a760d04fc63719e187c941babeb06b33ef8074bc8ecd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8fa7822a45d5343ea664fcebb4323226733aa48d27a8b35602d16b9496435021e0860b51b08ab0cbac70ccb7de30364c23734176b2fe8599642eccb24b158969
|
|
7
|
+
data.tar.gz: a10e2b0cca4ea7993255d896014557d388c20039e497d689737f11e90bd7f84f6a04e480300dcda5f4b2706ad0562542a1c51f549a24c5a425f5699baf95ede5
|
data/Gemfile.lock
CHANGED
|
@@ -7,11 +7,11 @@ GIT
|
|
|
7
7
|
PATH
|
|
8
8
|
remote: .
|
|
9
9
|
specs:
|
|
10
|
-
ehbrs-tools (0.
|
|
10
|
+
ehbrs-tools (0.31.0)
|
|
11
11
|
avm-tools (~> 0.82, >= 0.82.1)
|
|
12
12
|
eac_cli (~> 0.12, >= 0.12.5)
|
|
13
13
|
eac_ruby_utils (~> 0.71)
|
|
14
|
-
ehbrs_ruby_utils (~> 0.
|
|
14
|
+
ehbrs_ruby_utils (~> 0.17)
|
|
15
15
|
filesize
|
|
16
16
|
inifile (~> 3.0)
|
|
17
17
|
os
|
|
@@ -40,7 +40,7 @@ PATH
|
|
|
40
40
|
PATH
|
|
41
41
|
remote: sub/eac_cli
|
|
42
42
|
specs:
|
|
43
|
-
eac_cli (0.26.
|
|
43
|
+
eac_cli (0.26.2)
|
|
44
44
|
colorize (~> 0.8.1)
|
|
45
45
|
eac_config (~> 0.8)
|
|
46
46
|
eac_ruby_utils (~> 0.83)
|
|
@@ -62,7 +62,7 @@ PATH
|
|
|
62
62
|
PATH
|
|
63
63
|
remote: sub/eac_fs
|
|
64
64
|
specs:
|
|
65
|
-
eac_fs (0.
|
|
65
|
+
eac_fs (0.11.1)
|
|
66
66
|
content-type
|
|
67
67
|
eac_ruby_utils (~> 0.70)
|
|
68
68
|
ruby-filemagic
|
|
@@ -70,9 +70,9 @@ PATH
|
|
|
70
70
|
PATH
|
|
71
71
|
remote: sub/eac_ruby_base0
|
|
72
72
|
specs:
|
|
73
|
-
eac_ruby_base0 (0.
|
|
73
|
+
eac_ruby_base0 (0.16.1)
|
|
74
74
|
eac_cli (~> 0.26)
|
|
75
|
-
eac_fs (~> 0.
|
|
75
|
+
eac_fs (~> 0.10)
|
|
76
76
|
eac_ruby_gems_utils (~> 0.9.6, ~> 0.9)
|
|
77
77
|
eac_ruby_utils (~> 0.70)
|
|
78
78
|
|
|
@@ -87,7 +87,7 @@ PATH
|
|
|
87
87
|
PATH
|
|
88
88
|
remote: sub/eac_ruby_utils
|
|
89
89
|
specs:
|
|
90
|
-
eac_ruby_utils (0.
|
|
90
|
+
eac_ruby_utils (0.87.0)
|
|
91
91
|
activesupport (>= 4, < 7)
|
|
92
92
|
addressable (~> 2.6)
|
|
93
93
|
filesize
|
|
@@ -103,10 +103,10 @@ PATH
|
|
|
103
103
|
PATH
|
|
104
104
|
remote: sub/ehbrs_ruby_utils
|
|
105
105
|
specs:
|
|
106
|
-
ehbrs_ruby_utils (0.
|
|
106
|
+
ehbrs_ruby_utils (0.17.0)
|
|
107
107
|
aranha-parsers (~> 0.8, >= 0.8.5)
|
|
108
108
|
avm (~> 0.3, >= 0.3.2)
|
|
109
|
-
eac_fs (~> 0.
|
|
109
|
+
eac_fs (~> 0.10)
|
|
110
110
|
eac_ruby_utils (~> 0.70)
|
|
111
111
|
eac_templates (~> 0.1, >= 0.1.1)
|
|
112
112
|
taglib-ruby (~> 1.1)
|
|
@@ -122,7 +122,7 @@ PATH
|
|
|
122
122
|
GEM
|
|
123
123
|
remote: https://rubygems.org/
|
|
124
124
|
specs:
|
|
125
|
-
activesupport (6.1.4.
|
|
125
|
+
activesupport (6.1.4.6)
|
|
126
126
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
127
127
|
i18n (>= 1.6, < 2)
|
|
128
128
|
minitest (>= 5.1)
|
|
@@ -186,11 +186,11 @@ GEM
|
|
|
186
186
|
eac_fs (~> 0.5)
|
|
187
187
|
eac_ruby_utils (~> 0.76)
|
|
188
188
|
eac_templates (~> 0.2)
|
|
189
|
-
avm-git (0.3.
|
|
189
|
+
avm-git (0.3.2)
|
|
190
190
|
avm-files (~> 0.1)
|
|
191
191
|
eac_git (~> 0.11)
|
|
192
192
|
eac_ruby_utils (~> 0.76)
|
|
193
|
-
avm-tools (0.
|
|
193
|
+
avm-tools (0.114.0)
|
|
194
194
|
aranha-parsers (~> 0.4)
|
|
195
195
|
avm (~> 0.13)
|
|
196
196
|
avm-eac_asciidoctor_base0
|
|
@@ -223,7 +223,7 @@ GEM
|
|
|
223
223
|
thread_safe (~> 0.3, >= 0.3.1)
|
|
224
224
|
diff-lcs (1.5.0)
|
|
225
225
|
dry-inflector (0.2.1)
|
|
226
|
-
eac_git (0.
|
|
226
|
+
eac_git (0.12.0)
|
|
227
227
|
eac_ruby_utils (~> 0.83)
|
|
228
228
|
parseconfig (~> 1.0, >= 1.0.8)
|
|
229
229
|
eac_ruby_gem_support (0.5.0)
|
|
@@ -262,7 +262,7 @@ GEM
|
|
|
262
262
|
rchardet (~> 1.8)
|
|
263
263
|
hpricot (0.8.6)
|
|
264
264
|
htmlbeautifier (1.4.1)
|
|
265
|
-
i18n (1.
|
|
265
|
+
i18n (1.9.1)
|
|
266
266
|
concurrent-ruby (~> 1.0)
|
|
267
267
|
ice_nine (0.11.2)
|
|
268
268
|
inifile (3.0.0)
|
|
@@ -287,20 +287,20 @@ GEM
|
|
|
287
287
|
rainbow (3.1.1)
|
|
288
288
|
rchardet (1.8.0)
|
|
289
289
|
rexml (3.2.5)
|
|
290
|
-
rouge (3.
|
|
291
|
-
rspec (3.
|
|
292
|
-
rspec-core (~> 3.
|
|
293
|
-
rspec-expectations (~> 3.
|
|
294
|
-
rspec-mocks (~> 3.
|
|
295
|
-
rspec-core (3.
|
|
296
|
-
rspec-support (~> 3.
|
|
297
|
-
rspec-expectations (3.
|
|
290
|
+
rouge (3.28.0)
|
|
291
|
+
rspec (3.11.0)
|
|
292
|
+
rspec-core (~> 3.11.0)
|
|
293
|
+
rspec-expectations (~> 3.11.0)
|
|
294
|
+
rspec-mocks (~> 3.11.0)
|
|
295
|
+
rspec-core (3.11.0)
|
|
296
|
+
rspec-support (~> 3.11.0)
|
|
297
|
+
rspec-expectations (3.11.0)
|
|
298
298
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
299
|
-
rspec-support (~> 3.
|
|
300
|
-
rspec-mocks (3.
|
|
299
|
+
rspec-support (~> 3.11.0)
|
|
300
|
+
rspec-mocks (3.11.0)
|
|
301
301
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
302
|
-
rspec-support (~> 3.
|
|
303
|
-
rspec-support (3.
|
|
302
|
+
rspec-support (~> 3.11.0)
|
|
303
|
+
rspec-support (3.11.0)
|
|
304
304
|
rubocop (0.80.1)
|
|
305
305
|
jaro_winkler (~> 1.5.1)
|
|
306
306
|
parallel (~> 1.10)
|
|
@@ -334,7 +334,7 @@ GEM
|
|
|
334
334
|
axiom-types (~> 0.1)
|
|
335
335
|
coercible (~> 1.0)
|
|
336
336
|
descendants_tracker (~> 0.0, >= 0.0.3)
|
|
337
|
-
zeitwerk (2.5.
|
|
337
|
+
zeitwerk (2.5.4)
|
|
338
338
|
|
|
339
339
|
PLATFORMS
|
|
340
340
|
x86_64-linux
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'eac_cli/core_ext'
|
|
4
|
-
require '
|
|
5
|
-
require '
|
|
6
|
-
require '
|
|
4
|
+
require 'ehbrs_ruby_utils/videos/series/rename/file'
|
|
5
|
+
require 'ehbrs_ruby_utils/videos/series/rename/file/options'
|
|
6
|
+
require 'ehbrs_ruby_utils/videos/series/rename/results_builder'
|
|
7
7
|
|
|
8
8
|
module Ehbrs
|
|
9
9
|
module Tools
|
|
@@ -49,15 +49,16 @@ module Ehbrs
|
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
def traverser_check_file(path)
|
|
52
|
-
@files << ::
|
|
52
|
+
@files << ::EhbrsRubyUtils::Videos::Series::Rename::File
|
|
53
|
+
.new(path, series_file_options)
|
|
53
54
|
end
|
|
54
55
|
|
|
55
56
|
def series_file_options_uncached
|
|
56
|
-
::
|
|
57
|
+
::EhbrsRubyUtils::Videos::Series::Rename::File::Options.new(parsed)
|
|
57
58
|
end
|
|
58
59
|
|
|
59
60
|
def show_results
|
|
60
|
-
::
|
|
61
|
+
::EhbrsRubyUtils::Videos::Series::Rename::ResultsBuilder.new(files).show(0)
|
|
61
62
|
end
|
|
62
63
|
|
|
63
64
|
def rename_files
|
data/lib/ehbrs/tools/version.rb
CHANGED
data/lib/ehbrs/user_dirs.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'eac_fs/
|
|
3
|
+
require 'eac_fs/storage_tree'
|
|
4
4
|
require 'eac_ruby_utils/simple_cache'
|
|
5
5
|
|
|
6
6
|
module Ehbrs
|
|
@@ -15,7 +15,7 @@ module Ehbrs
|
|
|
15
15
|
private
|
|
16
16
|
|
|
17
17
|
def user_home_dir_uncached
|
|
18
|
-
::EacFs::
|
|
18
|
+
::EacFs::StorageTree.new(ENV['HOME'])
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def cache_uncached
|
|
@@ -11,11 +11,11 @@ module Ehbrs
|
|
|
11
11
|
AUDIO_SUPPORTED_CODECS = %w[aac ac3 eac3 mp3 vorbis].freeze
|
|
12
12
|
AUDIO_UNSUPPORTED_CODECS = %w[dts].freeze
|
|
13
13
|
|
|
14
|
-
VIDEO_SUPPORTED_CODECS = %w[h264 mpeg4 hevc].freeze
|
|
14
|
+
VIDEO_SUPPORTED_CODECS = %w[h264 mpeg4 hevc mjpeg].freeze
|
|
15
15
|
VIDEO_UNSUPPORTED_CODECS = %w[].freeze
|
|
16
16
|
|
|
17
|
-
SUBTITLE_SUPPORTED_CODECS = %w[ass dvd subrip].freeze
|
|
18
|
-
SUBTITLE_UNSUPPORTED_CODECS = %w[mov].freeze
|
|
17
|
+
SUBTITLE_SUPPORTED_CODECS = %w[ass dvd dvd_subtitle hdmv_pgs_subtitle subrip].freeze
|
|
18
|
+
SUBTITLE_UNSUPPORTED_CODECS = %w[mov mov_text].freeze
|
|
19
19
|
|
|
20
20
|
OTHER_SUPPORTED_CODECS = %w[png ttf].freeze
|
|
21
21
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'eac_fs/
|
|
3
|
+
require 'eac_fs/storage_tree'
|
|
4
4
|
require 'eac_ruby_utils/fs/temp'
|
|
5
5
|
require 'ehbrs/tools/runner'
|
|
6
6
|
require 'ehbrs/tools/runner/fs/used_space'
|
|
@@ -9,7 +9,7 @@ require 'ehbrs/observers/with_persistence'
|
|
|
9
9
|
RSpec.describe ::Ehbrs::Tools::Runner::Fs::UsedSpace do
|
|
10
10
|
let(:target) { ::EacRubyUtils::Fs::Temp.directory }
|
|
11
11
|
let(:user_dir) { ::EacRubyUtils::Fs::Temp.directory }
|
|
12
|
-
let(:cached_user_dir) { ::EacFs::
|
|
12
|
+
let(:cached_user_dir) { ::EacFs::StorageTree.new(user_dir) }
|
|
13
13
|
let(:observers_user_dir) { cached_user_dir.child('observers') }
|
|
14
14
|
let(:observer_path) do
|
|
15
15
|
observers_user_dir.child(target.to_s.parameterize).content_path.to_pathname
|
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.
|
|
4
|
+
version: 0.31.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: 2022-
|
|
11
|
+
date: 2022-02-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: avm-tools
|
|
@@ -70,20 +70,14 @@ dependencies:
|
|
|
70
70
|
requirements:
|
|
71
71
|
- - "~>"
|
|
72
72
|
- !ruby/object:Gem::Version
|
|
73
|
-
version: '0.
|
|
74
|
-
- - ">="
|
|
75
|
-
- !ruby/object:Gem::Version
|
|
76
|
-
version: 0.8.1
|
|
73
|
+
version: '0.17'
|
|
77
74
|
type: :runtime
|
|
78
75
|
prerelease: false
|
|
79
76
|
version_requirements: !ruby/object:Gem::Requirement
|
|
80
77
|
requirements:
|
|
81
78
|
- - "~>"
|
|
82
79
|
- !ruby/object:Gem::Version
|
|
83
|
-
version: '0.
|
|
84
|
-
- - ">="
|
|
85
|
-
- !ruby/object:Gem::Version
|
|
86
|
-
version: 0.8.1
|
|
80
|
+
version: '0.17'
|
|
87
81
|
- !ruby/object:Gem::Dependency
|
|
88
82
|
name: filesize
|
|
89
83
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -252,16 +246,6 @@ files:
|
|
|
252
246
|
- lib/ehbrs/videos/file.rb
|
|
253
247
|
- lib/ehbrs/videos/profiles/base.rb
|
|
254
248
|
- lib/ehbrs/videos/profiles/same_quality.rb
|
|
255
|
-
- lib/ehbrs/videos/series.rb
|
|
256
|
-
- lib/ehbrs/videos/series/rename.rb
|
|
257
|
-
- lib/ehbrs/videos/series/rename/directory_group.rb
|
|
258
|
-
- lib/ehbrs/videos/series/rename/file.rb
|
|
259
|
-
- lib/ehbrs/videos/series/rename/file/basename_parser.rb
|
|
260
|
-
- lib/ehbrs/videos/series/rename/file/options.rb
|
|
261
|
-
- lib/ehbrs/videos/series/rename/line_result.rb
|
|
262
|
-
- lib/ehbrs/videos/series/rename/line_result_group.rb
|
|
263
|
-
- lib/ehbrs/videos/series/rename/results_builder.rb
|
|
264
|
-
- lib/ehbrs/videos/series/rename/season_group.rb
|
|
265
249
|
- lib/ehbrs/videos/track.rb
|
|
266
250
|
- lib/ehbrs/videos/unsupported/check_result.rb
|
|
267
251
|
- lib/ehbrs/videos/unsupported/check_set.rb
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'ehbrs/videos/series/rename/line_result_group'
|
|
4
|
-
require 'ehbrs/videos/series/rename/season_group'
|
|
5
|
-
|
|
6
|
-
module Ehbrs
|
|
7
|
-
module Videos
|
|
8
|
-
module Series
|
|
9
|
-
module Rename
|
|
10
|
-
class DirectoryGroup < LineResultGroup
|
|
11
|
-
def line_out
|
|
12
|
-
name.light_yellow
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
protected
|
|
16
|
-
|
|
17
|
-
def child_key
|
|
18
|
-
:season
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def child_class
|
|
22
|
-
::Ehbrs::Videos::Series::Rename::SeasonGroup
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'ehbrs/videos/series/rename/line_result'
|
|
4
|
-
|
|
5
|
-
module Ehbrs
|
|
6
|
-
module Videos
|
|
7
|
-
module Series
|
|
8
|
-
module Rename
|
|
9
|
-
class File < ::Ehbrs::Videos::Series::Rename::LineResult
|
|
10
|
-
module BasenameParser
|
|
11
|
-
FORMATS = [{
|
|
12
|
-
format: /(\d+)(\d{2})(\d{2})/i,
|
|
13
|
-
build: ->(m) { { s: padding(m[1]), e: padding(m[2]) + '-' + padding(m[3]) } }
|
|
14
|
-
}, {
|
|
15
|
-
format: /s(\d+)e(\d+)-(\d+)/i,
|
|
16
|
-
build: ->(m) { { s: padding(m[1]), e: padding(m[2]) + '-' + padding(m[3]) } }
|
|
17
|
-
}, {
|
|
18
|
-
format: /(\d{1,2})\s*[^\d]\s*(\d{2})/i,
|
|
19
|
-
build: ->(m) { { s: padding(m[1]), e: padding(m[2]) } }
|
|
20
|
-
}, {
|
|
21
|
-
format: /(\d+)(\d{2})/i,
|
|
22
|
-
build: ->(m) { { s: padding(m[1]), e: padding(m[2]) } }
|
|
23
|
-
}, {
|
|
24
|
-
format: /(\d{2})/i,
|
|
25
|
-
build: ->(m) { { s: padding(1), e: padding(m[1]) } }
|
|
26
|
-
}].freeze
|
|
27
|
-
|
|
28
|
-
def self.padding(string)
|
|
29
|
-
string.to_s.rjust(2, '0')
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def parse_uncached
|
|
33
|
-
FORMATS.each do |format|
|
|
34
|
-
m = format.fetch(:format).match(current_name)
|
|
35
|
-
return format.fetch(:build).call(m) if m
|
|
36
|
-
end
|
|
37
|
-
nil
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Ehbrs
|
|
4
|
-
module Videos
|
|
5
|
-
module Series
|
|
6
|
-
module Rename
|
|
7
|
-
class File
|
|
8
|
-
class Options
|
|
9
|
-
common_constructor :options
|
|
10
|
-
delegate :kernel, :confirm, :recursive, :extension, to: :options
|
|
11
|
-
|
|
12
|
-
def episode_increment
|
|
13
|
-
options.episode_increment.if_present(0, &:to_i)
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'eac_ruby_utils/fs/extname'
|
|
4
|
-
require 'ostruct'
|
|
5
|
-
require_relative 'line_result'
|
|
6
|
-
require_relative 'file/basename_parser'
|
|
7
|
-
|
|
8
|
-
module Ehbrs
|
|
9
|
-
module Videos
|
|
10
|
-
module Series
|
|
11
|
-
module Rename
|
|
12
|
-
class File < ::Ehbrs::Videos::Series::Rename::LineResult
|
|
13
|
-
include ::Ehbrs::Videos::Series::Rename::File::BasenameParser
|
|
14
|
-
|
|
15
|
-
attr_reader :file, :options
|
|
16
|
-
|
|
17
|
-
def initialize(file, options)
|
|
18
|
-
@file = file
|
|
19
|
-
@options = options
|
|
20
|
-
@options = ::OpenStruct.new(options) if options.is_a?(::Hash)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def rename
|
|
24
|
-
target = ::File.expand_path(new_name, dirname)
|
|
25
|
-
return if ::File.exist?(target)
|
|
26
|
-
|
|
27
|
-
infov 'Renaming', @file
|
|
28
|
-
FileUtils.mv(@file, target)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def season
|
|
32
|
-
return '??' if parse.blank?
|
|
33
|
-
|
|
34
|
-
parse.fetch(:s)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def episode
|
|
38
|
-
return '??' if parse.blank?
|
|
39
|
-
|
|
40
|
-
parse.fetch(:e)
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def dirname
|
|
44
|
-
d = @file
|
|
45
|
-
while d != '/'
|
|
46
|
-
d = ::File.dirname(d)
|
|
47
|
-
return ::File.expand_path(d) + '/' unless ::File.basename(d).starts_with?('_')
|
|
48
|
-
end
|
|
49
|
-
raise "series_dirname not found for #{@file}"
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def line_out
|
|
53
|
-
"#{episode.green}: " + if new_name == current_name
|
|
54
|
-
current_name.light_black
|
|
55
|
-
else
|
|
56
|
-
"#{new_name} <= #{current_name}"
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def new_name
|
|
61
|
-
return "#{kernel}-s#{parse[:s]}e#{new_name_episodes}#{extension}" if parse.present?
|
|
62
|
-
|
|
63
|
-
current_name
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
private
|
|
67
|
-
|
|
68
|
-
def current_name
|
|
69
|
-
::File.expand_path(@file).gsub(/\A#{::Regexp.quote(dirname)}/, '')
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
def rename?
|
|
73
|
-
return false unless new_name
|
|
74
|
-
|
|
75
|
-
current_name != new_name
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def kernel
|
|
79
|
-
options.kernel || kernel_from_directory_name ||
|
|
80
|
-
raise("Kernel undefined (File: #{@file})")
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
def kernel_from_directory_name
|
|
84
|
-
dir = ::File.basename(dirname).sub(/\([0-9]+\)/, '')
|
|
85
|
-
dir.split(/\W+/).select { |w| /\A[a-z0-9]/.match(w) }.map { |p| p[0].downcase }.join('')
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
def extension
|
|
89
|
-
return options.extension if options.extension
|
|
90
|
-
|
|
91
|
-
extension_by_directory || ::EacRubyUtils::Fs.extname2(current_name)
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
def extension_by_directory
|
|
95
|
-
r = ::File.dirname(current_name)
|
|
96
|
-
return nil if r == '.'
|
|
97
|
-
|
|
98
|
-
r.gsub(/\A_/, '.')
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
def source_episodes
|
|
102
|
-
parse[:e].split('-').map(&:to_i)
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
def new_name_episodes
|
|
106
|
-
source_episodes.map do |i|
|
|
107
|
-
(i + options.episode_increment).to_s.rjust(2, '0')
|
|
108
|
-
end.join('-')
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
end
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'eac_ruby_utils/core_ext'
|
|
4
|
-
|
|
5
|
-
module Ehbrs
|
|
6
|
-
module Videos
|
|
7
|
-
module Series
|
|
8
|
-
module Rename
|
|
9
|
-
class LineResult
|
|
10
|
-
enable_simple_cache
|
|
11
|
-
enable_speaker
|
|
12
|
-
|
|
13
|
-
def show(level)
|
|
14
|
-
out(padding_level(level) + line_out + "\n")
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
private
|
|
18
|
-
|
|
19
|
-
def padding_level(level)
|
|
20
|
-
(' ' * level.to_i) + '* '
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative 'line_result'
|
|
4
|
-
|
|
5
|
-
module Ehbrs
|
|
6
|
-
module Videos
|
|
7
|
-
module Series
|
|
8
|
-
module Rename
|
|
9
|
-
class LineResultGroup < ::Ehbrs::Videos::Series::Rename::LineResult
|
|
10
|
-
attr_reader :name, :children
|
|
11
|
-
|
|
12
|
-
def initialize(name, files)
|
|
13
|
-
@name = name
|
|
14
|
-
@children = build_children(files)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def show(level)
|
|
18
|
-
super(level)
|
|
19
|
-
children.each do |child|
|
|
20
|
-
child.show(level + 1)
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
private
|
|
25
|
-
|
|
26
|
-
def build_children(files)
|
|
27
|
-
r = {}
|
|
28
|
-
files.each do |file|
|
|
29
|
-
key = file.send(child_key)
|
|
30
|
-
r[key] ||= []
|
|
31
|
-
r[key] << file
|
|
32
|
-
end
|
|
33
|
-
r.sort.map { |v| child_class.new(v[0], v[1]) }
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'ehbrs/videos/series/rename/directory_group'
|
|
4
|
-
require 'ehbrs/videos/series/rename/line_result_group'
|
|
5
|
-
|
|
6
|
-
module Ehbrs
|
|
7
|
-
module Videos
|
|
8
|
-
module Series
|
|
9
|
-
module Rename
|
|
10
|
-
class ResultsBuilder < LineResultGroup
|
|
11
|
-
def initialize(files)
|
|
12
|
-
super '', files
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def line_out
|
|
16
|
-
'Groups: '.cyan + children.count.to_s
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
protected
|
|
20
|
-
|
|
21
|
-
def child_key
|
|
22
|
-
:dirname
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def child_class
|
|
26
|
-
::Ehbrs::Videos::Series::Rename::DirectoryGroup
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative 'line_result'
|
|
4
|
-
|
|
5
|
-
module Ehbrs
|
|
6
|
-
module Videos
|
|
7
|
-
module Series
|
|
8
|
-
module Rename
|
|
9
|
-
class SeasonGroup < ::Ehbrs::Videos::Series::Rename::LineResult
|
|
10
|
-
attr_reader :season, :files
|
|
11
|
-
|
|
12
|
-
def initialize(season, files)
|
|
13
|
-
@season = season
|
|
14
|
-
@files = files.sort_by { |f| [f.episode] }
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def line_out
|
|
18
|
-
'Season: '.cyan + "#{season} (#{first_episode} - #{last_episode})"
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def show(level)
|
|
22
|
-
super
|
|
23
|
-
files.each { |file| file.show(level + 1) }
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
private
|
|
27
|
-
|
|
28
|
-
def first_episode
|
|
29
|
-
files.first.episode
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def last_episode
|
|
33
|
-
files.last.episode
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|