Repository: alltheplaces/alltheplaces

Issue:
Orange Theory Fitness
https://www.orangetheoryfitness.com/locations-list


Discussion:
This issue hasn't been worked on in a while. I'm removing the assignment so others can work on it. If you're still working on it, please reassign yourself and reference a pull request or branch where you're doing your work.

Resolving patch:
diff --git a/locations/spiders/orangetheory_fitness.py b/locations/spiders/orangetheory_fitness.py
new file mode 100644
--- /dev/null
+++ b/locations/spiders/orangetheory_fitness.py
@@ -0,0 +1,76 @@
+# -*- coding: utf-8 -*-
+import json
+
+import scrapy
+
+from locations.items import GeojsonPointItem
+
+
+class OrangetheoryFitnessSpider(scrapy.Spider):
+    name = "orangetheory_fitness"
+    allowed_domains = ['orangetheory.co']
+    start_urls = [
+        'https://api.orangetheory.co/partners/studios/v2?country=United+States',
+        'https://api.orangetheory.co/partners/studios/v2?country=Canada',
+        'https://api.orangetheory.co/partners/studios/v2?country=Australia',
+        'https://api.orangetheory.co/partners/studios/v2?country=Chile',
+        'https://api.orangetheory.co/partners/studios/v2?country=China',
+        'https://api.orangetheory.co/partners/studios/v2?country=Colombia',
+        'https://api.orangetheory.co/partners/studios/v2?country=Costa+Rica',
+        'https://api.orangetheory.co/partners/studios/v2?country=Dominican+Republic',
+        'https://api.orangetheory.co/partners/studios/v2?country=Germany',
+        'https://api.orangetheory.co/partners/studios/v2?country=Guatemala',
+        'https://api.orangetheory.co/partners/studios/v2?country=Hong+Kong',
+        'https://api.orangetheory.co/partners/studios/v2?country=India',
+        'https://api.orangetheory.co/partners/studios/v2?country=Israel',
+        'https://api.orangetheory.co/partners/studios/v2?country=Japan',
+        'https://api.orangetheory.co/partners/studios/v2?country=Kuwait',
+        'https://api.orangetheory.co/partners/studios/v2?country=Mexico',
+        'https://api.orangetheory.co/partners/studios/v2?country=New+Zealand',
+        'https://api.orangetheory.co/partners/studios/v2?country=Peru',
+        'https://api.orangetheory.co/partners/studios/v2?country=Puerto+Rico',
+        'https://api.orangetheory.co/partners/studios/v2?country=Singapore',
+        'https://api.orangetheory.co/partners/studios/v2?country=Spain',
+        'https://api.orangetheory.co/partners/studios/v2?country=United+Arab+Emirates',
+        'https://api.orangetheory.co/partners/studios/v2?country=United+Kingdom',
+    ]
+    download_delay = 0.3
+
+    def parse(self, response):
+        location_data = json.loads(response.text)
+        locations = location_data["data"]
+
+        for location in locations:
+            # Handle junk data
+            if " live" in location[0]['studioName'].lower():  # Skip Orangetheory Live virtual records
+                continue
+            if location[0]['studioLocation']['physicalAddress'] in ["*", "a"]:  # Skip placeholder records
+                continue
+            if location[0]['studioLocation']['longitude'] in ["1.00000000", "0.00000000"]:  # Skip test records
+                continue
+            if location[0]['studioName'] == "LatLong":  # Skip latlon placeholder record
+                continue
+
+            # Handle coordinates
+            if float(location[0]['studioLocation']['latitude']) < -55.0:  # Drop handful of bad coords in Antarctica
+                lat = lon = ''
+            elif float(location[0]['studioLocation']['longitude']) < -180.0:  # Drop handful of bad coords
+                lat = lon = ''
+            else:
+                lat = location[0]['studioLocation']['latitude']
+                lon = location[0]['studioLocation']['longitude']
+
+            properties = {
+                'ref': location[0]['studioId'],
+                'name': location[0]['studioName'],
+                'addr_full': location[0]['studioLocation']['physicalAddress'].strip(),
+                'city': location[0]['studioLocation']['physicalCity'],
+                'state': location[0]['studioLocation']['physicalState'],
+                'postcode': location[0]['studioLocation']['physicalPostalCode'],
+                'country': location[0]['studioLocation']['physicalCountry'],
+                'lat': lat,
+                'lon': lon,
+                'phone': location[0]['studioLocation']['phoneNumber'],
+            }
+
+            yield GeojsonPointItem(**properties)


Test patch: