Esempio n. 1
0
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
Esempio n. 2
0
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