sjaveed / apple_music

A ruby wrapper for the Apple Music API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AppleMusic

This is a ruby wrapper for the Apple Music API.

Installation

Add this line to your application's Gemfile:

gem 'apple_music'

And then execute:

$ bundle

Or install it yourself as:

$ gem install apple_music

Usage

AppleMusic gem was designed with usability as its primary goal:

e.g. Search Artists

artist = AppleMusic::Artist.search('Men I Trust').first # AppleMusic::Artist object
artist.genre_names # ['Electronic']
artist.id # "886240553"
albums = AppleMusic::Artist.related_albums(886240553).map(&:name) # ["Oncle Jazz", "Headroom"...

e.g. Search Albums

albums = AppleMusic::Album.search('BILL EVANS') # AppleMusic::Album object
tracks = AppleMusic::Album.related_tracks(albums[0].id)
tracks.first.name # "Waltz for Debby"

e.g. Search Songs

songs = AppleMusic::Song.search('Document', storefront: :jp) # AppleMusic::Song object
songs[0].artist_name # "TENDRE"
songs[0].album_name # "NOT IN ALMIGHTY"

Features

Currently, it work in progress, so it can use apis which does not need user token.

Albums

Feature Status Docs Code
Get a Catalog Album βœ… πŸ”— :octocat:
Get a Catalog Album's Relationship Directly by Name βœ… πŸ”— :octocat:
Get Multiple Catalog Albums βœ… πŸ”— :octocat:
Get a Library Album β›” πŸ”—
Get a Library Album's Relationship Directly by Name β›” πŸ”—
Get Multiple Library Albums β›” πŸ”—
Get All Library Albums β›” πŸ”—

Artists

Feature Status Docs Code
Get a Catalog Artist βœ… πŸ”— :octocat:
Get Multiple Catalog Artists βœ… πŸ”— :octocat:
Get a Catalog Artist's Relationship Directly by Name βœ… πŸ”— :octocat:
Get a Library Artist β›” πŸ”—
Get All Library Artists β›” πŸ”—
Get Multiple Library Artists β›” πŸ”—
Get a Library Artist's Relationship Directly by Name β›” πŸ”—

Songs

Feature Status Docs Code
Get a Catalog Song βœ… πŸ”— :octocat:
Get Multiple Catalog Songs by ID βœ… πŸ”— :octocat:
Get Multiple Catalog Songs by ISRC βœ… πŸ”— :octocat:
Get a Catalog Song's Relationship Directly by Name βœ… πŸ”— :octocat:
Get a Library Song β›” πŸ”—
Get All Library Songs β›” πŸ”—
Get Multiple Library Songs β›” πŸ”—
Get a Library Song's Relationship Directly by Name β›” πŸ”—

Music Videos

Feature Status Docs Code
Get a Catalog Music Video βœ… πŸ”— :octocat:
Get a Catalog Music Video's Relationship Directly by Name βœ… πŸ”— :octocat:
Get Multiple Catalog Music Videos by ID βœ… πŸ”— :octocat:
Get Multiple Catalog Music Videos by ISRC βœ… πŸ”— :octocat:
Get a Library Music Video β›” πŸ”—
Get a Library Music Video's Relationship Directly by Name β›” πŸ”—
Get Multiple Library Music Videos β›” πŸ”—
Get All Library Music Videos β›” πŸ”—

Playlists

Feature Status Docs Code
Get a Catalog Playlist βœ… πŸ”— :octocat:
Get a Catalog Playlist's Relationship Directly by Name βœ… πŸ”— :octocat:
Get Multiple Catalog Playlists βœ… πŸ”— :octocat:
Get a Library Playlist β›” πŸ”—
Get a Library Playlist's Relationship Directly by Name β›” πŸ”—
Get Multiple Library Playlists β›” πŸ”—
Get All Library Playlists β›” πŸ”—

Apple Music Stations

Feature Status Docs Code
Get a Catalog Station βœ… πŸ”— :octocat:
Get Multiple Catalog Stations βœ… πŸ”— :octocat:

Search

Feature Status Docs Code
Search for Catalog Resources βœ… πŸ”— :octocat:
Get Catalog Search Hints βœ… πŸ”— :octocat:
Search for Library Resources β›” πŸ”—

Ratings

