def search_storie(id): timestamp, public_key, hash = generate_keys() response = requests.get( 'http://gateway.marvel.com/v1/public/stories/{}?ts={}&apikey={}&hash={}' .format(id, timestamp, public_key, hash)) if response.status_code == 200: story = response.json()['data']['results'][0] return Story(id=story['id'], title=story['title'], description=story['description'], type=story['type']) else: return None
def search_character(id): timestamp, public_key, hash = generate_keys() response = requests.get( 'http://gateway.marvel.com/v1/public/characters/{}?ts={}&apikey={}&hash={}' .format(id, timestamp, public_key, hash)) if response.status_code == 200: character = response.json()['data']['results'][0] return Character(id=character['id'], name=character['name'], description=character['description'], urls=character['urls']) else: return None
def search_event(id): timestamp, public_key, hash = generate_keys() response = requests.get( 'http://gateway.marvel.com/v1/public/events/{}?ts={}&apikey={}&hash={}' .format(id, timestamp, public_key, hash)) if response.status_code == 200: event = response.json()['data']['results'][0] return Event(id=event['id'], title=event['title'], description=event['description'], start=event['start'], end=event['end'], urls=event['urls']) else: return None
def search_comics(id): timestamp, public_key, hash = generate_keys() response = requests.get( 'http://gateway.marvel.com/v1/public/comics/{}?ts={}&apikey={}&hash={}' .format(id, timestamp, public_key, hash)) if response.status_code == 200: comics = response.json()['data']['results'][0] return Comics(id=comics['id'], title=comics['title'], description=comics['description'], format=comics['format'], pageCount=comics['pageCount'], urls=comics['urls']) else: return None
def search_creator(id): timestamp, public_key, hash = generate_keys() response = requests.get( 'http://gateway.marvel.com/v1/public/creators/{}?ts={}&apikey={}&hash={}' .format(id, timestamp, public_key, hash)) if response.status_code == 200: creator = response.json()['data']['results'][0] return Creator(id=creator['id'], firstName=creator['firstName'], middleName=creator['middleName'], lastName=creator['lastName'], suffix=creator['suffix'], fullName=creator['fullName'], urls=creator['urls']) else: return None
def search_serie(id): timestamp, public_key, hash = generate_keys() response = requests.get('http://gateway.marvel.com/v1/public/series/{}?ts={}&apikey={}&hash={}'.format(id,timestamp, public_key, hash)) if response.status_code == 200: serie = response.json()['data']['results'][0] return Series( id=serie['id'], title=serie['title'], rating=serie['rating'], type=serie['type'], startYear=serie['startYear'], endYear=serie['endYear'], urls=serie['urls'] ) else: return None
def find_serie_characters(id, limit, offset): timestamp, public_key, hash = generate_keys() if offset != None: response = requests.get('http://gateway.marvel.com/v1/public/series/{}/characters?limit={}&offset={}&ts={}&apikey={}&hash={}'.format(id, limit, offset, timestamp, public_key, hash)) else: response = requests.get('http://gateway.marvel.com/v1/public/series/{}/characters?limit={}&ts={}&apikey={}&hash={}'.format(id, limit, timestamp, public_key, hash)) if response.status_code == 200: characters = [] for data in response.json()['data']['results']: characters.append(Character( id=data['id'], name=data['name'], description=data['description'], urls=data['urls'] )) return characters else: return None
def find_serie_stories(id, limit, offset): timestamp, public_key, hash = generate_keys() if offset != None: response = requests.get('http://gateway.marvel.com/v1/public/series/{}/stories?limit={}&offset={}&ts={}&apikey={}&hash={}'.format(id, limit, offset, timestamp, public_key, hash)) else: response = requests.get('http://gateway.marvel.com/v1/public/series/{}/stories?limit={}&ts={}&apikey={}&hash={}'.format(id, limit, timestamp, public_key, hash)) if response.status_code == 200: stories = [] for data in response.json()['data']['results']: stories.append(Story( id=data['id'], title=data['title'], description=data['description'], type=data['type'] )) return stories else: return None
def find_serie_events(id, limit, offset): timestamp, public_key, hash = generate_keys() if offset != None: response = requests.get('http://gateway.marvel.com/v1/public/series/{}/events?limit={}&offset={}&ts={}&apikey={}&hash={}'.format(id, limit, offset, timestamp, public_key, hash)) else: response = requests.get('http://gateway.marvel.com/v1/public/series/{}/events?limit={}&ts={}&apikey={}&hash={}'.format(id, limit, timestamp, public_key, hash)) if response.status_code == 200: events = [] for data in response.json()['data']['results']: events.append(Event( id=data['id'], title=data['title'], description=data['description'], start=data['start'], end=data['end'], urls=data['urls'] )) return events else: return None
def find_serie_creators(id, limit, offset): timestamp, public_key, hash = generate_keys() if offset != None: response = requests.get('http://gateway.marvel.com/v1/public/series/{}/creators?limit={}&offset={}&ts={}&apikey={}&hash={}'.format(id, limit, offset, timestamp, public_key, hash)) else: response = requests.get('http://gateway.marvel.com/v1/public/series/{}/creators?limit={}&ts={}&apikey={}&hash={}'.format(id, limit, timestamp, public_key, hash)) if response.status_code == 200: creators = [] for data in response.json()['data']['results']: creators.append(Creator( id=data['id'], firstName=data['firstName'], middleName=data['middleName'], lastName=data['lastName'], suffix=data['suffix'], fullName=data['fullName'], urls=data['urls'] )) return creators else: return None
def list_series(limit, offset): timestamp, public_key, hash = generate_keys() if offset != None: response = requests.get('http://gateway.marvel.com/v1/public/series?limit={}&offset={}&ts={}&apikey={}&hash={}'.format(limit,offset,timestamp, public_key, hash)) else: response = requests.get('http://gateway.marvel.com/v1/public/series?limit={}&ts={}&apikey={}&hash={}'.format(limit,timestamp, public_key, hash)) if response.status_code == 200: series = [] for data in response.json()['data']['results']: series.append(Series( id=data['id'], title=data['title'], rating=data['rating'], type=data['type'], startYear=data['startYear'], endYear=data['endYear'], urls=data['urls'] )) return series else: return None
def find_creator_comics(id, limit, offset): timestamp, public_key, hash = generate_keys() if offset != None: response = requests.get( 'http://gateway.marvel.com/v1/public/creator/{}/comics?limit={}&offset={}&ts={}&apikey={}&hash={}' .format(id, limit, offset, timestamp, public_key, hash)) else: response = requests.get( 'http://gateway.marvel.com/v1/public/creator/{}/comics?limit={}&ts={}&apikey={}&hash={}' .format(id, limit, timestamp, public_key, hash)) if response.status_code == 200: comics = [] for data in response.json()['data']['results']: comics.append( Comics(id=data['id'], title=data['title'], description=data['description'], format=data['format'], pageCount=data['pageCount'], urls=data['urls'])) return comics else: return None