apple_music 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d773101a4961951410d2edccd94c7dd2e76a98fa978eb45983271da26558c4bd
4
- data.tar.gz: a46aa197c924a7408e57bad1b95a050aee764a8e85b00430c58d2e554d09ff62
3
+ metadata.gz: 53da4d8f4beda9db38c165a12f5dc25b4941cef9d412c10ec27687c26bdda481
4
+ data.tar.gz: 6f168c26bf0137c25aa37311f39ea562aea942a0f8128400c355ec1a0fafb451
5
5
  SHA512:
6
- metadata.gz: c29ae368a3bf849a606679e09e43b8a91724abdd0955ac12e64566ada0daaa78e3af98999d2e35c14246f69947e7c2e666819236be19b5d83c6e4185ac2ed5e1
7
- data.tar.gz: 2d9f3ee87e0e8f22033d464110e165ced128c704c92cfe0da9e81c5f2303e3d59e86d5e9286baa1649309d12fbb58f5b7210feb3fefeb8aab9f293335cf0e4dd
6
+ metadata.gz: 9c2c4ca26b493bc697db16d9e7c7affb965e0821c6cd472c3bc6928297f9697dd1b9bbc4493f082ae185089a6b61d40da0c831c9b39dec87f30c20ab5e9c5850
7
+ data.tar.gz: 3dd7b64393d2798c815fbbce73e93655cde9fa85160646073b7a6d50a499954f72d275e0366e2327e6060940756727c36707df2012001f8cd2e02c1dca0fefd4
@@ -0,0 +1,59 @@
1
+ name: test
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+ types:
9
+ - opened
10
+ - synchronize
11
+ - reopened
12
+ schedule:
13
+ - cron: "0 10 * * 5" # JST 19:00 (Fri)
14
+
15
+ env:
16
+ CI: "true"
17
+ RUBYOPT: -EUTF-8
18
+
19
+ jobs:
20
+ test:
21
+ runs-on: ubuntu-latest
22
+
23
+ container: ${{ matrix.ruby }}
24
+
25
+ strategy:
26
+ fail-fast: false
27
+
28
+ matrix:
29
+ ruby:
30
+ - ruby:2.7
31
+ - ruby:3.0
32
+ - rubylang/ruby:master-nightly-bionic
33
+ include:
34
+ - ruby: rubylang/ruby:master-nightly-bionic
35
+ allow_failures: "true"
36
+
37
+ steps:
38
+ - uses: actions/checkout@v2
39
+
40
+ - name: Cache vendor/bundle
41
+ uses: actions/cache@v1
42
+ id: cache_gem
43
+ with:
44
+ path: vendor/bundle
45
+ key: v1-gem-${{ runner.os }}-${{ matrix.ruby }}-${{ github.sha }}
46
+ restore-keys: |
47
+ v1-gem-${{ runner.os }}-${{ matrix.ruby }}-
48
+ continue-on-error: ${{ matrix.allow_failures == 'true' }}
49
+
50
+ - name: bundle update
51
+ run: |
52
+ set -xe
53
+ bundle config path vendor/bundle
54
+ bundle update --jobs $(nproc) --retry 3
55
+ continue-on-error: ${{ matrix.allow_failures == 'true' }}
56
+
57
+ - run: bundle exec rspec
58
+ timeout-minutes: 1
59
+ continue-on-error: ${{ matrix.allow_failures == 'true' }}
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- apple_music (0.2.0)
4
+ apple_music (0.3.0)
5
5
  faraday
6
6
  faraday_middleware
7
7
  jwt (>= 2.2)
@@ -13,14 +13,26 @@ GEM
13
13
  coderay (1.1.3)
14
14
  diff-lcs (1.4.4)
15
15
  dotenv (2.7.6)
16
- faraday (1.3.0)
16
+ faraday (1.5.1)
17
+ faraday-em_http (~> 1.0)
18
+ faraday-em_synchrony (~> 1.0)
19
+ faraday-excon (~> 1.1)
20
+ faraday-httpclient (~> 1.0.1)
17
21
  faraday-net_http (~> 1.0)
22
+ faraday-net_http_persistent (~> 1.1)
23
+ faraday-patron (~> 1.0)
18
24
  multipart-post (>= 1.2, < 3)
19
- ruby2_keywords
25
+ ruby2_keywords (>= 0.0.4)
26
+ faraday-em_http (1.0.0)
27
+ faraday-em_synchrony (1.0.0)
28
+ faraday-excon (1.1.0)
29
+ faraday-httpclient (1.0.1)
20
30
  faraday-net_http (1.0.1)
31
+ faraday-net_http_persistent (1.2.0)
32
+ faraday-patron (1.0.0)
21
33
  faraday_middleware (1.0.0)
22
34
  faraday (~> 1.0)
23
- jwt (2.2.2)
35
+ jwt (2.2.3)
24
36
  method_source (1.0.0)
25
37
  multipart-post (2.1.1)
26
38
  parallel (1.20.1)
@@ -32,7 +44,7 @@ GEM
32
44
  rainbow (3.0.0)
33
45
  rake (13.0.3)
34
46
  regexp_parser (2.0.3)
35
- rexml (3.2.4)
47
+ rexml (3.2.5)
36
48
  rspec (3.10.0)
37
49
  rspec-core (~> 3.10.0)
38
50
  rspec-expectations (~> 3.10.0)
@@ -58,7 +70,7 @@ GEM
58
70
  rubocop-ast (1.4.1)
