yhirano55 / apple_music Goto Github PK
View Code? Open in Web Editor NEWA ruby wrapper for the Apple Music API
License: MIT License
A ruby wrapper for the Apple Music API
License: MIT License
Problem:
I was seeing that after having my server running a while, search results for songs that had been returning results were suddenly an empty array. Inspecting the API's results before the gem returned them showed a 401
error.
Looking at the gem's connection.rb
, the client is being memoized with the config.authentication_token
which expires after a day.
One suggestion is to improve the handling of API responses to alert when the request is no longer authenticated. This would have helped me see the real problem immediately.
Another suggestion is to check if the token is expired and initialize a new client with a fresh token.
TypeError: no implicit conversion of nil into String
from apple_music (c78cf4ffa6fe) lib/apple_music/song/attributes.rb:30:in `parse'
from apple_music (c78cf4ffa6fe) lib/apple_music/song/attributes.rb:30:in `initialize'
from apple_music (c78cf4ffa6fe) lib/apple_music/resource.rb:37:in `new'
from apple_music (c78cf4ffa6fe) lib/apple_music/resource.rb:37:in `initialize'
from apple_music (c78cf4ffa6fe) lib/apple_music/resource.rb:27:in `new'
from apple_music (c78cf4ffa6fe) lib/apple_music/resource.rb:27:in `build'
from apple_music (c78cf4ffa6fe) lib/apple_music/relationship.rb:20:in `block in build_list'
from apple_music (c78cf4ffa6fe) lib/apple_music/relationship.rb:20:in `map'
from apple_music (c78cf4ffa6fe) lib/apple_music/relationship.rb:20:in `build_list'
from apple_music (c78cf4ffa6fe) lib/apple_music/relationship.rb:11:in `initialize'
from apple_music (c78cf4ffa6fe) lib/apple_music/search_result.rb:16:in `new'
from apple_music (c78cf4ffa6fe) lib/apple_music/search_result.rb:16:in `initialize'
from apple_music (c78cf4ffa6fe) lib/apple_music/search.rb:20:in `new'
from apple_music (c78cf4ffa6fe) lib/apple_music/search.rb:20:in `search'
from apple_music (c78cf4ffa6fe) lib/apple_music.rb:35:in `search'
from apple_music (c78cf4ffa6fe) lib/apple_music/song.rb:74:in `search'
Context:
ruby: 3.0.4
rails: 6.1
the issue
ArgumentError: wrong number of arguments (given 3, expected 2)
from /usr/local/bundle/gems/apple_music-0.3.1/lib/apple_music/album.rb:47:in `get_relationship'
Same happens when calling ::Apple::Artist.related_albums(artist.id) for instance
PS: If you need that feature now you can call
AppleMusic::Album.get_relationship(raw.id, :artists)
to get the related artists of an album for instance
Right now the secret key must be in a file, but I would like to set it directly.
I have added gem in rails 6 app.
& created a file in config/initializers named apple_music.rb with settings
AppleMusic.configure do |config|
config.secret_key_path = ENV['APPLE_MUSIC_SECRET_KEY_PATH']
config.team_id = ENV['APPLE_MUSIC_TEAM_ID']
config.music_id = ENV['APPLE_MUSIC_MUSIC_ID']
config.storefront = 'us'
end
but gives error saying
undefined method `configure' for AppleMusic:Module
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.