songkick_ruby 1.1.1 → 1.1.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.
- data/lib/songkick/client/calendar.rb +31 -1
- data/lib/songkick/client/event.rb +8 -2
- data/lib/songkick/client/request.rb +5 -2
- data/lib/songkick/client/search.rb +37 -1
- data/lib/songkick/client.rb +5 -1
- data/lib/songkick.rb +11 -1
- data/songkick_ruby.gemspec +1 -1
- metadata +4 -4
@@ -2,16 +2,46 @@ module Songkick
|
|
2
2
|
class Client
|
3
3
|
module Calendar
|
4
4
|
|
5
|
+
# Find upcoming events for an artist
|
6
|
+
#
|
7
|
+
# Example:
|
8
|
+
# sg = Songkick.new("myapikey")
|
9
|
+
# events = sg.artist_calendar(123)
|
10
|
+
# or events = sg.artist_calendar(123, 2)
|
11
|
+
#
|
12
|
+
# The first argument is the artist_id
|
13
|
+
# and the second argument is the page number,
|
14
|
+
# by default it is set to 1
|
5
15
|
def artist_calendar(artist_id, page = 1)
|
6
16
|
get "artists/#{artist_id}/calendar.#{format}", page
|
7
17
|
end
|
8
18
|
|
19
|
+
# Find upcoming events for a location
|
20
|
+
#
|
21
|
+
# Example:
|
22
|
+
# sg = Songkick.new("myapikey")
|
23
|
+
# events = sg.location_calendar(123)
|
24
|
+
# or events = sg.location_calendar(123, 2)
|
25
|
+
#
|
26
|
+
# The first argument is the artist_id
|
27
|
+
# and the second argument is the page number,
|
28
|
+
# by default it is set to 1
|
9
29
|
def location_calendar(location_id, page = 1)
|
10
30
|
get "metro_areas/#{location_id}/calendar.#{format}", page
|
11
31
|
end
|
12
32
|
|
33
|
+
# Find upcoming events for a user
|
34
|
+
#
|
35
|
+
# Example:
|
36
|
+
# sg = Songkick.new("myapikey")
|
37
|
+
# events = sg.users(123)
|
38
|
+
# or events = sg.users(123, 2)
|
39
|
+
#
|
40
|
+
# The first argument is the artist_id
|
41
|
+
# and the second argument is the page number,
|
42
|
+
# by default it is set to 1
|
13
43
|
def user_calendar(username, page = 1)
|
14
|
-
get "users/#{
|
44
|
+
get "users/#{username}/calendar.#{format}", page
|
15
45
|
end
|
16
46
|
|
17
47
|
end
|
@@ -2,8 +2,14 @@ module Songkick
|
|
2
2
|
class Client
|
3
3
|
module Event
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
# Find detailed information about an event
|
6
|
+
#
|
7
|
+
# Example:
|
8
|
+
# sg = Songkick.new("myapikey")
|
9
|
+
# event = sg.find_event(123)
|
10
|
+
# The first argument is the event id
|
11
|
+
def find_event(event_id)
|
12
|
+
get "events/#{event_id}.#{format}"
|
7
13
|
end
|
8
14
|
|
9
15
|
end
|
@@ -4,18 +4,21 @@ module Songkick
|
|
4
4
|
|
5
5
|
private
|
6
6
|
|
7
|
-
|
7
|
+
# Perform a get request
|
8
|
+
# and returns the response body in the correct format
|
9
|
+
def get(url, page = 1)
|
8
10
|
uri = generate_uri(url, page)
|
9
11
|
|
10
12
|
response = Net::HTTP.get_response(uri)
|
11
13
|
json? ? JSON.parse(response.body) : response.body
|
12
14
|
end
|
13
15
|
|
16
|
+
# Generate uri with aditionnal options
|
17
|
+
# such as the page number and the api key
|
14
18
|
def generate_uri(url, page)
|
15
19
|
uri = API_URL + url
|
16
20
|
uri += uri.include?("?") ? "&page=#{page}" : "?page=#{page}" if page.to_i > 1
|
17
21
|
uri = URI.parse uri.include?("?") ? uri + "&apikey=#{api_key}" : uri + "?apikey=#{api_key}"
|
18
|
-
print
|
19
22
|
uri
|
20
23
|
end
|
21
24
|
|
@@ -2,19 +2,55 @@ module Songkick
|
|
2
2
|
class Client
|
3
3
|
module Search
|
4
4
|
|
5
|
+
# Search for upcoming events
|
6
|
+
#
|
7
|
+
# Options:
|
8
|
+
# * artist_name
|
9
|
+
# * location
|
10
|
+
# * * sk
|
11
|
+
# * * geo
|
12
|
+
# * * ip
|
13
|
+
# * * clientip
|
14
|
+
# * min_date
|
15
|
+
# * max_date
|
16
|
+
#
|
17
|
+
# Look at this page for more information about the location option:
|
18
|
+
# http://www.songkick.com/developer/event-search
|
19
|
+
#
|
20
|
+
# Example:
|
21
|
+
# sg = Songkick.new("myapikey")
|
22
|
+
# events = sg.search_events({:artist_name => "lady gaga"})
|
23
|
+
# events = sg.search_events({:artist_name => "lady gaga"}, 2)
|
24
|
+
# events = sg.search_events({:artist_name => "lady gaga", :location => "clientip=10.10.10.10"} )})
|
5
25
|
def search_events(opts, page = 1)
|
6
26
|
_opts = opts.collect{|k, v| "#{k}=#{v.gsub(" ", "%20")}"}.join("&")
|
7
27
|
get "events.#{format}?#{_opts}", page
|
8
28
|
end
|
9
29
|
alias_method :search_event, :search_events
|
10
30
|
|
11
|
-
|
31
|
+
# Search for locations
|
32
|
+
#
|
33
|
+
# Options:
|
34
|
+
# * query
|
35
|
+
# * location
|
36
|
+
#
|
37
|
+
# Look at this page for more information about the location option:
|
38
|
+
# http://www.songkick.com/developer/location-search
|
39
|
+
#
|
40
|
+
# Example:
|
41
|
+
# sg = Songkick.new("myapikey")
|
42
|
+
# locations = sg.search_locations({:query => "Paris"})
|
12
43
|
def search_locations(opts, page = 1)
|
13
44
|
_opts = opts.collect{|k, v| "#{k}=#{v.gsub(" ", "%20")}"}.join("&")
|
14
45
|
get "search/locations.#{format}?#{_opts}", page
|
15
46
|
end
|
16
47
|
alias_method :search_location, :search_locations
|
17
48
|
|
49
|
+
# Search for artists
|
50
|
+
#
|
51
|
+
# Example:
|
52
|
+
# sg = Songkick.new("myapikey")
|
53
|
+
# artists = sg.search_artists("ladygaga")
|
18
54
|
def search_artists(text, page = 1)
|
19
55
|
get "search/artists.#{format}?query=#{text.gsub(" ","%20")}", page
|
20
56
|
end
|
data/lib/songkick/client.rb
CHANGED
@@ -10,6 +10,8 @@ module Songkick
|
|
10
10
|
|
11
11
|
attr_accessor :api_key, :format
|
12
12
|
|
13
|
+
# Look at the songkick.rb file for info
|
14
|
+
# Songkick::Client.new == Songkick.new
|
13
15
|
def initialize(api_key, format = :json)
|
14
16
|
@api_key = api_key
|
15
17
|
@format = format
|
@@ -19,10 +21,12 @@ module Songkick
|
|
19
21
|
@format = format.to_s
|
20
22
|
end
|
21
23
|
|
24
|
+
# Clean way to know if the format is in json
|
22
25
|
def json?
|
23
26
|
format == 'json'
|
24
27
|
end
|
25
|
-
|
28
|
+
|
29
|
+
# Clean way to know if the format is in xml
|
26
30
|
def xml?
|
27
31
|
format == 'xml'
|
28
32
|
end
|
data/lib/songkick.rb
CHANGED
@@ -7,7 +7,17 @@ require "songkick/client.rb"
|
|
7
7
|
|
8
8
|
module Songkick
|
9
9
|
class << self
|
10
|
-
|
10
|
+
|
11
|
+
# In order to use the API you must have an API key
|
12
|
+
# To request one, go to this url: http://developer.songkick.com/
|
13
|
+
#
|
14
|
+
# Example:
|
15
|
+
# sg = Songkick.new("myaipkey")
|
16
|
+
# You can pass a second argument (json or xml) which is the output form.
|
17
|
+
# json is the default output
|
18
|
+
#
|
19
|
+
# Songkick.new is a shortcut for songkick::Client.new
|
20
|
+
# You can use both, they are the same
|
11
21
|
def new(api_key, format = :json)
|
12
22
|
Songkick::Client.new(api_key, format)
|
13
23
|
end
|
data/songkick_ruby.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: songkick_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 2
|
10
|
+
version: 1.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Gregory Marcilhacy
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-08-
|
18
|
+
date: 2011-08-19 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|