Skip to content

Commit

Permalink
Added to_json() function
Browse files Browse the repository at this point in the history
  • Loading branch information
jjoeldaniel committed Dec 25, 2022
1 parent 9064a78 commit 5ab2d44
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions geniusdotpy/album.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from geniusdotpy.utils import *

class Album:

def __init__(self, album_info):
Expand All @@ -10,3 +12,8 @@ def __init__(self, album_info):

def __str__(self):
return self.name

def to_json(self):
"""Returns a JSON object of the album"""

return format_json(self.album_info)
6 changes: 6 additions & 0 deletions geniusdotpy/artist.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from geniusdotpy.track import Track
from geniusdotpy.utils import *


class Artist:
Expand All @@ -11,3 +12,8 @@ def __init__(self, artist_info, tracks_info):
self.name = self.artist_info['name']
self.url = self.artist_info['url']
self.path = self.artist_info['api_path']

def to_json(self):
"""Returns a JSON object of the artist"""

return format_json(self.artist_info)
6 changes: 6 additions & 0 deletions geniusdotpy/track.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import datetime
from geniusdotpy.lyrics import Lyrics
from geniusdotpy.album import Album
from geniusdotpy.utils import *


class Track:
Expand Down Expand Up @@ -65,6 +66,11 @@ def __init__(self, track_info):
def __str__(self):
return self.full_title

def to_json(self):
"""Returns a JSON object of the track"""

return format_json(self.track_info)

def release_date(self):
"""Returns the release date of the track as a datetime object"""

Expand Down

0 comments on commit 5ab2d44

Please sign in to comment.