Feature Status Docs Code
Get a Personal Album Rating β›” πŸ”—
Get a Personal Music Video Rating β›” πŸ”—
Get a Personal Playlist Rating β›” πŸ”—
Get a Personal Song Rating β›” πŸ”—
Get a Personal Station Rating β›” πŸ”—
Get Multiple Personal Album Ratings β›” πŸ”—
Get Multiple Personal Music Video Ratings β›” πŸ”—
Get Multiple Personal Playlist Ratings β›” πŸ”—
Get Multiple Personal Song Ratings β›” πŸ”—
Get Multiple Personal Station Ratings β›” πŸ”—
Add a Personal Album Rating β›” πŸ”—
Add a Personal Music Video Rating β›” πŸ”—
Add a Personal Playlist Rating β›” πŸ”—
Add a Personal Song Rating β›” πŸ”—
Add a Personal Station Rating β›” πŸ”—
Delete a Personal Album Rating β›” πŸ”—
Delete a Personal Music Video Rating β›” πŸ”—
Delete a Personal Playlist Rating β›” πŸ”—
Delete a Personal Song Rating β›” πŸ”—
Delete a Personal Station Rating β›” πŸ”—
Get a Personal Library Music Video Rating β›” πŸ”—
Get a Personal Library Playlist Rating β›” πŸ”—
Get a Personal Library Song Rating β›” πŸ”—
Get Multiple Personal Library Music Video Ratings β›” πŸ”—
Get Multiple Personal Library Playlist Ratings β›” πŸ”—
Get Multiple Personal Library Songs Ratings β›” πŸ”—
Add a Personal Library Music Video Rating β›” πŸ”—
Add a Personal Library Playlist Rating β›” πŸ”—
Add a Personal Library Song Rating β›” πŸ”—
Delete a Personal Library Music Video Rating β›” πŸ”—
Delete a Personal Library Playlist Rating β›” πŸ”—
Delete a Personal Library Song Rating β›” πŸ”—

Charts

Feature Status Docs Code
Get Catalog Charts βœ… πŸ”— :octocat:

Music Genres

Feature Status Docs Code
Get a Catalog Genre βœ… πŸ”— :octocat:
Get a Catalog Genre's Relationship Directly by Name βœ… πŸ”— :octocat:
Get Multiple Catalog Genres βœ… πŸ”— :octocat:
Get Catalog Top Charts Genres βœ… πŸ”— :octocat:

Curators

Feature Status Docs Code
Get a Catalog Curator βœ… πŸ”— :octocat:
Get a Catalog Curator's Relationship Directly by Name βœ… πŸ”— :octocat:
Get Multiple Catalog Curators βœ… πŸ”— :octocat:
Get a Catalog Apple Curator β›” πŸ”—
Get a Catalog Apple Curator's Relationship Directly by Name β›” πŸ”—
Get Multiple Catalog Apple Curators β›” πŸ”—

Recommendations

Feature Status Docs Code
Get a Recommendation β›” πŸ”—
Get Multiple Recommendations β›” πŸ”—
Get Default Recommendations β›” πŸ”—

Activities

Feature Status Docs Code
Get a Catalog Activity βœ… πŸ”— :octocat:
Get a Catalog Activity's Relationship Directly by Name βœ… πŸ”— :octocat:
Get Multiple Catalog Activities βœ… πŸ”— :octocat:

History

Feature Status Docs Code
Get Heavy Rotation Content β›” πŸ”—
Get Recently Played Resources β›” πŸ”—
Get Recently Played Stations β›” πŸ”—
Get Recently Added Resources β›” πŸ”—

Storefronts and Localization

Feature Status Docs Code
Get a User's Storefront βœ… πŸ”— :octocat:
Get a Storefront βœ… πŸ”— :octocat:
Get Multiple Storefronts βœ… πŸ”— :octocat:
Get All Storefronts βœ… πŸ”— :octocat:

Configuration

NOTE It's necessary to prepare an TEAM_ID, MUSIC_ID, and a secret file in advance. Please confirm Apple Developer Website.

It can be set by either an ENV variable or an config/initializers/apple_music.rb:

AppleMusic.configure do |config|
  config.secret_key_path = './AuthKey_MUSIC_ID.p8' # or ENV['APPLE_MUSIC_SECRET_KEY_PATH']
  config.team_id         = 'YOUR TEAM_ID'          # or ENV['APPLE_MUSIC_TEAM_ID']
  config.music_id        = 'YOUR MUSIC_ID'         # or ENV['APPLE_MUSIC_MUSIC_ID']
  config.storefront      = 'jp'                    # or ENV['APPLE_MUSIC_STOREFRONT'] ('us' by default)
end

License

MIT

About

A ruby wrapper for the Apple Music API

License:MIT License


Languages

Language:Ruby 99.4%Language:Shell 0.6%