def search(self, query): """Fetch/Download anime list from MAL.""" try: response = self.request.execute(path='anime/search?q=%s' % urllib.quote(query), ssl=True) except (request.HttpRequestError, request.HttpStatusError): return False # All the data goes into a new dict to keep because the API # doesn't provide all the information yet. response_data = json.loads(response) data = {} for e in response_data: data[int(e['id'])] = { 'id': int(e['id']), 'title': utils.htmldecode(e['title']), 'type': e['type'], # TV, Movie, OVA, ONA, Special, Music 'episodes': self.getEpisodes(e['episodes']), #'status': e['status'], # finished airing, currently airing, not yet aired 'members_score': float(e['members_score']), 'image': e['image_url'] } return data
def list(self): """Fetch/Download anime list from MAL.""" try: response = self.request.execute(path='animelist/%s' % urllib.quote(self.username), authenticate=True, ssl=True) except (request.HttpRequestError, request.HttpStatusError): return False # All the data goes into a new dict response_data = json.loads(response)['anime'] data = {} for e in response_data: data[int(e['id'])] = { 'id': int(e['id']), 'title': utils.htmldecode(e['title']), 'type': e['type'], # TV, Movie, OVA, ONA, Special, Music 'episodes': self.getEpisodes(e['episodes']), 'status': e['status'], # finished airing, currently airing, not yet aired 'watched_status': e['watched_status'], # watching, completed, on-hold, dropped, plan to watch 'watched_episodes': int(e['watched_episodes']), 'score': int(e['score']), 'image': e['image_url'] } response_data = None return data