camelot_key_converter 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.key_convert_map.yml +32 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +26 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/camelot_key_converter.gemspec +28 -0
- data/exe/camelot_key_converter +7 -0
- data/lib/camelot_key_converter.rb +5 -0
- data/lib/camelot_key_converter/converter.rb +145 -0
- data/lib/camelot_key_converter/version.rb +3 -0
- metadata +142 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5c478e1ebbc736582a915eb75d7b05556e378d15
|
4
|
+
data.tar.gz: b15b634935ce861fa93017e304fa70b506d782f3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a7bcc682839fba49eca81fbdfba828b1af289a14113c6fa2768929f7c4193d289a2f6ed609c9fe15680d5eefe352eb3025dff510f38d2bf05a332643c018606c
|
7
|
+
data.tar.gz: bc2dcdbcc950f38116add87118d71f4980c89c741329a983ca1cd73565af4d224109886a3770bb93f2a51ba9dddf1da9764b7541a2fa8d1d977549426a086549
|
data/.gitignore
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
---
|
2
|
+
ignored: []
|
3
|
+
map:
|
4
|
+
Em: 09A
|
5
|
+
Eb: 05B
|
6
|
+
Am: 08A
|
7
|
+
Ebm: 02A
|
8
|
+
Bb: 06B
|
9
|
+
D: 10B
|
10
|
+
F#m: 11A
|
11
|
+
Bm: 10A
|
12
|
+
Gm: 06A
|
13
|
+
Abm: 01A
|
14
|
+
Fm: 04A
|
15
|
+
B: 01B
|
16
|
+
Dm: 07A
|
17
|
+
Bbm: 03A
|
18
|
+
Dbm: 12A
|
19
|
+
F#: 02B
|
20
|
+
C: 08B
|
21
|
+
Cm: 05A
|
22
|
+
A: 11B
|
23
|
+
G: 09B
|
24
|
+
E: 12B
|
25
|
+
Db: 03B
|
26
|
+
F: 07B
|
27
|
+
Ab: 04B
|
28
|
+
A#min: 01A
|
29
|
+
G#min: 06A
|
30
|
+
Fmaj: 07B
|
31
|
+
F#min: 11A
|
32
|
+
Amin: 08A
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Robin Wenglewski
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Camelot Key Converter
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
$ gem install camelot_key_converter
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
- optionally copy `.key_convert_map.yml` to your home directory and adjust it
|
10
|
+
- cd to the directory containing your mp3s
|
11
|
+
- execute `camelot_key_converter`
|
12
|
+
|
13
|
+
## Development
|
14
|
+
|
15
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
16
|
+
|
17
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
18
|
+
|
19
|
+
## Contributing
|
20
|
+
|
21
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/rweng/camelot_key_converter.
|
22
|
+
|
23
|
+
|
24
|
+
## License
|
25
|
+
|
26
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "camelot_key_converter"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'camelot_key_converter/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "camelot_key_converter"
|
8
|
+
spec.version = CamelotKeyConverter::VERSION
|
9
|
+
spec.authors = ["Robin Wenglewski"]
|
10
|
+
spec.email = ["robin@wenglewski.de"]
|
11
|
+
|
12
|
+
spec.summary = %q{tool to convert keys in mp3s}
|
13
|
+
spec.description = %q{}
|
14
|
+
spec.homepage = "https://github.com/rweng/camelot_key_converter"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_dependency "hashie"
|
25
|
+
spec.add_dependency "pry"
|
26
|
+
spec.add_dependency "highline"
|
27
|
+
spec.add_dependency "taglib-ruby", '~> 0.7.1'
|
28
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
require 'taglib'
|
2
|
+
require 'highline'
|
3
|
+
require 'pathname'
|
4
|
+
require 'pry'
|
5
|
+
require 'yaml'
|
6
|
+
require 'hashie'
|
7
|
+
|
8
|
+
class CamelotKeyConverter::Converter
|
9
|
+
MAP_FILE = File.expand_path('~/.key_convert_map.yml')
|
10
|
+
attr_accessor :ignored, :map, :should_convert_all
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
self.ignored = []
|
14
|
+
self.map = {}
|
15
|
+
self.should_convert_all = false
|
16
|
+
try_load_file
|
17
|
+
end
|
18
|
+
|
19
|
+
def run!
|
20
|
+
convert(Pathname.new('.'))
|
21
|
+
rescue ExitError => e
|
22
|
+
cli.say('exiting ...')
|
23
|
+
ensure
|
24
|
+
save_config!
|
25
|
+
end
|
26
|
+
|
27
|
+
def cli
|
28
|
+
@cli ||= HighLine.new
|
29
|
+
end
|
30
|
+
|
31
|
+
def save_config!
|
32
|
+
File.open(MAP_FILE, 'w') do |f|
|
33
|
+
f.write({
|
34
|
+
"ignored" => ignored,
|
35
|
+
"map" => map
|
36
|
+
}.to_yaml)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def convert(path)
|
41
|
+
if path.file?
|
42
|
+
convert_file! path
|
43
|
+
return
|
44
|
+
end
|
45
|
+
|
46
|
+
path.children.each do |child|
|
47
|
+
if self.should_convert_all
|
48
|
+
convert(child)
|
49
|
+
next
|
50
|
+
end
|
51
|
+
|
52
|
+
cli.choose do |menu|
|
53
|
+
menu.prompt = "What to do next?"
|
54
|
+
menu.choice(:convert, "Convert #{child}") do
|
55
|
+
convert(child)
|
56
|
+
end
|
57
|
+
|
58
|
+
menu.choice(:exit) do
|
59
|
+
raise ExitError
|
60
|
+
end
|
61
|
+
|
62
|
+
menu.choice(:convert_all) do
|
63
|
+
self.should_convert_all = true
|
64
|
+
convert(child)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def try_load_file
|
71
|
+
x = YAML::load_file(MAP_FILE)
|
72
|
+
self.ignored = x['ignored'] || []
|
73
|
+
self.map = x['map'] || {}
|
74
|
+
rescue
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
def convert_file!(path)
|
79
|
+
TagLib::MPEG::File.open(path.to_s) do |file|
|
80
|
+
tag = file.id3v2_tag
|
81
|
+
key = tag.frame_list('TKEY').first
|
82
|
+
|
83
|
+
if key.nil?
|
84
|
+
cli.say "no key found for #{path}"
|
85
|
+
return
|
86
|
+
end
|
87
|
+
|
88
|
+
if key.field_list.length != 1
|
89
|
+
binding.pry
|
90
|
+
return
|
91
|
+
end
|
92
|
+
|
93
|
+
if ignored.include? key.to_s
|
94
|
+
cli.say("#{key.to_s} is ignored")
|
95
|
+
return
|
96
|
+
end
|
97
|
+
|
98
|
+
if map.values.include? key.to_s
|
99
|
+
cli.say("#{key.to_s} already correct value")
|
100
|
+
return
|
101
|
+
end
|
102
|
+
|
103
|
+
new_key = map[key.to_s]
|
104
|
+
unless new_key
|
105
|
+
result = cli.choose do |menu|
|
106
|
+
menu.prompt = "Cant find #{key.to_s}. What to you want to do?"
|
107
|
+
menu.choice(:add)
|
108
|
+
menu.choice(:ignore) do
|
109
|
+
ignored << key.to_s
|
110
|
+
return
|
111
|
+
end
|
112
|
+
menu.choice(:exit) do
|
113
|
+
raise ExitError
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
# can only be :add because :ignore and :exit return
|
118
|
+
|
119
|
+
loop do
|
120
|
+
new_key = cli.ask('Enter the replacement and press enter: ')
|
121
|
+
if map.keys.include?(new_key)
|
122
|
+
cli.say('This value does already exist as key, which is not allowed to prevent loops.')
|
123
|
+
else
|
124
|
+
break
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
if cli.agree('Do you want to save the replacement?')
|
129
|
+
map[key.to_s] = new_key
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
cli.say("#{path.to_s} - #{new_key}")
|
134
|
+
|
135
|
+
# don't alter file if nothing changed
|
136
|
+
return if new_key == key.to_s
|
137
|
+
|
138
|
+
key.field_list = [new_key]
|
139
|
+
file.save
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
class ExitError < StandardError
|
144
|
+
end
|
145
|
+
end
|
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: camelot_key_converter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Robin Wenglewski
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: hashie
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: highline
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: taglib-ruby
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.7.1
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.7.1
|
97
|
+
description: ''
|
98
|
+
email:
|
99
|
+
- robin@wenglewski.de
|
100
|
+
executables:
|
101
|
+
- camelot_key_converter
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- ".gitignore"
|
106
|
+
- ".key_convert_map.yml"
|
107
|
+
- Gemfile
|
108
|
+
- LICENSE.txt
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- bin/console
|
112
|
+
- bin/setup
|
113
|
+
- camelot_key_converter.gemspec
|
114
|
+
- exe/camelot_key_converter
|
115
|
+
- lib/camelot_key_converter.rb
|
116
|
+
- lib/camelot_key_converter/converter.rb
|
117
|
+
- lib/camelot_key_converter/version.rb
|
118
|
+
homepage: https://github.com/rweng/camelot_key_converter
|
119
|
+
licenses:
|
120
|
+
- MIT
|
121
|
+
metadata: {}
|
122
|
+
post_install_message:
|
123
|
+
rdoc_options: []
|
124
|
+
require_paths:
|
125
|
+
- lib
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
requirements: []
|
137
|
+
rubyforge_project:
|
138
|
+
rubygems_version: 2.5.1
|
139
|
+
signing_key:
|
140
|
+
specification_version: 4
|
141
|
+
summary: tool to convert keys in mp3s
|
142
|
+
test_files: []
|