memphis 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 040f373e37a2f6e9c2a2c671e6795bc86988aeee
4
+ data.tar.gz: b903f99ff5ddd5f8fcac43859395d1ac68ca54b9
5
+ SHA512:
6
+ metadata.gz: 925f69971f11ade431531ce7b826ff2172d572f9fead02a0e075d2aab34fa368fdd9548dc025965e06ef13299c34a298fe6239208df365b2630bfa0d70aca24e
7
+ data.tar.gz: d63bc3c7b96937c56dbf7c57b3d49a6b975fd70722cbc875edc3f3d30e9ae13b30429a32499c5407e55c50a9de7f0085a17647c5cf126d8d26cdf32350b486e8
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ .rvmrc
2
+ *.gem
3
+ *.rbc
4
+ .bundle
5
+ .config
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in memphis.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 messick
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ 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, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Nick Messick
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,54 @@
1
+ # Memphis
2
+
3
+ An easy way to use The Echo Nest's Project Rosetta Stone to lookup IDs of other providers using a Echo Nest ID.
4
+
5
+ The [Decree of Memphis](http://en.wikipedia.org/wiki/Rosetta_Stone_decree) is the message that is inscribed on the actual Rosetta Stone.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'memphis'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install memphis
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ require 'memphis'
25
+
26
+ memphis = Memphis::Client.new ECHONEST_API_KEY
27
+
28
+ # Search using The Echo Nest ID for Radiohead
29
+ results = memphis.search "ARH6W4X1187B99274F"
30
+
31
+ results["7digital"] # "304"
32
+ results["deezer"] # "399"
33
+ results["echonest"] # "Radiohead"
34
+ results["facebook"] # "6979332244"
35
+ results["jambase"] # "8317"
36
+ results["musicbrainz"] # "a74b1b7f-71a5-4011-9441-d0b5e4122711"
37
+ results["playme"] # "1307"
38
+ results["rhapsody"] # "Art.4817"
39
+ results["rdio"] # "r91318"
40
+ results["seat_geek"] # "2570"
41
+ results["songkick"] # "253846"
42
+ results["song_meanings"] # "200"
43
+ results["spotify"] # "4Z8W4fKeB5YxbusRsdQVPb"
44
+ results["twitter"] # "radiohead"
45
+ results["who_sampled"] # "3309"
46
+ ```
47
+
48
+ ## Contributing
49
+
50
+ 1. Fork it
51
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
52
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
53
+ 4. Push to the branch (`git push origin my-new-feature`)
54
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,75 @@
1
+ module Memphis
2
+ class Client
3
+ class MemphisConnectionError < Exception; end
4
+
5
+ FOREIGN_PROVIDERS = {
6
+ '7digital-US' => '7digital',
7
+ 'deezer' => 'deezer',
8
+ 'facebook' => 'facebook',
9
+ 'fma' => 'free_music_rchive',
10
+ 'jambase' => 'jambase',
11
+ 'musicbrainz' => 'musicbrainz',
12
+ 'playme' => 'playme',
13
+ 'rhapsody-US' => 'rhapsody',
14
+ 'rdio-US' => 'rdio',
15
+ 'seatgeek' => 'seat_geek',
16
+ 'songkick' => 'songkick',
17
+ 'spotify-WW' => 'spotify',
18
+ 'songmeanings' => 'song_meanings',
19
+ 'twitter' => 'twitter',
20
+ 'whosampled' => 'who_sampled'
21
+ }
22
+
23
+ BASE_URI = 'http://developer.echonest.com/api/v4/artist/profile?'
24
+
25
+ def initialize api_key
26
+ @api_key = api_key
27
+ end
28
+
29
+ def search id
30
+ @id = id
31
+ results = get_foreign_id_hash
32
+
33
+ results
34
+ end
35
+
36
+ private
37
+
38
+ def get_foreign_id_hash
39
+ uri = BASE_URI
40
+ uri += "api_key=#{@api_key}"
41
+ uri += "&id=#{@id}"
42
+ uri += provider_params
43
+
44
+ parse_response HTTParty.get(uri)
45
+ end
46
+
47
+ def provider_params
48
+ "&bucket=id:" + FOREIGN_PROVIDERS.keys.join('&bucket=id:')
49
+ end
50
+
51
+ def parse_response http_response
52
+ foreign_ids = {}
53
+
54
+
55
+ # Also put the echonest artist name in there, even though
56
+ # it's not technically a "foreign" id
57
+ foreign_ids["echonest"] = http_response["response"]["artist"]["name"]
58
+
59
+ http_response['response']['artist']['foreign_ids'].each do |hash|
60
+
61
+ id_parts = hash["foreign_id"].split(':')
62
+
63
+ provider = FOREIGN_PROVIDERS[id_parts[0]]
64
+
65
+ foreign_id = id_parts[2]
66
+
67
+ foreign_ids[provider] = foreign_id
68
+ end
69
+
70
+ foreign_ids
71
+ end
72
+
73
+ end
74
+
75
+ end
@@ -0,0 +1,3 @@
1
+ module Memphis
2
+ VERSION = "0.0.2"
3
+ end
data/lib/memphis.rb ADDED
@@ -0,0 +1,9 @@
1
+ require_relative 'memphis/client'
2
+ require_relative 'memphis/version'
3
+
4
+ require 'httparty'
5
+ require 'multi_json'
6
+
7
+ module Memphis
8
+
9
+ end
data/memphis.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'memphis/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "memphis"
8
+ spec.version = Memphis::VERSION
9
+ spec.authors = ["Nick Messick"]
10
+ spec.email = ["nmessick@gmail.com"]
11
+ spec.description = %q{Use Echonest's Rosetta Stone project to lookup ids for various other services}
12
+ spec.summary = %q{Use Echonest's Rosetta Stone project to lookup ids for various other services}
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 "httparty"
22
+ spec.add_dependency "multi_json"
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: memphis
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Nick Messick
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
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: multi_json
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: rake
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
+ description: Use Echonest's Rosetta Stone project to lookup ids for various other
70
+ services
71
+ email:
72
+ - nmessick@gmail.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - .gitignore
78
+ - Gemfile
79
+ - LICENSE
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - lib/memphis.rb
84
+ - lib/memphis/client.rb
85
+ - lib/memphis/version.rb
86
+ - memphis.gemspec
87
+ homepage: ''
88
+ licenses:
89
+ - MIT
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 2.0.5
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: Use Echonest's Rosetta Stone project to lookup ids for various other services
111
+ test_files: []