From b98b8bf3ced39afcb04e705d500cd5184d8b5254 Mon Sep 17 00:00:00 2001 From: clarkzjw Date: Thu, 23 Feb 2023 16:45:01 -0800 Subject: - bot: support pleroma instances - status_update() in mastodon.py currently doesn't support content_type, thus it still fallbacks to text/plain on pleroma instances when adding comments --- foursquare/poi.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'foursquare') diff --git a/foursquare/poi.py b/foursquare/poi.py index 39895b7..5e31dc8 100644 --- a/foursquare/poi.py +++ b/foursquare/poi.py @@ -4,6 +4,7 @@ from config import FSQ_API_KEY from dbstore.peewee_store import create_or_update_poi POI_API_ENDPOINT = "https://api.foursquare.com/v3/places/nearby?ll={}%2C{}&limit=10" +POI_DETAIL_ENDPOINT = "https://api.foursquare.com/v3/places/{}" POI_SEARCH_API_ENDPOINT = "https://api.foursquare.com/v3/places/search?query={}&ll={}%2C{}&radius=2000&limit=10" POI_PHOTO_ENDPOINT = "https://api.foursquare.com/v3/places/{}/photos?sort=POPULAR&limit=10" OSM_ENDPOINT = "https://www.openstreetmap.org/?mlat={}&mlon={}&zoom=15&layers=M" @@ -35,6 +36,26 @@ def query_poi(search, latitude, longitude): return locations +def query_poi_by_fsq_id(fsq_id): + url = POI_DETAIL_ENDPOINT.format(fsq_id) + response = requests.get(url, headers=headers) + + poi = json.loads(response.text) + + loc = { + "fsq_id": fsq_id, + "name": poi["name"], + "locality": poi["location"]["locality"] if "locality" in poi["location"] else "", + "region": poi["location"]["region"] if "region" in poi["location"] else "", + "latitude": poi["geocodes"]["main"]["latitude"], + "longitude": poi["geocodes"]["main"]["longitude"], + "osm_url": OSM_ENDPOINT.format(poi["geocodes"]["main"]["latitude"], poi["geocodes"]["main"]["longitude"]) + } + create_or_update_poi(loc) + + return loc + + def get_poi_top_photo(fsq_id): url = POI_PHOTO_ENDPOINT.format(fsq_id) response = requests.get(url, headers=headers) -- cgit v1.2.3