itunes_api 0.6.0 → 0.7.0
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 +4 -4
- data/lib/itunes_api/music/artist.rb +2 -2
- data/lib/itunes_api/music/artist_lookup.rb +9 -5
- data/lib/itunes_api/music/artist_search.rb +10 -4
- data/lib/itunes_api/requests/lookup.rb +8 -5
- data/lib/itunes_api/requests/search.rb +1 -1
- data/lib/itunes_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '086360de32ce5889a48b42076307dad1053d3246'
|
4
|
+
data.tar.gz: 23a2bd2b8077266ba0e7f80b4675f3e21648341a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5254e87655037e9627c841f531977aae91d3cff571dfe717784f1c75e451e77890960b25207cfae7ce392f754604024b53daa7a72570d69522a9585a3a32cf14
|
7
|
+
data.tar.gz: aa4d762126de0bdf0087d2dd56ceba1690eed644ceca577247a269258ddd0afeb19c3ba32774ce08cc154b3699c7e08c9b72583d17e8a3d9905bd5e34fed3864
|
@@ -11,17 +11,21 @@ module ItunesApi
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def artist
|
14
|
-
|
14
|
+
build_artist
|
15
15
|
end
|
16
16
|
|
17
17
|
private
|
18
18
|
|
19
19
|
attr_reader :artist_id
|
20
20
|
|
21
|
-
def build_artist
|
22
|
-
|
23
|
-
|
24
|
-
)
|
21
|
+
def build_artist
|
22
|
+
return lookup unless lookup
|
23
|
+
|
24
|
+
Artist.new(lookup)
|
25
|
+
end
|
26
|
+
|
27
|
+
def lookup
|
28
|
+
@lookup ||= Requests::Lookup.artist_with_albums(artist_id)
|
25
29
|
end
|
26
30
|
end
|
27
31
|
end
|
@@ -11,7 +11,7 @@ module ItunesApi
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def artists
|
14
|
-
@artists ||= artist_ids.map { |id| build_artist(id) }
|
14
|
+
@artists ||= artist_ids.map { |id| build_artist(id) }.compact
|
15
15
|
end
|
16
16
|
|
17
17
|
private
|
@@ -23,9 +23,15 @@ module ItunesApi
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def build_artist(id)
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
if (lookup = lookup(id))
|
27
|
+
Artist.new(lookup)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def lookup(id)
|
32
|
+
Requests::Lookup.artist_with_albums(id)
|
33
|
+
rescue
|
34
|
+
nil
|
29
35
|
end
|
30
36
|
end
|
31
37
|
end
|
@@ -13,6 +13,8 @@ module ItunesApi
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def artist_with_albums
|
16
|
+
return artist unless artist
|
17
|
+
|
16
18
|
artist.merge(albums: albums)
|
17
19
|
end
|
18
20
|
|
@@ -33,11 +35,13 @@ module ItunesApi
|
|
33
35
|
end
|
34
36
|
|
35
37
|
def artist
|
38
|
+
return artist_data unless artist_data
|
39
|
+
|
36
40
|
symbolize_keys(unwrapped(artist_data))
|
37
41
|
end
|
38
42
|
|
39
43
|
def artist_data
|
40
|
-
results.find do |wrappers|
|
44
|
+
@artist_data ||= results.find do |wrappers|
|
41
45
|
wrappers['wrapperType'] == 'artist'
|
42
46
|
end
|
43
47
|
end
|
@@ -45,16 +49,15 @@ module ItunesApi
|
|
45
49
|
def query
|
46
50
|
{
|
47
51
|
entity: 'album',
|
48
|
-
|
52
|
+
id: @artist_id,
|
49
53
|
country: country_code,
|
50
54
|
limit: LIMIT,
|
51
55
|
sort: 'recent'
|
52
56
|
}
|
53
57
|
end
|
54
58
|
|
55
|
-
def unwrapped(
|
56
|
-
hash.delete('wrapperType')
|
57
|
-
hash
|
59
|
+
def unwrapped(data_hash)
|
60
|
+
data_hash.tap { |hash| hash.delete('wrapperType') }
|
58
61
|
end
|
59
62
|
end
|
60
63
|
end
|
data/lib/itunes_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itunes_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mario D’Arco
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|