diff options
author | clarkzjw <[email protected]> | 2023-02-23 16:45:01 -0800 |
---|---|---|
committer | clarkzjw <[email protected]> | 2023-02-23 16:46:12 -0800 |
commit | b98b8bf3ced39afcb04e705d500cd5184d8b5254 (patch) | |
tree | b7b9491817e83452f69750655fe240702ab44e0e /foursquare | |
parent | 20b8220a12fc92f95ecae267ce4eb5a80584f564 (diff) | |
download | swarm2fediverse-b98b8bf3ced39afcb04e705d500cd5184d8b5254.tar.gz |
- 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
Diffstat (limited to 'foursquare')
-rw-r--r-- | foursquare/poi.py | 21 |
1 files changed, 21 insertions, 0 deletions
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 | |||
4 | from dbstore.peewee_store import create_or_update_poi | 4 | from dbstore.peewee_store import create_or_update_poi |
5 | 5 | ||
6 | POI_API_ENDPOINT = "https://api.foursquare.com/v3/places/nearby?ll={}%2C{}&limit=10" | 6 | POI_API_ENDPOINT = "https://api.foursquare.com/v3/places/nearby?ll={}%2C{}&limit=10" |
7 | POI_DETAIL_ENDPOINT = "https://api.foursquare.com/v3/places/{}" | ||
7 | POI_SEARCH_API_ENDPOINT = "https://api.foursquare.com/v3/places/search?query={}&ll={}%2C{}&radius=2000&limit=10" | 8 | POI_SEARCH_API_ENDPOINT = "https://api.foursquare.com/v3/places/search?query={}&ll={}%2C{}&radius=2000&limit=10" |
8 | POI_PHOTO_ENDPOINT = "https://api.foursquare.com/v3/places/{}/photos?sort=POPULAR&limit=10" | 9 | POI_PHOTO_ENDPOINT = "https://api.foursquare.com/v3/places/{}/photos?sort=POPULAR&limit=10" |
9 | OSM_ENDPOINT = "https://www.openstreetmap.org/?mlat={}&mlon={}&zoom=15&layers=M" | 10 | OSM_ENDPOINT = "https://www.openstreetmap.org/?mlat={}&mlon={}&zoom=15&layers=M" |
@@ -35,6 +36,26 @@ def query_poi(search, latitude, longitude): | |||
35 | return locations | 36 | return locations |
36 | 37 | ||
37 | 38 | ||
39 | def query_poi_by_fsq_id(fsq_id): | ||
40 | url = POI_DETAIL_ENDPOINT.format(fsq_id) | ||
41 | response = requests.get(url, headers=headers) | ||
42 | |||
43 | poi = json.loads(response.text) | ||
44 | |||
45 | loc = { | ||
46 | "fsq_id": fsq_id, | ||
47 | "name": poi["name"], | ||
48 | "locality": poi["location"]["locality"] if "locality" in poi["location"] else "", | ||
49 | "region": poi["location"]["region"] if "region" in poi["location"] else "", | ||
50 | "latitude": poi["geocodes"]["main"]["latitude"], | ||
51 | "longitude": poi["geocodes"]["main"]["longitude"], | ||
52 | "osm_url": OSM_ENDPOINT.format(poi["geocodes"]["main"]["latitude"], poi["geocodes"]["main"]["longitude"]) | ||
53 | } | ||
54 | create_or_update_poi(loc) | ||
55 | |||
56 | return loc | ||
57 | |||
58 | |||
38 | def get_poi_top_photo(fsq_id): | 59 | def get_poi_top_photo(fsq_id): |
39 | url = POI_PHOTO_ENDPOINT.format(fsq_id) | 60 | url = POI_PHOTO_ENDPOINT.format(fsq_id) |
40 | response = requests.get(url, headers=headers) | 61 | response = requests.get(url, headers=headers) |