Initial commit
This commit is contained in:
34
musicbrainz_entities.py
Normal file
34
musicbrainz_entities.py
Normal file
@ -0,0 +1,34 @@
|
||||
from typing import List
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
|
||||
class MbArtistCredit:
|
||||
def __init__(self, mb_json):
|
||||
self.id: str = mb_json['artist']['id']
|
||||
self.name: str = mb_json['artist']['name']
|
||||
self.type: str = mb_json['artist']['type']
|
||||
self.country: str = mb_json['artist']['country']
|
||||
self.disambiguation: str = mb_json['artist']['disambiguation']
|
||||
self.join_phrase: str = mb_json['joinphrase']
|
||||
|
||||
|
||||
class MbRecording:
|
||||
def __init__(self, mb_json):
|
||||
self.id: str = mb_json['id']
|
||||
self.title: str = mb_json['title']
|
||||
self.is_video: bool = mb_json['video']
|
||||
self.disambiguation: str = mb_json['disambiguation']
|
||||
self.isrcs: List[str] = mb_json['isrcs']
|
||||
self.first_release_date: datetime = datetime.strptime(mb_json['first-release-date'], '%Y-%m-%d')
|
||||
self.length: timedelta = timedelta(seconds = int(mb_json['length']))
|
||||
self.artist_credit: List[MbArtistCredit] = [MbArtistCredit(artist_credit) for artist_credit in mb_json['artist-credit']]
|
||||
|
||||
|
||||
class MbArtist:
|
||||
def __init__(self, mb_json):
|
||||
self.id: str = mb_json['id']
|
||||
self.name: str = mb_json['name']
|
||||
self.disambiguation: str = mb_json['disambiguation']
|
||||
self.country: str = mb_json['country']
|
||||
# TODO: more
|
||||
|
||||
Reference in New Issue
Block a user