Class: Mediaman::CommandLine

Inherits:
Thor
  • Object
show all
Defined in:
lib/mediaman/command.rb

Instance Method Summary collapse

Instance Method Details

#add(path) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/mediaman/command.rb', line 11

def add(path)
  puts "Adding #{File.basename File.expand_path(path)}..."
  library_document = LibraryDocument.from_path path
  library_document.library_path = File.expand_path options[:library]
  puts "Found #{library_document.video_files.size} video files and #{library_document.junk_files.size} junk files."
  library_document.move_to_library!
  library_document.save_and_apply_metadata!
  puts "New location: #{library_document.path}."
  if options[:itunes]
    library_document.add_to_itunes!
    puts "Added to iTunes!"
  end
end

#metadata(path) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/mediaman/command.rb', line 26

def (path)
  path = File.expand_path path
  if !File.exists?(path) && !File.directory?(path)
    name = path
  end
  if name
    doc = Mediaman::TemporaryDocument.from_name(name)
    puts doc..stringify_keys.to_yaml
  else
    doc = Document.from_path(path)
    doc.save_and_apply_metadata!
    puts "Metadata and image saved to #{doc.extras_path}"
  end
end