mini_subler 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +35 -0
- data/Rakefile +1 -0
- data/lib/.DS_Store +0 -0
- data/lib/mini_subler.rb +5 -0
- data/lib/mini_subler/command.rb +69 -0
- data/lib/mini_subler/version.rb +3 -0
- data/mini_subler.gemspec +24 -0
- data/vendor/SublerCLI +0 -0
- metadata +86 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Wil Gieseler
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# MiniSubler
|
2
|
+
|
3
|
+
A lightweight Ruby wrapper around [Subler](http://code.google.com/p/subler/)'s CLI interface.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
MiniSubler::Command.vendored.set_metadata("~/movie.mp4", {genre: "Comedy", artwork: "/path/to/artwork"})
|
9
|
+
```
|
10
|
+
|
11
|
+
See a full list of metadata tags at http://code.google.com/p/subler/wiki/SublerCLIHelp
|
12
|
+
|
13
|
+
MiniSubler underscores the tag names, replaces "#" with "number", and converts it to a symbol. Therefore, the tag `TV Episode #` would become the symbol `:tv_episode_number`.
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
Add this line to your application's Gemfile:
|
18
|
+
|
19
|
+
gem 'mini_subler'
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
$ bundle
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
$ gem install mini_subler
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
1. Fork it
|
32
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
33
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
34
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
35
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/.DS_Store
ADDED
Binary file
|
data/lib/mini_subler.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'cocaine'
|
2
|
+
|
3
|
+
module MiniSubler
|
4
|
+
|
5
|
+
class Command
|
6
|
+
|
7
|
+
def self.vendored
|
8
|
+
gem_root = File.expand_path '../../..', __FILE__
|
9
|
+
s = Command.new
|
10
|
+
s.command_path = File.join gem_root, "vendor", "SublerCLI"
|
11
|
+
s
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_accessor :command_path
|
15
|
+
|
16
|
+
def get_metadata(file_path)
|
17
|
+
file_path = File.expand_path file_path
|
18
|
+
metadata_text = Cocaine::CommandLine.new(self.command_path, "-source :source -listmetadata", source: file_path).run
|
19
|
+
hash = {}
|
20
|
+
metadata_text.each_line do |line|
|
21
|
+
if line.include?(self.command_path)
|
22
|
+
# Do nothing
|
23
|
+
else
|
24
|
+
split = line.split ": "
|
25
|
+
hash[split[0].parameterize("_").to_sym] = split[1].chomp
|
26
|
+
end
|
27
|
+
end
|
28
|
+
hash
|
29
|
+
rescue
|
30
|
+
nil
|
31
|
+
end
|
32
|
+
|
33
|
+
def set_metadata(file_path, hash)
|
34
|
+
file_path = File.expand_path file_path
|
35
|
+
line = Cocaine::CommandLine.new(self.command_path, "-dest :source -metadata :metadata", source: file_path, metadata: subler_hash_to_argument(hash_to_subler_hash(hash)))
|
36
|
+
puts line.run
|
37
|
+
end
|
38
|
+
|
39
|
+
def hash_to_subler_hash(h)
|
40
|
+
n = {}
|
41
|
+
h.each do |key, value|
|
42
|
+
n[key.to_s.titleize.gsub("Tv", "TV").gsub("Id", "ID").gsub("Hd", "HD").gsub("Number", "#")] = value
|
43
|
+
end
|
44
|
+
n
|
45
|
+
end
|
46
|
+
|
47
|
+
def subler_hash_to_hash(h)
|
48
|
+
n = {}
|
49
|
+
h.each do |tag_name, tag_value|
|
50
|
+
n[tag_name.gsub("#", "Number").parameterize("_").to_sym] = tag_value
|
51
|
+
end
|
52
|
+
n
|
53
|
+
end
|
54
|
+
|
55
|
+
def subler_hash_to_argument(h)
|
56
|
+
s = ""
|
57
|
+
h.each do |key, value|
|
58
|
+
s << "{#{escape key}:#{escape value}}"
|
59
|
+
end
|
60
|
+
s
|
61
|
+
end
|
62
|
+
|
63
|
+
def escape(s)
|
64
|
+
s.to_s.gsub("{", "{").gsub("{", "}").gsub(":", ":")
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
data/mini_subler.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'mini_subler/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "mini_subler"
|
8
|
+
gem.version = MiniSubler::VERSION
|
9
|
+
gem.authors = ["Wil Gieseler"]
|
10
|
+
gem.email = ["supapuerco@gmail.com"]
|
11
|
+
gem.description = %q{A lightweight Ruby wrapper around Subler's CLI interface.}
|
12
|
+
gem.summary = %q{A lightweight Ruby wrapper around Subler's CLI interface.}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency 'activesupport', '>=3.0.0'
|
21
|
+
gem.add_dependency 'cocaine'
|
22
|
+
|
23
|
+
end
|
24
|
+
|
data/vendor/SublerCLI
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mini_subler
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Wil Gieseler
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2012-08-19 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: activesupport
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 3.0.0
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: cocaine
|
28
|
+
prerelease: false
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: "0"
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id002
|
37
|
+
description: A lightweight Ruby wrapper around Subler's CLI interface.
|
38
|
+
email:
|
39
|
+
- supapuerco@gmail.com
|
40
|
+
executables: []
|
41
|
+
|
42
|
+
extensions: []
|
43
|
+
|
44
|
+
extra_rdoc_files: []
|
45
|
+
|
46
|
+
files:
|
47
|
+
- .gitignore
|
48
|
+
- Gemfile
|
49
|
+
- LICENSE.txt
|
50
|
+
- README.md
|
51
|
+
- Rakefile
|
52
|
+
- lib/.DS_Store
|
53
|
+
- lib/mini_subler.rb
|
54
|
+
- lib/mini_subler/command.rb
|
55
|
+
- lib/mini_subler/version.rb
|
56
|
+
- mini_subler.gemspec
|
57
|
+
- vendor/SublerCLI
|
58
|
+
homepage: ""
|
59
|
+
licenses: []
|
60
|
+
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: "0"
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: "0"
|
78
|
+
requirements: []
|
79
|
+
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 1.8.15
|
82
|
+
signing_key:
|
83
|
+
specification_version: 3
|
84
|
+
summary: A lightweight Ruby wrapper around Subler's CLI interface.
|
85
|
+
test_files: []
|
86
|
+
|