bbc 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +19 -0
- data/README.md +5 -0
- data/lib/bbc.rb +12 -0
- data/lib/bbc/extensions/array.rb +11 -0
- data/lib/bbc/radio1.rb +8 -0
- data/lib/bbc/radio1/artist.rb +40 -0
- data/lib/bbc/radio1/link.rb +14 -0
- data/lib/bbc/radio1/release.rb +15 -0
- data/lib/bbc/radio1/review.rb +9 -0
- data/lib/bbc/radio1/song.rb +29 -0
- metadata +121 -0
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2010 Oliver Nightingale
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
data/lib/bbc.rb
ADDED
data/lib/bbc/radio1.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
module BBC
|
2
|
+
module Radio1
|
3
|
+
class Artist
|
4
|
+
|
5
|
+
attr_reader :name, :id, :releases, :links, :reviews, :image_url, :related_artists
|
6
|
+
|
7
|
+
def self.find(id)
|
8
|
+
RestClient.get("http://www.bbc.co.uk/music/artists/#{id}.json") do |r|
|
9
|
+
response = JSON.parse(r)
|
10
|
+
new(response['artist'])
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(params)
|
15
|
+
populate_from params
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_details
|
19
|
+
unless @details_retreived
|
20
|
+
RestClient.get("http://www.bbc.co.uk/music/artists/#{id}.json") do |r|
|
21
|
+
response = JSON.parse(r)
|
22
|
+
populate_from response['artist']
|
23
|
+
@details_retreived = true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def populate_from(params)
|
31
|
+
@name = params['name']
|
32
|
+
@id = params['gid']
|
33
|
+
@releases = Array.wrap(params['releases']).map { |release| BBC::Radio1::Release.new(release) }
|
34
|
+
@links = Array.wrap(params['links']).map { |link| BBC::Radio1::Link.new(link) }
|
35
|
+
@related_artists = Array.wrap(params['related_artists']).map { |artist| BBC::Radio1::Artist.new(artist['artist'])}
|
36
|
+
@image_url = params['image'] ? params['image']['src'] : nil
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module BBC
|
2
|
+
module Radio1
|
3
|
+
class Release
|
4
|
+
|
5
|
+
attr_reader :name, :year, :type, :status
|
6
|
+
|
7
|
+
def initialize(params)
|
8
|
+
@name = params['name']
|
9
|
+
@year = params['release_year']
|
10
|
+
@type = params['release_type']
|
11
|
+
@status = params['official']
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module BBC
|
2
|
+
module Radio1
|
3
|
+
class Song
|
4
|
+
|
5
|
+
NOW_PLAYING_API = "http://www.bbc.co.uk/radio1/nowplaying/latest.json"
|
6
|
+
|
7
|
+
attr_reader :artist_gid, :artist, :title
|
8
|
+
|
9
|
+
def self.playing_now
|
10
|
+
RestClient.get(NOW_PLAYING_API) do |response|
|
11
|
+
new(JSON.parse(response)['nowplaying'].first)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.played_recently
|
16
|
+
RestClient.get(NOW_PLAYING_API) do |response|
|
17
|
+
JSON.parse(response)['nowplaying'].slice(1, 6).map { |song| new(song) }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(params)
|
22
|
+
@artist_gid = params['artist_gid']
|
23
|
+
@artist = params['artist']
|
24
|
+
@title = params['title']
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bbc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Oliver Nightingale
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-08-11 00:00:00 +01:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rest-client
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :runtime
|
31
|
+
version_requirements: *id001
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: json
|
34
|
+
prerelease: false
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
segments:
|
40
|
+
- 0
|
41
|
+
version: "0"
|
42
|
+
type: :runtime
|
43
|
+
version_requirements: *id002
|
44
|
+
- !ruby/object:Gem::Dependency
|
45
|
+
name: shoulda
|
46
|
+
prerelease: false
|
47
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
segments:
|
52
|
+
- 0
|
53
|
+
version: "0"
|
54
|
+
type: :development
|
55
|
+
version_requirements: *id003
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: webmock
|
58
|
+
prerelease: false
|
59
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
segments:
|
64
|
+
- 0
|
65
|
+
version: "0"
|
66
|
+
type: :development
|
67
|
+
version_requirements: *id004
|
68
|
+
description:
|
69
|
+
email:
|
70
|
+
- oliver.n@new-bamboo.co.uk
|
71
|
+
executables: []
|
72
|
+
|
73
|
+
extensions: []
|
74
|
+
|
75
|
+
extra_rdoc_files: []
|
76
|
+
|
77
|
+
files:
|
78
|
+
- lib/bbc/extensions/array.rb
|
79
|
+
- lib/bbc/radio1/artist.rb
|
80
|
+
- lib/bbc/radio1/link.rb
|
81
|
+
- lib/bbc/radio1/release.rb
|
82
|
+
- lib/bbc/radio1/review.rb
|
83
|
+
- lib/bbc/radio1/song.rb
|
84
|
+
- lib/bbc/radio1.rb
|
85
|
+
- lib/bbc.rb
|
86
|
+
- LICENSE
|
87
|
+
- README.md
|
88
|
+
has_rdoc: true
|
89
|
+
homepage: http://github.com/olivernn/bbc
|
90
|
+
licenses: []
|
91
|
+
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
segments:
|
102
|
+
- 0
|
103
|
+
version: "0"
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
segments:
|
109
|
+
- 1
|
110
|
+
- 3
|
111
|
+
- 6
|
112
|
+
version: 1.3.6
|
113
|
+
requirements: []
|
114
|
+
|
115
|
+
rubyforge_project:
|
116
|
+
rubygems_version: 1.3.6
|
117
|
+
signing_key:
|
118
|
+
specification_version: 3
|
119
|
+
summary: Ruby Library to interact with the BBC APIs
|
120
|
+
test_files: []
|
121
|
+
|