mediaman 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,24 +1,91 @@
1
1
  # Mediaman
2
2
 
3
- TODO: Write a gem description
3
+ **Mediaman manages your media, man.**
4
4
 
5
- ## Installation
5
+ Have video files you need to organize? DVD backups or something?
6
6
 
7
- Add this line to your application's Gemfile:
7
+ ## Usage
8
8
 
9
- gem 'mediaman'
9
+ Mediaman comes with a command line interface called, cleverly enough, `mediaman`. There's a few little commands for you.
10
10
 
11
- And then execute:
11
+ #### Add to Library
12
12
 
13
- $ bundle
14
13
 
15
- Or install it yourself as:
14
+ $ mediaman add ~/path/to/movie.mp4
16
15
 
17
- $ gem install mediaman
16
+ This will take the video file at the passed in path and try to organize it into a library directory structure. Mediaman will try to figure out what the video file represents, and if it can, download metadata about the film or television show.
18
17
 
19
- ## Usage
18
+ It does this based on a few simple rules:
19
+
20
+ - Movies
21
+
22
+ If the filename contains text followed by a year, it's assumed to be a movie.
23
+
24
+ For example: `Star Wars (1977)` or `star.wars.1977.stereo`.
25
+
26
+ - TV Shows
27
+
28
+ If the filename contains season and episode number info, it's assumed to be a TV show.
29
+
30
+ For example: `Star Trek The Next Generation S02E03`.
31
+
32
+ - Other Media
33
+
34
+ Anything else is considered "Other Media".
35
+
36
+ Then it will throw it into a pretty folder for you. Like this:
37
+
38
+ ../Movies/Star Wars (1977).mov
39
+
40
+ ../TV Shows/Star Trek - The Next Generation/Season 2/2x03 - Elementary, Dear Data.mov
41
+
42
+ The library root directory is your current directory, or pass in something else with the `-l` flag.
43
+
44
+ If it can, it will add the media's metadata (including artwork) to an `mp4` or `mkv` file using Subler.
45
+
46
+ The artwork image and metadata (in YAML format) will also be saved for your reference in an `Extras` folder in the same directory as the movie file.
47
+
48
+ #### Get Metadata Only
49
+
50
+ To save a sidecar YAML file with as much metadata as Mediaman can muster, just use:
51
+
52
+ $ mediaman metadata ~/path/to/movie.mp4
53
+
54
+ #### Help
55
+
56
+ For more information, try:
57
+
58
+ $ mediaman help
59
+
60
+ ## Configuration
61
+
62
+ To download metadata, we currently use the [Trakt](http://trakt.tv) API, for which you can get a free key [through their website](http://trakt.tv/api-docs/authentication).
63
+
64
+ Mediaman looks for this information in the environment variable `TRAKT_API_KEY`.
65
+
66
+ On systems like OS X, the simplest way to have this stick around is to set this in your `~/.bash_profile` like so:
67
+
68
+ export TRAKT_API_KEY=86f7e437faa5a7fce15d1ddcb9eaeaea377667b8
69
+
70
+ Want another service? Pull request please!
71
+
72
+ ## Requirements
73
+
74
+ - OS X
75
+
76
+ Tested only with OS X 10.8 Mountain Lion (so far).
77
+
78
+ - Ruby 1.9.x
79
+
80
+ This is not the default Ruby shipped with Mountain Lion. You'll have to figure that one out yourself.
81
+
82
+ ## Installation
83
+
84
+ Install as a Ruby gem:
85
+
86
+ $ gem install mediaman
20
87
 
21
- TODO: Write usage instructions here
88
+ Or throw it in your Gemfile and use it directly from Ruby. Your move.
22
89
 
23
90
  ## Contributing
24
91
 
@@ -6,21 +6,20 @@ module Mediaman
6
6
 
7
7
  desc "add <file>", "sorts the file according to its metadata"
8
8
  method_option :library, type: :string, aliases: "-l", desc: "Media library base folder to sort into.", default: "."
9
- method_option :batch, type: :boolean, aliases: "-b", desc: "Adds each file or folder in the passed-in folder to the library.", default: false
9
+ # method_option :batch, type: :boolean, aliases: "-b", desc: "Adds each file or folder in the passed-in folder to the library.", default: false
10
+ method_option :itunes, type: :boolean, desc: "Attempts to add the final file to iTunes.", default: false
10
11
  def add(path)
12
+ puts "Adding #{File.basename File.expand_path(path)}..."
11
13
  library_document = LibraryDocument.from_path path
12
14
  library_document.library_path = File.expand_path options[:library]
13
- # puts "Sidecar path:"
14
- # puts library_document.library_sidecar_path
15
- puts "Video:"
16
- puts library_document.video_files
17
- puts "Junk:"
18
- puts library_document.junk_files
19
- puts "Files to move:"
20
- puts library_document.files_to_move.to_yaml
21
- puts "moving"
15
+ puts "Found #{library_document.video_files.size} video files and #{library_document.junk_files.size} junk files."
22
16
  library_document.move_to_library!
23
17
  library_document.save_and_apply_metadata!
18
+ puts "New location: #{library_document.path}."
19
+ if options[:itunes]
20
+ library_document.add_to_itunes!
21
+ puts "Added to iTunes!"
22
+ end
24
23
  end
25
24
 
26
25
  desc "metadata <file>", "returns all the metadata discoverable about this file or directory"
@@ -33,14 +33,22 @@ module Mediaman
33
33
  end
34
34
 
35
35
  def add_metadata_to_file!
36
- h = metadata.to_subler_hash
37
- h[:artwork] = artwork_path if File.exists?(artwork_path)
38
- puts "Primary: #{primary_video_file}"
39
- puts h.to_s
40
- MiniSubler::Command.vendored.set_metadata primary_video_file, h
36
+ if supports_embedding_video_metadata?
37
+ h = metadata.to_subler_hash
38
+ h[:artwork] = artwork_path if File.exists?(artwork_path)
39
+ MiniSubler::Command.vendored.set_metadata primary_video_file, h
40
+ end
41
41
  rescue
42
42
  puts "Exception while adding metadata to file."
43
43
  end
44
+
45
+ def supports_embedding_video_metadata?
46
+ ext =~ /mp4/i || ext =~ /m4v/i || ext =~ /mkv/i || ext =~ /mov/i
47
+ end
48
+
49
+ def ext
50
+ File.extname self.path
51
+ end
44
52
 
45
53
  def download_image!
46
54
  if !File.exists?(artwork_path) && metadata.canonical_image_url.present?
@@ -56,6 +64,11 @@ module Mediaman
56
64
  def artwork_path
57
65
  extra_path "Artwork#{metadata.canonical_image_url.present? ? File.extname(metadata.canonical_image_url) : ".jpg"}"
58
66
  end
67
+
68
+ def add_to_itunes!
69
+ cmd = "osascript -e \"tell application \\\"iTunes\\\" to add POSIX file \\\"#{self.path}\\\"\""
70
+ `#{cmd}`
71
+ end
59
72
 
60
73
  def metadata
61
74
  @metadata ||= begin
@@ -71,9 +84,8 @@ module Mediaman
71
84
  def local_metadata
72
85
  @local_metadata ||= begin
73
86
  metadata = {}
74
- metadata.merge!(filename_metadata || {})
75
- metadata.merge!(video_metadata || {})
76
87
  metadata.merge!(sidecar_metadata || {})
88
+ metadata.merge!(filename_metadata || {})
77
89
  metadata.reject!{|k, v| v.blank?}
78
90
  Metadata.new(metadata)
79
91
  end
@@ -91,6 +103,8 @@ module Mediaman
91
103
  tv = Trakt::TVEpisode.new show_title: local_metadata['name'], season_number: local_metadata['season_number'], episode_number: local_metadata['episode_number']
92
104
  Metadata.new({'episode_details' => tv.to_hash, 'show_details' => tv.show.to_hash})
93
105
  end
106
+ rescue
107
+ {}
94
108
  end
95
109
  end
96
110
 
@@ -46,7 +46,9 @@ module Mediaman
46
46
  def canonical_director
47
47
  if movie?
48
48
  d = movie_details.try(:[], "people").try(:[], "directors").presence
49
- d.map{|director| director.name}.join ", "
49
+ if d
50
+ d.map{|director| director.name}.join ", "
51
+ end
50
52
  end
51
53
  end
52
54
 
@@ -1,3 +1,3 @@
1
1
  module Mediaman
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/mediaman.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |gem|
8
8
  gem.version = Mediaman::VERSION
9
9
  gem.authors = ["Wil Gieseler"]
10
10
  gem.email = ["supapuerco@gmail.com"]
11
- gem.description = "Helps you organize your media!"
12
- gem.summary = "Helps you organize your media!"
11
+ gem.description = "Mediaman manages your media, man."
12
+ gem.summary = "Mediaman manages your media, man."
13
13
  gem.homepage = "http://github.com/supapuerco/mediaman"
14
14
 
15
15
  gem.files = `git ls-files`.split($/)
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: mediaman
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Wil Gieseler
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-08-20 00:00:00 Z
13
+ date: 2012-08-27 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -89,7 +89,7 @@ dependencies:
89
89
  version: "0"
90
90
  type: :development
91
91
  version_requirements: *id007
92
- description: Helps you organize your media!
92
+ description: Mediaman manages your media, man.
93
93
  email:
94
94
  - supapuerco@gmail.com
95
95
  executables:
@@ -144,7 +144,7 @@ rubyforge_project:
144
144
  rubygems_version: 1.8.15
145
145
  signing_key:
146
146
  specification_version: 3
147
- summary: Helps you organize your media!
147
+ summary: Mediaman manages your media, man.
148
148
  test_files:
149
149
  - spec/mediaman/media_filename_spec.rb
150
150
  - spec/spec_helper.rb