def from_api(ApiData, publicUser): data = filter_output(ApiData, PlaylistTrack.__dict__.keys()) data['added_at'] = dateutil.parser.parse(data['added_at']) playlistTrack = PlaylistTrack(**data) playlistTrack.added_by = publicUser track_data = filter_output(data['track'], media_schema.Track.__dict__.keys()) playlistTrack.track = media_schema.Track(**track_data) return playlistTrack
def from_api(ApiData, album_id=None): data = filter_output(ApiData, Track.__dict__.keys()) track = Track(**data) if 'album' in ApiData: track._album_id = ApiData['album']['id'] elif album_id is not None: track._album_id = album_id return track
def from_api(ApiData, publicUser=None): data = filter_output(ApiData, Playlist.__dict__.keys()) playlist = Playlist(**data) playlist.images = [misc_schema.Image(**img) for img in data['images']] if publicUser: playlist.owner = publicUser else: playlist.owner = user_schema.PublicUser.from_api(data['owner']) return playlist
def from_api(ApiData): data = filter_output(ApiData, Artist.__dict__.keys()) artist = Artist(**data) artist.images = [misc_schema.Image(**img) for img in data['images']] return artist
def from_api(ApiData): data = filter_output(ApiData, Album.__dict__.keys()) album = Album(**data) album._artists_ids = [i['id'] for i in data['artists']] album.images = [misc_schema.Image(**img) for img in data['images']] return album
def from_api(ApiData): data = filter_output(ApiData[0], AudioFeatures.__dict__.keys()) aFeat = AudioFeatures(**data) return aFeat
def from_api(ApiData): fields = list(PublicUser.__dict__.keys()) + list(User.__dict__.keys()) data = filter_output(ApiData, fields) return PublicUser(**data)
def from_api(ApiData): fields = list(PrivateUser.__dict__.keys()) + list(User.__dict__.keys()) data = filter_output(ApiData, fields) user = PrivateUser(**data) user.images = [misc_schema.Image(**img) for img in data['images']] return user