musicbrainz_cli 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 +18 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +59 -0
- data/Rakefile +1 -0
- data/bin/musicbrainz-cli +51 -0
- data/lib/musicbrainz_cli.rb +15 -0
- data/lib/musicbrainz_cli/cli.rb +25 -0
- data/lib/musicbrainz_cli/commands.rb +16 -0
- data/lib/musicbrainz_cli/info.rb +20 -0
- data/lib/musicbrainz_cli/version.rb +3 -0
- data/musicbrainz_cli.gemspec +27 -0
- metadata +127 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 75d096b9b4810cae5dd6918dbb9bbd9d5943043e
|
4
|
+
data.tar.gz: 64f932ceea386a054e084d5d0efa304845140015
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f38bf759acba8725cf15e1ae81a4943015d4969175f816fa553e1382b5779fc32b1c5556016e9f0d25758894fc9bb75e662193ffecea521c730ab1179ce3a6dd
|
7
|
+
data.tar.gz: 690ec25a555208f7bd7453d93fc20326cfb9e6c218b8461e052bcaba9d4a43958237345ca55011dcb75cb7e2a89e25f46c9c88c73762814c50484d5e62d0ca38
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Andrea Franz (http://gravityblast.com)
|
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,59 @@
|
|
1
|
+
# MusicbrainzCli
|
2
|
+
|
3
|
+
A command line interface to the ["Musicbrainz database"]("http://musicbrainz.org/doc/MusicBrainz_Database")
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
$ gem install musicbrainz_cli
|
8
|
+
|
9
|
+
And then execute:
|
10
|
+
|
11
|
+
$ musicbrainz-cli
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
This gem uses the ["ActiveMusicbrainz"]("https://github.com/pilu/active_musicbrainz"), so you can use its model like the following:
|
16
|
+
|
17
|
+
artist = ActiveMusicbrainz::Model::Artist.where(gid: '9a709693-b4f8-4da9-8cc1-038c911a61be').first
|
18
|
+
=> #<ActiveMusicbrainz::Model::Artist id: 24146, gid: "9a709693-b4f8-4da9-8cc1-038c911a61be", name: 143497, sort_name: 143497, begin_date_year: 1976, begin_date_month: 3, begin_date_day: 30, end_date_year: nil, end_date_month: nil, end_date_day: nil, type: 1, area: 221, gender: 1, comment: "UK electro artist Simon Green", edits_pending: 0, last_updated: "2013-05-13 11:00:09", ended: false, begin_area: nil, end_area: nil>
|
19
|
+
|
20
|
+
artist.name
|
21
|
+
=> "Bonobo"
|
22
|
+
|
23
|
+
artist.release_groups.first.type
|
24
|
+
=> #<ActiveMusicbrainz::Model::ReleaseGroupPrimaryType id: 1, name: "Album">
|
25
|
+
|
26
|
+
artist.release_groups.each{|r| puts r.name }
|
27
|
+
Black Sands
|
28
|
+
Dial 'M' for Monkey
|
29
|
+
Scuba EP
|
30
|
+
Flutter
|
31
|
+
Pick Up
|
32
|
+
Terrapin
|
33
|
+
Eyesdown
|
34
|
+
...
|
35
|
+
|
36
|
+
artist.release_groups.first.releases.first.mediums
|
37
|
+
=> [#<ActiveMusicbrainz::Model::Medium id: 654199, release: 654199, position: 1, format: 1, name: nil, edits_pending: 0, last_updated: "2012-01-15 13:46:18", track_count: 12>]
|
38
|
+
|
39
|
+
artist.release_groups.first.releases.first.mediums.first.tracks.each{|t| puts t.name}
|
40
|
+
Prelude
|
41
|
+
Kiara
|
42
|
+
Kong
|
43
|
+
Eyesdown
|
44
|
+
...
|
45
|
+
|
46
|
+
artist.release_groups.first.releases.first.mediums.first.format
|
47
|
+
=> #<ActiveMusicbrainz::Model::MediumFormat id: 1, name: "CD", parent: nil, child_order: 0, year: 1982, has_discids: true>
|
48
|
+
|
49
|
+
## Author
|
50
|
+
|
51
|
+
Andrea Franz - [http://gravityblast.com](http://gravityblast.com)
|
52
|
+
|
53
|
+
## Contributing
|
54
|
+
|
55
|
+
1. Fork it
|
56
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
57
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
58
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
59
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/musicbrainz-cli
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'musicbrainz_cli'
|
5
|
+
|
6
|
+
DEFAULT_CONFIGURATION_FILE = '~/.musicbrainz_cli.yml'
|
7
|
+
|
8
|
+
options = {
|
9
|
+
config_file: DEFAULT_CONFIGURATION_FILE
|
10
|
+
}
|
11
|
+
|
12
|
+
OptionParser.new do |opts|
|
13
|
+
opts.banner = "Usage: #{File.basename(__FILE__)} [options]"
|
14
|
+
opts.on '-v', '--verbose', 'Run queries verbosely' do |v|
|
15
|
+
options[:logdev] = STDOUT
|
16
|
+
end
|
17
|
+
opts.on '-f', '--config-file FILE', String, 'Load database config file' do |v|
|
18
|
+
options[:config_file] = v
|
19
|
+
end
|
20
|
+
|
21
|
+
opts.on_tail '-h', '--help', 'Help' do
|
22
|
+
puts opts
|
23
|
+
exit
|
24
|
+
end
|
25
|
+
|
26
|
+
opts.on_tail '--version', 'Show version' do
|
27
|
+
puts MusicbrainzCli::VERSION
|
28
|
+
exit
|
29
|
+
end
|
30
|
+
end.parse!
|
31
|
+
|
32
|
+
options[:config_file] = File.expand_path(options[:config_file].to_s)
|
33
|
+
|
34
|
+
unless File.exists? options[:config_file]
|
35
|
+
puts "Configuration file not found (#{options[:config_file]})."
|
36
|
+
puts "Default configuration file is #{DEFAULT_CONFIGURATION_FILE}."
|
37
|
+
puts "You can also specify the config file with the -f option."
|
38
|
+
puts "Configuration file example:"
|
39
|
+
puts ":database:
|
40
|
+
:adapter: 'postgresql'
|
41
|
+
:host: 'localhost'
|
42
|
+
:username: 'root'
|
43
|
+
:password: ''
|
44
|
+
:database: 'musicbrainz'
|
45
|
+
:username: 'musicbrainz'"
|
46
|
+
exit 1
|
47
|
+
end
|
48
|
+
|
49
|
+
MusicbrainzCli.init options[:config_file]
|
50
|
+
cli = MusicbrainzCli::CLI.new options
|
51
|
+
cli.loop
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'active_musicbrainz'
|
2
|
+
require 'ripl'
|
3
|
+
require 'yaml'
|
4
|
+
require "musicbrainz_cli/version"
|
5
|
+
require "musicbrainz_cli/commands"
|
6
|
+
require "musicbrainz_cli/info"
|
7
|
+
require "musicbrainz_cli/cli"
|
8
|
+
|
9
|
+
module MusicbrainzCli
|
10
|
+
def self.init config_file_path
|
11
|
+
config = YAML.load_file config_file_path
|
12
|
+
ActiveRecord::Base.establish_connection config[:database]
|
13
|
+
ActiveMusicbrainz.init
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
module MusicbrainzCli
|
4
|
+
class CLI
|
5
|
+
include Commands
|
6
|
+
include ActiveMusicbrainz::Model
|
7
|
+
|
8
|
+
def initialize options={}
|
9
|
+
ActiveRecord::Base.logger = Logger.new options[:logdev] if options[:logdev]
|
10
|
+
end
|
11
|
+
|
12
|
+
def loop
|
13
|
+
Ripl.start binding: binding, prompt: 'MusicBrainz CLI > '
|
14
|
+
end
|
15
|
+
|
16
|
+
def method_missing m, *args, &block
|
17
|
+
command_name = "command_#{m}"
|
18
|
+
if respond_to? command_name
|
19
|
+
send command_name, *args
|
20
|
+
else
|
21
|
+
super
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module MusicbrainzCli
|
2
|
+
module Commands
|
3
|
+
def self.command name, &block
|
4
|
+
define_method "command_#{name}", &block
|
5
|
+
end
|
6
|
+
|
7
|
+
command :tables do |pattern=""|
|
8
|
+
regexp = Regexp.new pattern.to_s
|
9
|
+
ActiveRecord::Base.connection.tables.find_all{|table_name| table_name =~ regexp}
|
10
|
+
end
|
11
|
+
|
12
|
+
command :info do
|
13
|
+
puts Info.new
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module MusicbrainzCli
|
2
|
+
class Info
|
3
|
+
def to_s
|
4
|
+
info.collect do |key, value|
|
5
|
+
"#{key} => #{value}"
|
6
|
+
end.join "\n"
|
7
|
+
end
|
8
|
+
|
9
|
+
def info
|
10
|
+
@info ||= build_info
|
11
|
+
end
|
12
|
+
|
13
|
+
def build_info
|
14
|
+
@info = {}
|
15
|
+
tables = ActiveRecord::Base.connection.tables
|
16
|
+
@info['Tables count'] = tables.count
|
17
|
+
@info
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'musicbrainz_cli/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "musicbrainz_cli"
|
8
|
+
spec.version = MusicbrainzCli::VERSION
|
9
|
+
spec.authors = ["Andrea Franz"]
|
10
|
+
spec.email = ["andrea@gravityblast.com"]
|
11
|
+
spec.description = %q{Command Line Interface for the MusicBrainz database}
|
12
|
+
spec.summary = %q{MusicBrainz database CLI}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'active_musicbrainz'
|
22
|
+
spec.add_dependency 'ripl'
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
25
|
+
spec.add_development_dependency "pg"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: musicbrainz_cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrea Franz
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: active_musicbrainz
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ripl
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pg
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
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: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Command Line Interface for the MusicBrainz database
|
84
|
+
email:
|
85
|
+
- andrea@gravityblast.com
|
86
|
+
executables:
|
87
|
+
- musicbrainz-cli
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- .gitignore
|
92
|
+
- Gemfile
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- bin/musicbrainz-cli
|
97
|
+
- lib/musicbrainz_cli.rb
|
98
|
+
- lib/musicbrainz_cli/cli.rb
|
99
|
+
- lib/musicbrainz_cli/commands.rb
|
100
|
+
- lib/musicbrainz_cli/info.rb
|
101
|
+
- lib/musicbrainz_cli/version.rb
|
102
|
+
- musicbrainz_cli.gemspec
|
103
|
+
homepage: ''
|
104
|
+
licenses:
|
105
|
+
- MIT
|
106
|
+
metadata: {}
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - '>='
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 2.0.3
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: MusicBrainz database CLI
|
127
|
+
test_files: []
|