Beispiel #1
0
    def parse_page(self, events_json):
        result = []
        map_client = MapClient()
        for event in events_json['discover_events']:
            if not event['address']:
                continue
            address_dict = map_client.breakdown_address(event['address'])
            if not address_dict:
                continue

            curr_event = Event()
            curr_event.name = helpers.clean_string(event['title'])
            curr_event.description = helpers.clean_string(event['description'])
            curr_event.date = parser.parse(event['start_time'])
            curr_event.place = event['location']
            curr_event.address1 = address_dict['address1']
            curr_event.address2 = None
            curr_event.city = address_dict['city']
            curr_event.state = address_dict['state']
            curr_event.zipcode = address_dict['zipcode']
            curr_event.cost = 0 if not event['price'] else event['price']
            curr_event.link = event['ticket_url']
            curr_event.api = 'https://www.universe.com/api/v2/event_id/' + str(event['id'])
            curr_event.source = self.source
            curr_event.api_id = event['id']
            result.append(curr_event)
        return result
Beispiel #2
0
def import_events() -> [Event]:
    events = []
    events_path = Path('events.json').resolve()

    with open(events_path, 'r') as f:
        data = f.read()
        events_json = json.loads(data)
        for event_json in events_json:
            event = Event(**event_json)
            event.date = datetime.strptime(event_json['date'],
                                           '%Y-%m-%d %H:%M')  # format date
            events.append(event)
        return events
Beispiel #3
0
 def parse_page(self, events_json):
     result = []
     for event in events_json['events']['event']:
         curr_event = Event()
         curr_event.name = helpers.clean_string(event['title'])
         description = helpers.clean_string(event['description'])
         if not description:
             curr_event.description = self.get_alt_description(event['id'])
         curr_event.date = datetime.datetime.strptime(event['start_time'], "%Y-%m-%d %H:%M:%S")
         curr_event.place = event['venue_name']
         curr_event.address1 = helpers.clean_address(event['venue_address'])
         curr_event.address2 = None
         curr_event.city = helpers.clean_city(event['city_name'])
         curr_event.state = event['region_abbr']
         curr_event.zipcode = event['postal_code']
         curr_event.cost = 0 if 'cost' not in event else event['cost']
         curr_event.link = event['url']
         curr_event.api = 'http://api.eventful.com/json/events/get?app_key=' + self.token + '&id=' + event['id']
         curr_event.source = self.source
         curr_event.api_id = event['id']
         result.append(curr_event)
     return result