from attr import attrib, attrs @attrs class Category: category_id = attrib(type=int) category_name = attrib(type=str) @attrs class Playlist: image_url = attrib() track_id = attrib() id = attrib() updated_date = attrib() # '2021-11-16', category_id = attrib(type=int) category_name = attrib() name = attrib() country_code = attrib() # '_gl' category_market = attrib(default=None) personalized = attrib(type=bool, default=None) removed_date = attrib(default=None) # specific for history playlist # specific for playlists by track position_change_date = attrib(default=None) current_streams = attrib(default=None) current_position = attrib(default=None) is_new = attrib(default=None) trend = attrib(default=None) followers = attrib(default=None) added_date = attrib(default=None) prev_streams = attrib(default=None) username = attrib(default=None) num_days_on = attrib(default=None) track_id = attrib(default=None) @attrs class HistoryByTrackResponse: next = attrib() # link categories = attrib(converter=lambda items: [Category(**kv) for kv in items]) previous = attrib() items = attrib(converter=lambda items: [Playlist(**kv) for kv in items]) count = attrib(type=int) streams_type = attrib(default=None) num_days_on = attrib(default=None)