movie_organizer 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +7 -0
- data/lib/movie_organizer/movie.rb +2 -10
- data/lib/movie_organizer/tv_show.rb +3 -4
- data/lib/movie_organizer/version.rb +1 -1
- data/lib/movie_organizer/video.rb +14 -12
- data/lib/movie_organizer.rb +27 -0
- data/spec/fixtures/.movie_organizer.yml +3 -0
- data/spec/lib/movie_organizer/tv_show_spec.rb +0 -8
- data/spec/lib/movie_organizer/video_spec.rb +45 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7885aa1f3f8cb1095d8710d11f6bbfcb06ae97016b1d068a3380f56f5eea650
|
4
|
+
data.tar.gz: e234282cbc7fcc5bf81406f0f5705041023fa3d14960a46cd3f783a7e9c46f08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bab5fc2431675860b49fb64fd32b4bc8b8dc31bc83a061c93ccfa398eb1423546cdf968dd66abb3a7132b1272be089161da5c13377daa468218a68f636633c93
|
7
|
+
data.tar.gz: a89986894a78352fa1135236b997b7832b3d28a0896c4c6e7a30f8a1dc4589c9d6413471b2617582758485d6e88cc31d6fa0ae14afe876647b85de854f010df8
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
*0.1.8* (March 03, 2018)
|
2
|
+
|
3
|
+
* Prompt for movie directory setting if missing
|
4
|
+
* Prompt for tv show directory setting if missing
|
5
|
+
* Prompt for video directory setting if missing
|
6
|
+
* Actual get home video processing working
|
7
|
+
|
1
8
|
*0.1.7* (March 03, 2018)
|
2
9
|
|
3
10
|
* Prompt for TMDB API key if missing
|
@@ -10,16 +10,8 @@ module MovieOrganizer
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def process!
|
13
|
-
|
14
|
-
|
15
|
-
settings[:movies][:directory],
|
16
|
-
"#{title} (#{year})"
|
17
|
-
)
|
18
|
-
FileUtils.mkdir_p(target_dir, noop: dry_run?)
|
19
|
-
target_file = File.join(
|
20
|
-
target_dir,
|
21
|
-
processed_filename
|
22
|
-
)
|
13
|
+
target_dir = File.join(MovieOrganizer.movie_directory, "#{title} (#{year})")
|
14
|
+
target_file = File.join(target_dir, processed_filename)
|
23
15
|
logger.info(" target dir: [#{target_dir}]")
|
24
16
|
logger.info(" target file: [#{target_file.green.bold}]")
|
25
17
|
fc = FileCopier.new(filename, target_file, options)
|
@@ -17,13 +17,12 @@ module MovieOrganizer
|
|
17
17
|
def process!
|
18
18
|
return nil if should_skip?
|
19
19
|
# rename the file
|
20
|
-
|
20
|
+
raise "Show not configured #{basename}" if title.nil?
|
21
21
|
target_dir = File.join(
|
22
|
-
|
22
|
+
MovieOrganizer.tv_shows_directory,
|
23
23
|
title,
|
24
24
|
"Season #{season.sub(/^0+/, '')}"
|
25
25
|
)
|
26
|
-
FileUtils.mkdir_p(target_dir, noop: dry_run?)
|
27
26
|
target_file = File.join(target_dir, processed_filename)
|
28
27
|
logger.info(" target dir: [#{target_dir}]")
|
29
28
|
logger.info(" target file: [#{target_file.green.bold}]")
|
@@ -33,7 +32,7 @@ module MovieOrganizer
|
|
33
32
|
force: true, noop: dry_run?
|
34
33
|
)
|
35
34
|
rescue ArgumentError => err
|
36
|
-
raise err unless err.message
|
35
|
+
raise err unless err.message =~ /^same file:/
|
37
36
|
end
|
38
37
|
|
39
38
|
# Standardize the filename
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative 'string'
|
4
|
+
|
3
5
|
module MovieOrganizer
|
4
6
|
class Video < Media
|
5
7
|
attr_reader :settings
|
@@ -9,12 +11,12 @@ module MovieOrganizer
|
|
9
11
|
super
|
10
12
|
end
|
11
13
|
|
12
|
-
def process!
|
13
|
-
|
14
|
-
FileUtils.mkdir_p(target_dir, noop: dry_run?)
|
14
|
+
def process!(file_copier = nil)
|
15
|
+
target_file = File.join(target_dir, processed_filename)
|
15
16
|
logger.info(" target dir: [#{target_dir}]")
|
16
17
|
logger.info(" target file: [#{target_file.green.bold}]")
|
17
|
-
|
18
|
+
fc = file_copier || FileCopier.new(filename, target_file, options)
|
19
|
+
fc.copy
|
18
20
|
end
|
19
21
|
|
20
22
|
def processed_filename
|
@@ -23,13 +25,13 @@ module MovieOrganizer
|
|
23
25
|
|
24
26
|
def title
|
25
27
|
@title ||= begin
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
)
|
32
|
-
|
28
|
+
prompt = <<-STRING.here_with_pipe(' ')
|
29
|
+
|Enter a friendly title for this video: [#{basename}]
|
30
|
+
|or hit enter to keep the current title
|
31
|
+
STRING
|
32
|
+
new_title = MovieOrganizer.prompt_for(prompt, '')
|
33
|
+
return File.basename(filename, ext) if new_title.nil? || new_title.empty?
|
34
|
+
new_title
|
33
35
|
end
|
34
36
|
end
|
35
37
|
|
@@ -41,7 +43,7 @@ module MovieOrganizer
|
|
41
43
|
# private
|
42
44
|
|
43
45
|
def target_dir
|
44
|
-
File.join(
|
46
|
+
File.join(MovieOrganizer.video_directory, "#{title} (#{date_time})")
|
45
47
|
end
|
46
48
|
end
|
47
49
|
end
|
data/lib/movie_organizer.rb
CHANGED
@@ -45,6 +45,33 @@ module MovieOrganizer
|
|
45
45
|
settings[:movies][:tmdb_key]
|
46
46
|
end
|
47
47
|
|
48
|
+
def self.movie_directory(settings = Settings.new, test_response = nil)
|
49
|
+
return settings[:movies][:directory] if settings[:movies] && settings[:movies][:directory]
|
50
|
+
settings[:movies] ||= {}
|
51
|
+
settings[:movies][:directory] =
|
52
|
+
prompt_for('Movie destination directory', test_response)
|
53
|
+
settings.save
|
54
|
+
settings[:movies][:directory]
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.tv_shows_directory(settings = Settings.new, test_response = nil)
|
58
|
+
return settings[:tv_shows][:directory] if settings[:tv_shows] && settings[:tv_shows][:directory]
|
59
|
+
settings[:tv_shows] ||= {}
|
60
|
+
settings[:tv_shows][:directory] =
|
61
|
+
prompt_for('TV show destination directory', test_response)
|
62
|
+
settings.save
|
63
|
+
settings[:tv_shows][:directory]
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.video_directory(settings = Settings.new, test_response = nil)
|
67
|
+
return settings[:videos][:directory] if settings[:videos] && settings[:videos][:directory]
|
68
|
+
settings[:videos] ||= {}
|
69
|
+
settings[:videos][:directory] =
|
70
|
+
prompt_for('Video destination directory', test_response)
|
71
|
+
settings.save
|
72
|
+
settings[:videos][:directory]
|
73
|
+
end
|
74
|
+
|
48
75
|
#:nocov:
|
49
76
|
def self.prompt_for(message = '', test_response = nil)
|
50
77
|
prompt = "#{message.dup}\n? "
|
@@ -63,14 +63,6 @@ module MovieOrganizer
|
|
63
63
|
|
64
64
|
context '.process!' do
|
65
65
|
it 'moves the file to the configured location' do
|
66
|
-
settings = Settings.new
|
67
|
-
binding.pry if settings.nil?
|
68
|
-
target_dir = File.join(
|
69
|
-
settings[:tv_shows][:directory],
|
70
|
-
tv_show.title,
|
71
|
-
"Season #{tv_show.season.sub(/^0+/, '')}"
|
72
|
-
)
|
73
|
-
expect(FileUtils).to receive(:mkdir_p).with(target_dir, noop: true).and_return(nil)
|
74
66
|
expect(FileUtils).to receive(:move).and_return(nil)
|
75
67
|
tv_show.process!
|
76
68
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# rubocop:disable Metrics/BlockLength
|
4
|
+
module MovieOrganizer
|
5
|
+
RSpec.describe Video, type: :lib do
|
6
|
+
include_context 'media_shared'
|
7
|
+
|
8
|
+
let(:filename) do
|
9
|
+
create_test_file(
|
10
|
+
filename: 'Vacation in Florida',
|
11
|
+
extension: 'mp4'
|
12
|
+
).first
|
13
|
+
end
|
14
|
+
let(:video) { Video.new(filename, default_options) }
|
15
|
+
|
16
|
+
context '#new' do
|
17
|
+
it 'returns a child of the Media class' do
|
18
|
+
expect(video).to be_a(Media)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'is a Video' do
|
22
|
+
expect(video).to be_a(Video)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'sets filename accessor' do
|
26
|
+
expect(video.filename).to eq(filename)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context '.processed_filename' do
|
31
|
+
it 'returns a string' do
|
32
|
+
expect(video.processed_filename).to be_a(String)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context '.process!' do
|
37
|
+
it 'moves the file to the configured location' do
|
38
|
+
fc = FileCopier.new('/tmp/bogus', '/tmp/bogus2', default_options)
|
39
|
+
expect(fc).to receive(:copy).and_return(nil)
|
40
|
+
video.process!(fc)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
# rubocop:enable Metrics/BlockLength
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: movie_organizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Blackburn
|
@@ -280,6 +280,7 @@ files:
|
|
280
280
|
- spec/lib/movie_organizer/movie_spec.rb
|
281
281
|
- spec/lib/movie_organizer/organizer_spec.rb
|
282
282
|
- spec/lib/movie_organizer/tv_show_spec.rb
|
283
|
+
- spec/lib/movie_organizer/video_spec.rb
|
283
284
|
- spec/lib/movie_organizer_spec.rb
|
284
285
|
- spec/spec_helper.rb
|
285
286
|
- spec/support/filename_mappings.yml
|
@@ -325,6 +326,7 @@ test_files:
|
|
325
326
|
- spec/lib/movie_organizer/movie_spec.rb
|
326
327
|
- spec/lib/movie_organizer/organizer_spec.rb
|
327
328
|
- spec/lib/movie_organizer/tv_show_spec.rb
|
329
|
+
- spec/lib/movie_organizer/video_spec.rb
|
328
330
|
- spec/lib/movie_organizer_spec.rb
|
329
331
|
- spec/spec_helper.rb
|
330
332
|
- spec/support/filename_mappings.yml
|