apple_music 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.env.example +4 -0
  3. data/.gitignore +4 -0
  4. data/.rubocop.yml +11 -10
  5. data/.ruby-gemset +1 -0
  6. data/.ruby-version +1 -0
  7. data/Gemfile +1 -0
  8. data/Gemfile.lock +50 -35
  9. data/README.md +223 -1
  10. data/apple_music.gemspec +2 -1
  11. data/bin/console +3 -9
  12. data/bin/setup +1 -0
  13. data/lib/apple_music.rb +36 -0
  14. data/lib/apple_music/activity.rb +52 -0
  15. data/lib/apple_music/activity/attributes.rb +19 -0
  16. data/lib/apple_music/activity/relationships.rb +16 -0
  17. data/lib/apple_music/album.rb +62 -0
  18. data/lib/apple_music/album/attributes.rb +50 -0
  19. data/lib/apple_music/album/relationships.rb +18 -0
  20. data/lib/apple_music/apple_curator.rb +10 -0
  21. data/lib/apple_music/apple_curator/attributes.rb +19 -0
  22. data/lib/apple_music/apple_curator/relationships.rb +16 -0
  23. data/lib/apple_music/artist.rb +67 -0
  24. data/lib/apple_music/artist/attributes.rb +19 -0
  25. data/lib/apple_music/artist/relationships.rb +20 -0
  26. data/lib/apple_music/artwork.rb +30 -0
  27. data/lib/apple_music/chart.rb +33 -0
  28. data/lib/apple_music/chart_response.rb +21 -0
  29. data/lib/apple_music/config.rb +45 -0
  30. data/lib/apple_music/connection.rb +45 -0
  31. data/lib/apple_music/curator.rb +52 -0
  32. data/lib/apple_music/curator/attributes.rb +19 -0
  33. data/lib/apple_music/curator/relationships.rb +16 -0
  34. data/lib/apple_music/editorial_notes.rb +13 -0
  35. data/lib/apple_music/error.rb +27 -0
  36. data/lib/apple_music/genre.rb +38 -0
  37. data/lib/apple_music/genre/attributes.rb +16 -0
  38. data/lib/apple_music/music_video.rb +76 -0
  39. data/lib/apple_music/music_video/attributes.rb +42 -0
  40. data/lib/apple_music/music_video/relationships.rb +18 -0
  41. data/lib/apple_music/play_parameters.rb +13 -0
  42. data/lib/apple_music/playlist.rb +57 -0
  43. data/lib/apple_music/playlist/attributes.rb +45 -0
  44. data/lib/apple_music/playlist/relationships.rb +17 -0
  45. data/lib/apple_music/preview.rb +13 -0
  46. data/lib/apple_music/relationship.rb +23 -0
  47. data/lib/apple_music/resource.rb +57 -0
  48. data/lib/apple_music/response.rb +29 -0
  49. data/lib/apple_music/search.rb +39 -0
  50. data/lib/apple_music/search_result.rb +20 -0
  51. data/lib/apple_music/song.rb +81 -0
  52. data/lib/apple_music/song/attributes.rb +39 -0
  53. data/lib/apple_music/song/relationships.rb +19 -0
  54. data/lib/apple_music/station.rb +38 -0
  55. data/lib/apple_music/station/attributes.rb +27 -0
  56. data/lib/apple_music/storefront.rb +32 -0
  57. data/lib/apple_music/storefront/attributes.rb +18 -0
  58. data/lib/apple_music/version.rb +1 -1
  59. metadata +66 -5
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AppleMusic
4
+ class Song < Resource
5
+ # https://developer.apple.com/documentation/applemusicapi/song/relationships
6
+ class Relationships
7
+ attr_reader :albums, :artists, :genres, :station
8
+
9
+ def initialize(props = {})
10
+ @albums = Relationship.new(props['albums']).data
11
+ @artists = Relationship.new(props['artists']).data
12
+ @genres = Relationship.new(props['genres']).data
13
+ @station = Relationship.new(props['station']).data.first
14
+ end
15
+ end
16
+
17
+ self.relationships_model = self::Relationships
18
+ end
19
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AppleMusic
4
+ # https://developer.apple.com/documentation/applemusicapi/station
5
+ class Station < Resource
6
+ class << self
7
+ # e.g. AppleMusic::Station.find('ra.985484166')
8
+ # https://developer.apple.com/documentation/applemusicapi/get_a_catalog_station
9
+ def find(id, **options)
10
+ storefront = Storefront.lookup(options.delete(:storefront))
11
+ response = AppleMusic.get("catalog/#{storefront}/stations/#{id}", options)
12
+ Response.new(response.body).data.first
13
+ end
14
+
15
+ # e.g. AppleMusic::Station.list(ids: ['ra.985484166', 'ra.1128062616'])
16
+ def list(**options)
17
+ raise ParameterMissing, 'required parameter :ids is missing' unless options[:ids]
18
+
19
+ get_collection_by_ids(options.delete(:ids), options)
20
+ end
21
+
22
+ # e.g. AppleMusic::Station.get_collection_by_ids(['ra.985484166', 'ra.1128062616'])
23
+ # https://developer.apple.com/documentation/applemusicapi/get_multiple_catalog_stations
24
+ def get_collection_by_ids(ids, **options)
25
+ ids = ids.is_a?(Array) ? ids.join(',') : ids
26
+ storefront = Storefront.lookup(options.delete(:storefront))
27
+ response = AppleMusic.get("catalog/#{storefront}/stations", options.merge(ids: ids))
28
+ Response.new(response.body).data
29
+ end
30
+
31
+ def search(term, **options)
32
+ AppleMusic.search(**options.merge(term: term, types: :stations)).stations
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ require 'apple_music/station/attributes'
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AppleMusic
4
+ class Station < Resource
5
+ # https://developer.apple.com/documentation/applemusicapi/station/attributes
6
+ class Attributes
7
+ attr_reader :artwork, :duration_in_millis, :editorial_notes,
8
+ :episode_number, :is_live, :name, :url
9
+
10
+ def initialize(props = {})
11
+ @artwork = Artwork.new(props['artwork']) # required
12
+ @duration_in_millis = props['durationInMillis']
13
+ @editorial_notes = EditorialNotes.new(props['editorialNotes']) if props['editorialNotes']
14
+ @episode_number = props['episodeNumber']
15
+ @is_live = props['isLive'] # required
16
+ @name = props['name'] # required
17
+ @url = props['url'] # required
18
+ end
19
+
20
+ def live?
21
+ is_live
22
+ end
23
+ end
24
+
25
+ self.attributes_model = self::Attributes
26
+ end
27
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AppleMusic
4
+ # https://developer.apple.com/documentation/applemusicapi/storefront
5
+ class Storefront < Resource
6
+ class << self
7
+ # https://developer.apple.com/documentation/applemusicapi/get_a_storefront
8
+ def find(id, **options)
9
+ response = AppleMusic.get("storefronts/#{id}", options)
10
+ Response.new(response.body).data.first
11
+ end
12
+
13
+ # https://developer.apple.com/documentation/applemusicapi/get_all_storefronts
14
+ def list(**options)
15
+ response = AppleMusic.get('storefronts', options)
16
+ Response.new(response.body).data
17
+ end
18
+
19
+ def lookup(value, required: true)
20
+ (value || AppleMusic.config.storefront).tap do |storefront|
21
+ raise ParameterMissing, 'required parameter :storefront is missing' if required && !storefront
22
+ end
23
+ end
24
+
25
+ def search(**_options)
26
+ warn 'WARN: :storefronts is not searchable resource'
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ require 'apple_music/storefront/attributes'
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AppleMusic
4
+ class Storefront < Resource
5
+ # https://developer.apple.com/documentation/applemusicapi/storefront/attributes
6
+ class Attributes
7
+ attr_reader :default_language_tag, :name, :support_language_tags
8
+
9
+ def initialize(props = {})
10
+ @default_language_tag = props['defaultLanguageTag'] # required
11
+ @name = props['name'] # required
12
+ @support_language_tags = props['supportedLanguageTags'] # required
13
+ end
14
+ end
15
+
16
+ self.attributes_model = self::Attributes
17
+ end
18
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AppleMusic
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apple_music
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoshiyuki Hirano
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-18 00:00:00.000000000 Z
11
+ date: 2021-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -16,14 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.15.4
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.15.4
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday_middleware
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: jwt
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -87,9 +101,12 @@ executables: []
87
101
  extensions: []
