(args, map_dict, step_location, db_update_queue, wh_update_queue)
| 576 | |
| 577 | # todo: this probably shouldn't _really_ be in "models" anymore, but w/e |
| 578 | def parse_map(args, map_dict, step_location, db_update_queue, wh_update_queue): |
| 579 | pokemons = {} |
| 580 | pokestops = {} |
| 581 | gyms = {} |
| 582 | |
| 583 | cells = map_dict['responses']['GET_MAP_OBJECTS']['map_cells'] |
| 584 | for cell in cells: |
| 585 | if config['parse_pokemon']: |
| 586 | for p in cell.get('wild_pokemons', []): |
| 587 | # time_till_hidden_ms was overflowing causing a negative integer. |
| 588 | # It was also returning a value above 3.6M ms. |
| 589 | if 0 < p['time_till_hidden_ms'] < 3600000: |
| 590 | d_t = datetime.utcfromtimestamp( |
| 591 | (p['last_modified_timestamp_ms'] + |
| 592 | p['time_till_hidden_ms']) / 1000.0) |
| 593 | else: |
| 594 | # Set a value of 15 minutes because currently its unknown but larger than 15. |
| 595 | d_t = datetime.utcfromtimestamp((p['last_modified_timestamp_ms'] + 900000) / 1000.0) |
| 596 | |
| 597 | printPokemon(p['pokemon_data']['pokemon_id'], p['latitude'], |
| 598 | p['longitude'], d_t) |
| 599 | pokemons[p['encounter_id']] = { |
| 600 | 'encounter_id': b64encode(str(p['encounter_id'])), |
| 601 | 'spawnpoint_id': p['spawn_point_id'], |
| 602 | 'pokemon_id': p['pokemon_data']['pokemon_id'], |
| 603 | 'latitude': p['latitude'], |
| 604 | 'longitude': p['longitude'], |
| 605 | 'disappear_time': d_t |
| 606 | } |
| 607 | |
| 608 | if args.webhooks: |
| 609 | wh_update_queue.put(('pokemon', { |
| 610 | 'encounter_id': b64encode(str(p['encounter_id'])), |
| 611 | 'spawnpoint_id': p['spawn_point_id'], |
| 612 | 'pokemon_id': p['pokemon_data']['pokemon_id'], |
| 613 | 'latitude': p['latitude'], |
| 614 | 'longitude': p['longitude'], |
| 615 | 'disappear_time': calendar.timegm(d_t.timetuple()), |
| 616 | 'last_modified_time': p['last_modified_timestamp_ms'], |
| 617 | 'time_until_hidden_ms': p['time_till_hidden_ms'] |
| 618 | })) |
| 619 | |
| 620 | for f in cell.get('forts', []): |
| 621 | if config['parse_pokestops'] and f.get('type') == 1: # Pokestops |
| 622 | if 'active_fort_modifier' in f: |
| 623 | lure_expiration = datetime.utcfromtimestamp( |
| 624 | f['last_modified_timestamp_ms'] / 1000.0) + timedelta(minutes=30) |
| 625 | active_fort_modifier = f['active_fort_modifier'] |
| 626 | if args.webhooks and args.webhook_updates_only: |
| 627 | wh_update_queue.put(('pokestop', { |
| 628 | 'pokestop_id': b64encode(str(f['id'])), |
| 629 | 'enabled': f['enabled'], |
| 630 | 'latitude': f['latitude'], |
| 631 | 'longitude': f['longitude'], |
| 632 | 'last_modified_time': f['last_modified_timestamp_ms'], |
| 633 | 'lure_expiration': calendar.timegm(lure_expiration.timetuple()), |
| 634 | 'active_fort_modifier': active_fort_modifier |
| 635 | })) |
no test coverage detected