beatport 0.1.1
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/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +18 -0
- data/Gemfile.lock +44 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +23 -0
- data/Rakefile +55 -0
- data/VERSION +1 -0
- data/beatport.gemspec +129 -0
- data/lib/beatport.rb +15 -0
- data/lib/beatport/catalog.rb +93 -0
- data/lib/beatport/catalog/account_type.rb +11 -0
- data/lib/beatport/catalog/artist.rb +20 -0
- data/lib/beatport/catalog/audio_format.rb +10 -0
- data/lib/beatport/catalog/audio_format_fee.rb +8 -0
- data/lib/beatport/catalog/autocomplete.rb +11 -0
- data/lib/beatport/catalog/chart.rb +27 -0
- data/lib/beatport/catalog/chart_overview.rb +12 -0
- data/lib/beatport/catalog/country.rb +16 -0
- data/lib/beatport/catalog/currency.rb +9 -0
- data/lib/beatport/catalog/feature.rb +16 -0
- data/lib/beatport/catalog/genre.rb +32 -0
- data/lib/beatport/catalog/home.rb +13 -0
- data/lib/beatport/catalog/image.rb +7 -0
- data/lib/beatport/catalog/images.rb +13 -0
- data/lib/beatport/catalog/item_type.rb +9 -0
- data/lib/beatport/catalog/key.rb +7 -0
- data/lib/beatport/catalog/keys.rb +7 -0
- data/lib/beatport/catalog/label.rb +29 -0
- data/lib/beatport/catalog/list.rb +7 -0
- data/lib/beatport/catalog/mixed.rb +9 -0
- data/lib/beatport/catalog/recommendations.rb +7 -0
- data/lib/beatport/catalog/release.rb +32 -0
- data/lib/beatport/catalog/search.rb +11 -0
- data/lib/beatport/catalog/slide.rb +17 -0
- data/lib/beatport/catalog/slideshow.rb +30 -0
- data/lib/beatport/catalog/source_type.rb +9 -0
- data/lib/beatport/catalog/state.rb +7 -0
- data/lib/beatport/catalog/track.rb +43 -0
- data/lib/beatport/client.rb +22 -0
- data/lib/beatport/collection.rb +37 -0
- data/lib/beatport/inflector.rb +44 -0
- data/lib/beatport/item.rb +81 -0
- data/lib/beatport/parser.rb +8 -0
- data/lib/beatport/price.rb +8 -0
- data/lib/beatport/query_builder.rb +74 -0
- data/spec/catalog/account_type_spec.rb +16 -0
- data/spec/catalog/artist_spec.rb +83 -0
- data/spec/catalog/audio_format_spec.rb +14 -0
- data/spec/catalog/autocomplete_spec.rb +25 -0
- data/spec/catalog/chart_overview_spec.rb +15 -0
- data/spec/catalog/chart_spec.rb +96 -0
- data/spec/catalog/country_spec.rb +22 -0
- data/spec/catalog/currency_spec.rb +13 -0
- data/spec/catalog/genre_spec.rb +118 -0
- data/spec/catalog/home_spec.rb +16 -0
- data/spec/catalog/item_type_spec.rb +11 -0
- data/spec/catalog/label_spec.rb +103 -0
- data/spec/catalog/mixed_spec.rb +26 -0
- data/spec/catalog/release_spec.rb +138 -0
- data/spec/catalog/search_spec.rb +24 -0
- data/spec/catalog/slide_spec.rb +45 -0
- data/spec/catalog/source_type_spec.rb +11 -0
- data/spec/catalog/track_spec.rb +173 -0
- data/spec/collection_spec.rb +11 -0
- data/spec/inflector_spec.rb +34 -0
- data/spec/item_spec.rb +11 -0
- data/spec/query_builder_spec.rb +100 -0
- data/spec/spec_helper.rb +19 -0
- metadata +251 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module Beatport
|
|
2
|
+
module Catalog
|
|
3
|
+
class Chart < Item
|
|
4
|
+
has_one :audio_format_fee, AudioFormatFee
|
|
5
|
+
has_many :genres, Genre
|
|
6
|
+
has_one :images, Images
|
|
7
|
+
has_one :price, Price
|
|
8
|
+
has_many :tracks, Track
|
|
9
|
+
|
|
10
|
+
def self.find(id)
|
|
11
|
+
Client.retrieve('charts/detail', Chart, :id => id)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.all(*args)
|
|
15
|
+
Client.retrieve 'charts', Chart, *args
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.overview
|
|
19
|
+
ChartOverview.get
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.featured(*args)
|
|
23
|
+
Client.retrieve('featured/charts', Chart, *args)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Beatport
|
|
2
|
+
module Catalog
|
|
3
|
+
class Country < Item
|
|
4
|
+
has_one :currency, Currency
|
|
5
|
+
has_many :states, State
|
|
6
|
+
|
|
7
|
+
def self.all
|
|
8
|
+
Client.retrieve 'countries', Country
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def self.find(code)
|
|
12
|
+
Client.retrieve('countries', Country, :code_short => code).first
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#TODO deprecated in latest api version?
|
|
2
|
+
module Beatport
|
|
3
|
+
module Catalog
|
|
4
|
+
class Feature < Item
|
|
5
|
+
# associated this manually since we don't know the type of the items by default
|
|
6
|
+
attr_reader :items
|
|
7
|
+
|
|
8
|
+
def initialize(data = {})
|
|
9
|
+
item_klass = Inflector.constantize("Beatport::Catalog::#{data['type']}")
|
|
10
|
+
|
|
11
|
+
associate(data, 'items', true, item_klass)
|
|
12
|
+
super
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module Beatport
|
|
2
|
+
module Catalog
|
|
3
|
+
class Genre < Item
|
|
4
|
+
has_many :subgenres, Genre
|
|
5
|
+
# has_many :top_downloads, Track
|
|
6
|
+
# has_one :slideshow, Slideshow
|
|
7
|
+
# has_many :features, Feature
|
|
8
|
+
has_one :counts, Item
|
|
9
|
+
has_one :list, List
|
|
10
|
+
|
|
11
|
+
def self.find(id)
|
|
12
|
+
Client.retrieve('genres', Genre, :id => id, :subgenres => true).first
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.all(*args)
|
|
16
|
+
Client.retrieve('genres', Genre, *args)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.overview
|
|
20
|
+
Client.retrieve('genres/overview', Genre)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def top_downloads
|
|
24
|
+
@top_downloads ||= Track.most_popular_for_genre(id)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def slideshow
|
|
28
|
+
@slideshow ||= Slideshow.find(id)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Beatport
|
|
2
|
+
module Catalog
|
|
3
|
+
class Label < Item
|
|
4
|
+
has_many :genres, Genre
|
|
5
|
+
has_many :subgenres, Genre
|
|
6
|
+
has_many :top_downloads, Track
|
|
7
|
+
has_many :featured_releases, Release
|
|
8
|
+
has_many :most_popular_releases, Release
|
|
9
|
+
has_one :images, Images
|
|
10
|
+
|
|
11
|
+
def self.find(id)
|
|
12
|
+
Client.retrieve('labels/detail', Label, :id => id)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.all(*args)
|
|
16
|
+
Client.retrieve('labels', Label, *args)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.featured(*args)
|
|
20
|
+
Client.retrieve('featured/labels', Label, *args)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def releases(options)
|
|
24
|
+
options[:label_id] = id
|
|
25
|
+
Release.all(options)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module Beatport
|
|
2
|
+
module Catalog
|
|
3
|
+
class Release < Item
|
|
4
|
+
has_many :artists, Artist
|
|
5
|
+
has_one :audio_format_fee, AudioFormatFee
|
|
6
|
+
has_many :genres, Genre
|
|
7
|
+
has_one :images, Images
|
|
8
|
+
has_one :label, Label
|
|
9
|
+
has_one :price, Price
|
|
10
|
+
has_one :recommendations, Recommendations
|
|
11
|
+
has_many :tracks, Track
|
|
12
|
+
has_one :tracks_price, Price
|
|
13
|
+
|
|
14
|
+
def discount
|
|
15
|
+
tracks_price - price
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.find(id)
|
|
19
|
+
Client.retrieve('releases/detail', Release, :id => id)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.all(*args)
|
|
23
|
+
Client.retrieve('releases', Release, *args)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.featured(*args)
|
|
27
|
+
Client.retrieve('featured/releases', Release, *args)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Beatport
|
|
2
|
+
module Catalog
|
|
3
|
+
class Slide < Item
|
|
4
|
+
def self.header(*args)
|
|
5
|
+
Client.retrieve('slideshows/header', Slide, *args)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def self.feature(*args)
|
|
9
|
+
Client.retrieve('slideshows/feature', Slide, *args)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.small(*args)
|
|
13
|
+
Client.retrieve('slideshows/small', Slide, *args)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module Beatport
|
|
2
|
+
module Catalog
|
|
3
|
+
class Slideshow < Item
|
|
4
|
+
attr_accessor :genre_id
|
|
5
|
+
|
|
6
|
+
has_many :header, Slide
|
|
7
|
+
has_many :feature, Slide
|
|
8
|
+
has_many :small, Slide
|
|
9
|
+
|
|
10
|
+
def self.find(id = nil)
|
|
11
|
+
obj = Slideshow.new
|
|
12
|
+
obj.genre_id = id
|
|
13
|
+
obj
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def header
|
|
17
|
+
@header ||= Slide.header(:genre_id => genre_id)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def feature
|
|
21
|
+
@feature ||= Slide.feature(:genre_id => genre_id)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def small
|
|
25
|
+
@small ||= Slide.small(:genre_id => genre_id)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
module Beatport
|
|
2
|
+
module Catalog
|
|
3
|
+
class Track < Item
|
|
4
|
+
has_many :genres, Genre
|
|
5
|
+
has_many :sub_genres, Genre
|
|
6
|
+
has_many :artists, Artist
|
|
7
|
+
has_many :charts, Chart
|
|
8
|
+
has_one :release, Release
|
|
9
|
+
has_one :label, Label
|
|
10
|
+
has_one :price, Price
|
|
11
|
+
has_one :images, Images
|
|
12
|
+
has_one :audio_format_fee, AudioFormatFee
|
|
13
|
+
has_one :key, Keys
|
|
14
|
+
|
|
15
|
+
# Returns the track with the given id
|
|
16
|
+
def self.find(id)
|
|
17
|
+
Client.retrieve('tracks', Track, :id => id).first
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Returns all the tracks matching the criterea
|
|
21
|
+
def self.all(*args)
|
|
22
|
+
Client.retrieve 'tracks', Track, *args
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.most_popular(*args)
|
|
26
|
+
Client.retrieve 'most-popular', Track, *args
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.most_popular_for_genre(*args)
|
|
30
|
+
Client.retrieve "most-popular/genre", Track, *args
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def self.most_popular_for_artist(*args)
|
|
34
|
+
Client.retrieve "most-popular/artist", Track, *args
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def self.most_popular_for_label(*args)
|
|
38
|
+
Client.retrieve "most-popular/label", Track, *args
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Beatport
|
|
2
|
+
module Client
|
|
3
|
+
include HTTParty
|
|
4
|
+
parser Beatport::Parser
|
|
5
|
+
base_uri "http://api.beatport.com/catalog/3"
|
|
6
|
+
format :json
|
|
7
|
+
# default_params :v => '1.0', :format => 'json'
|
|
8
|
+
|
|
9
|
+
def self.retrieve(path, klass, *args)
|
|
10
|
+
result = get("/#{path}", :query => QueryBuilder.process(*args))
|
|
11
|
+
|
|
12
|
+
case result['results']
|
|
13
|
+
when Array
|
|
14
|
+
Collection.new(klass, result)
|
|
15
|
+
when Hash
|
|
16
|
+
klass.new(result['results'])
|
|
17
|
+
else
|
|
18
|
+
raise "results is an unexpected class #{result['results'].class}"
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|