88
102
  extra_rdoc_files: []
89
103
  files:
104
+ - ".env.example"
90
105
  - ".gitignore"
91
106
  - ".rspec"
92
107
  - ".rubocop.yml"
108
+ - ".ruby-gemset"
109
+ - ".ruby-version"
93
110
  - ".travis.yml"
94
111
  - Gemfile
95
112
  - Gemfile.lock
@@ -100,6 +117,50 @@ files:
100
117
  - bin/console
101
118
  - bin/setup
102
119
  - lib/apple_music.rb
120
+ - lib/apple_music/activity.rb
121
+ - lib/apple_music/activity/attributes.rb
122
+ - lib/apple_music/activity/relationships.rb
123
+ - lib/apple_music/album.rb
124
+ - lib/apple_music/album/attributes.rb
125
+ - lib/apple_music/album/relationships.rb
126
+ - lib/apple_music/apple_curator.rb
127
+ - lib/apple_music/apple_curator/attributes.rb
128
+ - lib/apple_music/apple_curator/relationships.rb
129
+ - lib/apple_music/artist.rb
130
+ - lib/apple_music/artist/attributes.rb
131
+ - lib/apple_music/artist/relationships.rb
132
+ - lib/apple_music/artwork.rb
133
+ - lib/apple_music/chart.rb
134
+ - lib/apple_music/chart_response.rb
135
+ - lib/apple_music/config.rb
136
+ - lib/apple_music/connection.rb
137
+ - lib/apple_music/curator.rb
138
+ - lib/apple_music/curator/attributes.rb
139
+ - lib/apple_music/curator/relationships.rb
140
+ - lib/apple_music/editorial_notes.rb
141
+ - lib/apple_music/error.rb
142
+ - lib/apple_music/genre.rb
143
+ - lib/apple_music/genre/attributes.rb
144
+ - lib/apple_music/music_video.rb
145
+ - lib/apple_music/music_video/attributes.rb
146
+ - lib/apple_music/music_video/relationships.rb
147
+ - lib/apple_music/play_parameters.rb
148
+ - lib/apple_music/playlist.rb
149
+ - lib/apple_music/playlist/attributes.rb
150
+ - lib/apple_music/playlist/relationships.rb
151
+ - lib/apple_music/preview.rb
152
+ - lib/apple_music/relationship.rb
153
+ - lib/apple_music/resource.rb
154
+ - lib/apple_music/response.rb
155
+ - lib/apple_music/search.rb
156
+ - lib/apple_music/search_result.rb
157
+ - lib/apple_music/song.rb
158
+ - lib/apple_music/song/attributes.rb
159
+ - lib/apple_music/song/relationships.rb
160
+ - lib/apple_music/station.rb
161
+ - lib/apple_music/station/attributes.rb
162
+ - lib/apple_music/storefront.rb
163
+ - lib/apple_music/storefront/attributes.rb
103
164
  - lib/apple_music/version.rb
104
165
  homepage: https://github.com/yhirano55/apple_music
105
166
  licenses:
@@ -120,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
181
  - !ruby/object:Gem::Version
121
182
  version: '0'
122
183
  requirements: []
123
- rubygems_version: 3.0.3
184
+ rubygems_version: 3.2.9
124
185
  signing_key:
125
186
  specification_version: 4
126
187
  summary: Apple Music API Client Ruby