59
71
  parser (>= 2.7.1.5)
60
72
  ruby-progressbar (1.11.0)
61
- ruby2_keywords (0.0.4)
73
+ ruby2_keywords (0.0.5)
62
74
  unicode-display_width (2.0.0)
63
75
 
64
76
  PLATFORMS
data/README.md CHANGED
@@ -58,6 +58,7 @@ Currently, it work in progress, so it can use apis which does not need user toke
58
58
  | Get a Catalog Album | :white_check_mark: | [:link:](https://developer.apple.com/documentation/applemusicapi/get_a_catalog_album) | [:octocat:](#) |
59
59
  | Get a Catalog Album's Relationship Directly by Name | :white_check_mark: | [:link:](https://developer.apple.com/documentation/applemusicapi/get_a_catalog_album_s_relationship_directly_by_name) | [:octocat:](#) |
60
60
  | Get Multiple Catalog Albums | :white_check_mark: | [:link:](https://developer.apple.com/documentation/applemusicapi/get_multiple_catalog_albums) | [:octocat:](#) |
61
+ | Get Multiple Catalog Albums by UPC | :white_check_mark: | [:link:](https://developer.apple.com/documentation/applemusicapi/get_multiple_catalog_albums_by_upc) | [:octocat:](#) |
61
62
  | Get a Library Album | :no_entry: | [:link:](https://developer.apple.com/documentation/applemusicapi/get_a_library_album) | |
62
63
  | Get a Library Album's Relationship Directly by Name | :no_entry: | [:link:](https://developer.apple.com/documentation/applemusicapi/get_a_library_album_s_relationship_directly_by_name) | |
63
64
  | Get Multiple Library Albums | :no_entry: | [:link:](https://developer.apple.com/documentation/applemusicapi/get_multiple_library_albums) | |
@@ -13,10 +13,15 @@ module AppleMusic
13
13
  end
14
14
 
15
15
  # e.g. AppleMusic::Album.list(ids: [310730204, 19075891])
16
+ # e.g. AppleMusic::Album.list(upc: '8717837013241')
16
17
  def list(**options)
17
- raise ParameterMissing, 'required parameter :ids is missing' unless options[:ids]
18
-
19
- get_collection_by_ids(options.delete(:ids), options)
18
+ if options[:ids]
19
+ get_collection_by_ids(options.delete(:ids), **options)
20
+ elsif options[:upc]
21
+ get_collection_by_upc(options.delete(:upc), **options)
22
+ else
23
+ raise ParameterMissing, 'required parameter :ids or :upc is missing'
24
+ end
20
25
  end
21
26
 
22
27
  # e.g. AppleMusic::Album.get_collection_by_ids([310730204, 19075891])
@@ -28,6 +33,15 @@ module AppleMusic
28
33
  Response.new(response.body).data
29
34
  end
30
35
 
36
+ # e.g. AppleMusic::Album.get_collection_by_upc(8717837013241)
37
+ # https://developer.apple.com/documentation/applemusicapi/get_multiple_catalog_albums_by_upc
38
+ def get_collection_by_upc(upc, **options)
39
+ upc = upc.is_a?(Array) ? upc.join(',') : upc
40
+ storefront = Storefront.lookup(options.delete(:storefront))
41
+ response = AppleMusic.get("catalog/#{storefront}/albums", options.merge('filter[upc]': upc))
42
+ Response.new(response.body).data
43
+ end
44
+
31
45
  # e.g. AppleMusic::Album.get_relationship(310730204, :artists)
32
46
  # https://developer.apple.com/documentation/applemusicapi/get_a_catalog_album_s_relationship_directly_by_name
33
47
  def get_relationship(id, relationship_type, **options)
@@ -2,12 +2,12 @@
2
2
 
3
3
  module AppleMusic
4
4
  class Album < Resource
5
- # https://developer.apple.com/documentation/applemusicapi/album/attributes
5
+ # https://developer.apple.com/documentation/applemusicapi/albums/attributes
6
6
  class Attributes
7
7
  attr_reader :album_name, :artist_name, :artwork, :content_rating,
8
8
  :copyright, :editorial_notes, :genre_names, :is_complete,
9
9
  :is_single, :name, :play_params, :record_label, :release_date,
10
- :track_count, :url, :is_mastered_for_itunes
10
+ :track_count, :url, :is_mastered_for_itunes, :upc
11
11
 
12
12
  def initialize(props = {})
13
13
  @album_name = props['albumName'] # required
@@ -30,6 +30,7 @@ module AppleMusic
30
30
  @track_count = props['trackCount'] # required
31
31
  @url = props['url'] # required
32
32
  @is_mastered_for_itunes = props['isMasteredForItunes'] # required
33
+ @upc = props['upc']
33
34
  end
34
35
 
35
36
  def complete?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AppleMusic
4
- VERSION = '0.2.0'
4
+ VERSION = '0.3.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.2.0
4
+ version: 0.3.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: 2021-04-03 00:00:00.000000000 Z
11
+ date: 2021-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -102,12 +102,12 @@ extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
104
  - ".env.example"
105
+ - ".github/workflows/test.yml"
105
106
  - ".gitignore"
106
107
  - ".rspec"
107
108
  - ".rubocop.yml"
108
109
  - ".ruby-gemset"
109
110
  - ".ruby-version"
110
- - ".travis.yml"
111
111
  - Gemfile
112
112
  - Gemfile.lock
113
113
  - LICENSE.txt
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.6.3
7
- before_install: gem install bundler -v 2.0.1