guitarparty-ruby 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/guitarparty.rb +62 -0
- metadata +46 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: de38795368e9379972620583613e2c4ebaa5e6c8
|
4
|
+
data.tar.gz: bc1ecb904f961b84d629c54b040fd88f27479f46
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ab66dd7c2cbdc5682c57fc698d738d4348aec475b1989d106c89a0cfbb3e2b37594588d1fe0c16bac5a89c31dca6aad48634cb7402cf26c4860ac5bc72a63c44
|
7
|
+
data.tar.gz: 198c5d99dfb03b64f14984cac2a1b894fe2485a7079c43c21542237b0c3b7869eb7663085646356fab49e0953b6c4db88d0d8f8088ec1d5880bb751a389324bc
|
data/lib/guitarparty.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'open-uri'
|
3
|
+
# rate limit: 130 requests per hour
|
4
|
+
|
5
|
+
module GuitarParty
|
6
|
+
class Client
|
7
|
+
include HTTParty
|
8
|
+
base_uri "api.guitarparty.com/v2"
|
9
|
+
|
10
|
+
def initialize(api_key)
|
11
|
+
@api_key = api_key
|
12
|
+
@headers = {"Guitarparty-Api-Key" => @api_key}
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_song(song_id)
|
16
|
+
make_request("/songs/#{song_id}/")
|
17
|
+
end
|
18
|
+
|
19
|
+
def search_songs(query_string)
|
20
|
+
make_request("/songs/?query=#{URI::encode(query_string)}")
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_artist(artist_id)
|
24
|
+
make_request("/artists/#{artist_id}/")
|
25
|
+
end
|
26
|
+
|
27
|
+
def search_artists(query_string)
|
28
|
+
make_request("/artists/?query=#{URI::encode(query_string)}")
|
29
|
+
end
|
30
|
+
|
31
|
+
# Guitarparty's returning a 404 for these requests -- seems like something might be broken on their end
|
32
|
+
# but I'll look further into it.
|
33
|
+
|
34
|
+
# def get_songbooks
|
35
|
+
# make_request("/songbooks/")
|
36
|
+
# end
|
37
|
+
|
38
|
+
# def create_songbook(title, description, is_public = false)
|
39
|
+
# data = Hash["title", title, "description", description, "is_public", is_public]
|
40
|
+
# p data
|
41
|
+
# songbook = make_request("/songbooks", "post", data)
|
42
|
+
# songbook
|
43
|
+
# end
|
44
|
+
|
45
|
+
def get_song_chords(song_id)
|
46
|
+
song = JSON.parse((self.get_song(song_id).body))
|
47
|
+
{title: song["title"], artist: song["authors"][0]["name"], chords: grab_chords(song)}
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def make_request(uri)
|
53
|
+
self.class.get(uri, headers: @headers)
|
54
|
+
end
|
55
|
+
|
56
|
+
def grab_chords(song)
|
57
|
+
chords = song["body"].scan(/\[\w{1}\]/)
|
58
|
+
chords.each { |chord| chord.gsub!(/\[|\]/, "")}
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: guitarparty-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Marshall Hattersley
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-09-01 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Easy-to-use Ruby client for the Guitarparty API -- find the source code
|
14
|
+
(instructions on how to use included) at https://github.com/mwhatters/guitarparty-ruby-client
|
15
|
+
-- for more information on the Guitarparty API itself, visit http://www.guitarparty.com/developers/
|
16
|
+
email: mwhatters@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/guitarparty.rb
|
22
|
+
homepage: http://rubygems.org/gems/guitarparty-ruby
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 2.2.3
|
43
|
+
signing_key:
|
44
|
+
specification_version: 4
|
45
|
+
summary: Ruby client for the Guitarparty API
|
46
|
+
test_files: []
|