Git Product home page Git Product logo

apple_music's Issues

Handle re-intializing a new client when the auth token expires

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

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'

ArgumentError: wrong number of arguments (given 3, expected 2) when calling relationships

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

undefined method `configure' for AppleMusic:Module

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.