Repository: alltheplaces/alltheplaces

Issue:
Billa
### Brand name

Billa

### Wikidata ID

Q537781 for Austria, Bulgaria and Slovakia; Q42969493 for Czechia

### Store finder url(s)

https://www.billa.at/api/stores
https://www.billa.bg/api/stores
https://www.billa.sk/api/stores

https://www.billa.cz/api/stores


Discussion:
Partially implemented for AT at https://data.alltheplaces.xyz/runs/2023-05-31-05-12-59/stats/billa_at.json

Resolving patch:
diff --git a/locations/hours.py b/locations/hours.py
--- a/locations/hours.py
+++ b/locations/hours.py
@@ -59,6 +59,7 @@
 }
 DAYS_BG = {
     "Понеделник": "Mo",
+    "Пн": "Mo",
     "Пон": "Mo",
     "По": "Mo",
     "Вторник": "Tu",
@@ -67,6 +68,7 @@
     "Ср": "We",
     "Четвъртък": "Th",
     "Че": "Th",
+    "Чт": "Th",
     "Петък": "Fr",
     "Пет": "Fr",
     "Пе": "Fr",
@@ -74,6 +76,7 @@
     "Събота": "Sa",
     "Съб": "Sa",
     "Съ": "Sa",
+    "Сб": "Sa",
     "Неделя": "Su",
     "нед": "Su",
     "Не": "Su",
diff --git a/locations/spiders/billa.py b/locations/spiders/billa.py
new file mode 100644
--- /dev/null
+++ b/locations/spiders/billa.py
@@ -0,0 +1,45 @@
+from scrapy import Spider
+from scrapy.http import JsonRequest
+
+from locations.dict_parser import DictParser
+from locations.hours import DAYS_BG, DAYS_CZ, DAYS_SK, OpeningHours
+
+
+class BILLASpider(Spider):
+    name = "billa"
+    item_attributes = {"brand": "BILLA", "brand_wikidata": "Q537781"}
+    allowed_domains = ["www.billa.at", "www.billa.bg", "www.billa.sk", "www.billa.cz"]
+    start_urls = [
+        "https://www.billa.at/api/stores",
+        "https://www.billa.bg/api/stores",
+        "https://www.billa.sk/api/stores",
+        "https://www.billa.cz/api/stores",
+    ]
+
+    def start_requests(self):
+        for url in self.start_urls:
+            yield JsonRequest(url=url)
+
+    def parse(self, response):
+        for location in response.json():
+            if not location.get("open") and not location.get("openingTimes"):
+                continue
+            item = DictParser.parse(location)
+            item["lon"] = location["coordinate"]["x"]
+            item["lat"] = location["coordinate"]["y"]
+            item["opening_hours"] = OpeningHours()
+            for day_hours in location["openingTimes"]:
+                if len(day_hours.get("times", [])) != 2:
+                    continue
+                if "billa.bg" in response.url:
+                    day_name = DAYS_BG[day_hours["dayOfWeek"][:2].title()]
+                elif "billa.sk" in response.url:
+                    day_name = DAYS_SK[day_hours["dayOfWeek"][:2].title()]
+                elif "billa.cz" in response.url:
+                    day_name = DAYS_CZ[day_hours["dayOfWeek"][:2].title()]
+                else:
+                    day_name = day_hours["dayOfWeek"]
+                item["opening_hours"].add_range(day_name, day_hours["times"][0], day_hours["times"][1])
+            if "parking" in location and "spotCount" in location["parking"]:
+                item["extras"]["capacity:motorcar"] = location["parking"]["spotCount"]
+            yield item
diff --git a/locations/spiders/billa_at.py b/locations/spiders/billa_at.py
deleted file mode 100644
--- a/locations/spiders/billa_at.py
+++ /dev/null
@@ -1,30 +0,0 @@
-from scrapy import Spider
-from scrapy.http import JsonRequest
-
-from locations.dict_parser import DictParser
-from locations.hours import OpeningHours
-
-
-class BILLAATSpider(Spider):
-    name = "billa_at"
-    item_attributes = {"brand": "BILLA", "brand_wikidata": "Q537781"}
-    allowed_domains = ["billa.at"]
-    start_urls = ["https://www.billa.at/api/stores"]
-
-    def start_requests(self):
-        for url in self.start_urls:
-            yield JsonRequest(url=url)
-
-    def parse(self, response):
-        for location in response.json():
-            if not location["open"]:
-                continue
-            item = DictParser.parse(location)
-            item["lon"] = location["coordinate"]["x"]
-            item["lat"] = location["coordinate"]["y"]
-            item["opening_hours"] = OpeningHours()
-            for day_hours in location["openingTimes"]:
-                item["opening_hours"].add_range(day_hours["dayOfWeek"], day_hours["times"][0], day_hours["times"][1])
-            if "parking" in location and "spotCount" in location["parking"]:
-                item["extras"]["capacity:motorcar"] = location["parking"]["spotCount"]
-            yield item


Test patch: