marcderbauer / songcrawler

Crawl Spotify and Genius for all the songs of your favourite artist!
MIT License
0 stars 0 forks source link

Abstract class #5

Closed marcderbauer closed 1 year ago

marcderbauer commented 1 year ago

Create an abstract class for all the music classes (song, album, ...).

Requested features:

Will definitely need to think this through before implementing.

The main reason for seperating is to have a consistent logic. Music things should be handled by the music class and the songcrawler class should be more of an interface to interact with

Created via Raycast

marcderbauer commented 1 year ago

To make this work well the following changes need to be made:

  1. The requests class should be a subclass of Songcrawler. Songcrawler is the only class that ever instantiates requests, so this makes sense. Mayyyybe leave the option open to directly create albums/songs/etc. from_spotify(), but primary access should happen through requests.
  2. The request class will inherit all the parameters from Songcrawler. A fair bit of this can probably be handled through the super init. This will make it easier to make the correct request in the music class. TODO: Automatically get Spotify type in constructor if the request is of type spotify. More on this below in notes.
  3. The music class recieves a .request(r) with r being a request object from songcrawler. The .request method is a classmethod which instantiates the correct music object (Artist, song, etc.)
  4. When instantiating the object, the object will generally start querying automatically based on the request. The finished, queried object can then be returned to Songcrawler sc. If the type is album, then I need to still handle the logic for saving.
  5. Maybe don't save when instantiating. Best to just return the object. The sc class then calls the .save method or in case of an artists queries each album and then .saves it. This allows for additional steps before saving, for example running sentiment analysis on the lyrics or smth like that.

Notes: -Still need to handle all the genius stuff. May need to create an additional genius class wrapper? Need to look more into how the genius requests work, but for now I only support querying single songs from genius.

marcderbauer commented 1 year ago

The parallel querying from #6 should then be handled within the Album class.

marcderbauer commented 1 year ago

Implemented and works (for spotify classes at least). Still need to work on genius classes, but created a new ticket for that #17