Repository: alltheplaces/alltheplaces

Issue:
Allsups/Yesway
The locations for both are present on both location pages, but the spider only handles Allsups:

https://yesway.com/locations/
https://allsups.com/allsups-locations/

Looks like a buyout or so.



Discussion:

Resolving patch:
diff --git a/locations/spiders/allsups.py b/locations/spiders/allsups.py
deleted file mode 100644
--- a/locations/spiders/allsups.py
+++ /dev/null
@@ -1,32 +0,0 @@
-import scrapy
-
-from locations.items import Feature
-from locations.spiders.vapestore_gb import clean_address
-
-
-class AllsupsSpider(scrapy.Spider):
-    name = "allsups"
-    item_attributes = {"brand": "Allsup's", "brand_wikidata": "Q4733292"}
-    allowed_domains = ["allsups.com"]
-    start_urls = [
-        "https://allsups.com/wp-json/acf/v3/business_locations?_embed&per_page=1000",
-    ]
-
-    def parse(self, response):
-        stores = response.json()
-
-        for store in stores:
-            properties = {
-                "ref": store["acf"]["internal_store_code"],
-                "name": store["acf"]["business_name"],
-                "street_address": clean_address([store["acf"]["address_line_1"], store["acf"]["address_line_2"]]),
-                "city": store["acf"]["city"],
-                "state": store["acf"]["state"],
-                "postcode": store["acf"]["postal_code"],
-                "country": store["acf"]["country"],
-                "lat": store["acf"]["latitude"],
-                "lon": store["acf"]["longitude"],
-                "phone": store["acf"]["primary_phone"],
-            }
-
-            yield Feature(**properties)
diff --git a/locations/spiders/allsups_yesway_us.py b/locations/spiders/allsups_yesway_us.py
new file mode 100644
--- /dev/null
+++ b/locations/spiders/allsups_yesway_us.py
@@ -0,0 +1,44 @@
+import scrapy
+
+from locations.categories import Extras, Fuel, apply_yes_no
+from locations.dict_parser import DictParser
+from locations.hours import DAYS_FULL, OpeningHours
+from locations.spiders.vapestore_gb import clean_address
+
+
+class AllsupsYeswayUSSpider(scrapy.Spider):
+    name = "allsups_yesway_us"
+    allowed_domains = ["allsups.com"]
+    start_urls = [
+        "https://allsups.com/wp-json/acf/v3/business_locations?_embed&per_page=1000",
+    ]
+
+    BRANDS = {
+        "Allsup's": {"brand": "Allsup's", "brand_wikidata": "Q4733292"},
+        "Yesway": {"brand": "Yesway", "brand_wikidata": "Q75851666"},
+    }
+
+    def parse(self, response):
+        for store in response.json():
+            item = DictParser.parse(store["acf"])
+            item["ref"] = store["acf"]["internal_store_code"]
+            item["phone"] = store["acf"]["primary_phone"]
+            item["street_address"] = clean_address([store["acf"]["address_line_1"], store["acf"]["address_line_2"]])
+
+            if brand := self.BRANDS.get(store["acf"]["business_name"]):
+                item.update(brand)
+
+            apply_yes_no(Extras.ATM, item, "atm" in store["acf"]["amenities"])
+            apply_yes_no(Extras.CAR_WASH, item, "car_wash" in store["acf"]["amenities"])
+            apply_yes_no(Fuel.DIESEL, item, "diesel_fuel" in store["acf"]["amenities"])
+            apply_yes_no(Fuel.E85, item, "e85_fuel" in store["acf"]["amenities"])
+
+            if "twenty_four_hour" in store["acf"]["amenities"]:
+                item["opening_hours"] = "24/7"
+            else:
+                item["opening_hours"] = OpeningHours()
+                for day in DAYS_FULL:
+                    if times := store["acf"].get(day.lower(), "").replace(" - ", "-"):
+                        item["opening_hours"].add_range(day, *times.split("-"), time_format="%I:%M%p")
+
+            yield item


Test patch: