Fix crash on places without a bounding box

Fixes #374
This commit is contained in:
JustAnotherArchivist
2022-02-07 00:38:22 +00:00
parent aa7d7d3dc3
commit 8e95e9a9a7

View File

@@ -548,7 +548,7 @@ class _TwitterAPIScraper(snscrape.base.Scraper):
kwargs['coordinates'] = Coordinates(coords[1], coords[0])
if tweet.get('place'):
kwargs['place'] = Place(tweet['place']['full_name'], tweet['place']['name'], tweet['place']['place_type'], tweet['place']['country'], tweet['place']['country_code'])
if 'coordinates' not in kwargs and tweet['place']['bounding_box'] and (coords := tweet['place']['bounding_box']['coordinates']) and coords[0] and len(coords[0][0]) == 2:
if 'coordinates' not in kwargs and tweet['place'].get('bounding_box') and (coords := tweet['place']['bounding_box']['coordinates']) and coords[0] and len(coords[0][0]) == 2:
# Take the first (longitude, latitude) couple of the "place square"
kwargs['coordinates'] = Coordinates(coords[0][0][0], coords[0][0][1])
if tweet['entities'].get('hashtags'):