12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/mediaman/command.rb', line 12
def add(input_path)
if options[:batch] && File.directory?(input_path)
paths = []
Dir.glob File.join(input_path, "*") do |searchfile|
case File.extname(searchfile)[1..-1]
when /mov|mp4|m4v|avi|wmv|mkv/i then
paths << searchfile
else
if File.directory?(searchfile)
paths << searchfile
end
end
end
else
paths = [input_path]
end
if paths.length > 0
puts "Found #{paths.length} supported file#{paths.length == 1 ? "" : "s"}.".yellow
else
puts "No directories or supported files found.".red
end
for path in paths
puts "Adding #{File.basename File.expand_path(path)}".green
library_document = LibraryDocument.from_path path
library_document.library_path = File.expand_path options[:library]
puts " -> #{library_document.video_files.size} video files / #{library_document.junk_files.size} junk files."
library_document.move_to_library!
library_document.save_and_apply_metadata!
puts " -> Destination: #{library_document.path}"
if options[:itunes]
library_document.add_to_itunes!
puts " -> Added to iTunes"
end
end
end
|