diff --git a/ksoftapi/__init__.py b/ksoftapi/__init__.py index 462385b..74fa23e 100644 --- a/ksoftapi/__init__.py +++ b/ksoftapi/__init__.py @@ -8,7 +8,7 @@ __author__ = 'AndyTempel' __license__ = 'GNU' __copyright__ = 'Copyright 2018-2020 AndyTempel' -__version__ = '0.3.3a' +__version__ = '0.4.0' import logging from collections import namedtuple diff --git a/ksoftapi/models.py b/ksoftapi/models.py index 96f5fb7..395bb15 100644 --- a/ksoftapi/models.py +++ b/ksoftapi/models.py @@ -1,6 +1,21 @@ from typing import Dict, List, Optional +class Proxy: + def __init__(self, data): + self.__dict__.update(data) + + def __repr__(self): + attributes = (f'{k}={v}' for k, v in self.__dict__.items() if not k.startswith('_')) + return 'Proxy({})'.format(', '.join(attributes)) + + def __iter__(self): + return iter(self.__dict__.items()) + + def __len__(self): + return len(self.__dict__) + + class BanInfo: def __init__(self, data: dict): self.id: str = data['id'] @@ -61,6 +76,8 @@ def __init__(self, data: dict): self.search_str: str = data['search_str'] self.album_art: str = data['album_art'] self.popularity: int = data['popularity'] + self.singalong: List[dict] = data['singalong'] + self.meta: Proxy = Proxy(data['meta']) self.id: str = data['id'] self.search_score: float = data['search_score'] self.url: str = data['url'] @@ -93,6 +110,7 @@ def __init__(self, data: dict): self.youtube_link: str = youtube['link'] self.youtube_title: str = youtube['title'] self.youtube_thumbnail: str = youtube['thumbnail'] + self.youtube_description: str = youtube['description'] self.spotify_id: str = spotify['id'] self.spotify_name: str = spotify['name'] @@ -119,6 +137,7 @@ def __init__(self, data: dict): self.comments: int = data.get('comments') self.created_at: int = data.get('created_at') self.nsfw: bool = data.get('nsfw') + self.awards: int = data.get('awards') self.raw: dict = data @@ -182,7 +201,7 @@ def __init__(self, data: dict): self.postal_code: str = data.get('postal_code') self.region: str = data.get('region') self.timezone: str = data.get('time_zone') - self.apis: Dict[str, str] = data.get('apis') + self.apis: Proxy = Proxy(data.get('apis')) self.raw: dict = data @@ -190,3 +209,4 @@ class Currency: def __init__(self, data: dict): self.value: float = data.get('value') self.pretty: str = data.get('pretty') + self.raw: dict = data