From a8a179b0c6a707c7e7ac4f2a7558e806bdbd6bdd Mon Sep 17 00:00:00 2001 From: Nemo Date: Fri, 10 Jan 2025 16:56:33 +0530 Subject: [PATCH] bluetokai fixes. --- out/bluetokai.json | 27 ++++++++++++++++++++++++++- src/bluetokai.py | 21 +++++++++++++++++++-- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/out/bluetokai.json b/out/bluetokai.json index 0637a088..6226f9d6 100644 --- a/out/bluetokai.json +++ b/out/bluetokai.json @@ -1 +1,26 @@ -[] \ No newline at end of file +[ + { + "url": "https://bluetokaicoffee.com/products/blue-tokai-s-cup-tasters-championship-2025", + "name": "Blue Tokai\u2019s Cup Tasters Championship 2025", + "description": "Join us for a sensory challenge and the chance to win a relaxing two-day getaway at Bicode Estate, a tranquil coffee plantation, for you and a plus one \u00a0\nBrought to you in partnership with Benki Brewing Tools and Sangameshwar Coffee Estates, this is a fast-paced contest where every sip counts. Identify the \"odd one out\" in a lineup featuring carefully selected brews.\nThe ChallengeIdentify the \"odd one out\" in a lineup featuring carefully selected brews from Sangameshwar Coffee Estates. It's fast-paced and every sip counts!\nRules and Format\u2615 Triangular Cupping FormatTaste 8 sets of 3 cups. Two are identical, one is different. Can you pick the odd one out?\ud83d\udd12 Rely on Your SensesNo devices or tools allowed.\u23f1 Race Against TimeEach round is 5 minutes\u2014stay focused and finish quickly to stay ahead!\ud83c\udfad Blind TastingNo labels, origins, or roast profiles. It\u2019s just you, your senses, and the coffee.\ud83e\uddf4 Maintain HygieneUse sanitised spoons and hands to maintain hygiene.\ud83c\udfc5 Rounds & ScoringCompete through the prelims, semifinals, and final round. Earn 1 point for each correct guess. In case of a tie, the fastest taster wins.\nRewards That Await\ud83e\udd47 Grand PrizeA two-day stay at Bicode Estate for two, plus a luxury gift hamper.\u00a0\ud83e\udd48 Runner-Up\u20b95000 worth of shopping on our website, and a curated gift hamper.\nDate: 16th February 2025 (Sunday)Time: 11 PM - 4 PM Location: The Pour Room, Koramangala\nPlease Note: Tickets for this event are non-refundable and cannot be transferred to future events.\u00a0", + "startDate": "2025-02-16T11:00:00+05:30", + "endDate": "2025-02-16T16:00:00+05:30", + "image": "https://cdn.shopify.com/s/files/1/0738/1409/files/900_x_1200.png?v=1736233698", + "offers": { + "@type": "Offer", + "price": "300", + "priceCurrency": "INR" + }, + "location": { + "@type": "Place", + "name": "Blue Tokai Coffee Roasters Koramangala", + "url": "https://cafe.bluetokaicoffee.com/koramangala-bengaluru-33591/home", + "address": "Blue Tokai Coffee Roasters Koramangala Bengaluru", + "geo": { + "@type": "GeoCoordinates", + "latitude": 12.94098007, + "longitude": 77.62012452 + } + } + } +] \ No newline at end of file diff --git a/src/bluetokai.py b/src/bluetokai.py index b1edb808..ee47a464 100644 --- a/src/bluetokai.py +++ b/src/bluetokai.py @@ -38,6 +38,13 @@ 12.99609493, 77.6954406 ), + ( + "https://bluetokaicoffee.com/pages/blue-tokai-coffee-roasters-ub-city-bangalore", + "Blue Tokai Coffee Roasters UB City", + r"\bub city\b", + 12.9717222, + 77.59425 + ), # This is not a cafe but their Roastery itself ( "https://maps.app.goo.gl/fssZvwfXuxhaC7G77", @@ -99,6 +106,13 @@ 12.90694327, 77.59912373 ), + ( + "https://bluetokaicoffee.com/pages/blue-tokai-coffee-roasters-aecs-layout" + "Blue Tokai Coffee Roasters AECS Layout", + r"\baecs\b", + 12.9633889, + 77.7095833 + ) ] @@ -141,9 +155,11 @@ def extract_timing(body_html): ) if timing_match: start_hour, start_period, end_hour, end_period = timing_match.groups() - # Convert to 24-hour format start_hour = int(start_hour) % 12 + (12 if start_period.upper() == "PM" else 0) end_hour = int(end_hour) % 12 + (12 if end_period.upper() == "PM" else 0) + # Sometimes we get a listing like Time: 11 PM - 4 PM + if start_hour > end_hour: + start_hour -= 12 return start_hour, end_hour return None @@ -151,7 +167,7 @@ def extract_timing(body_html): def guess_location(body_html): body_text = BeautifulSoup(body_html, "html.parser").get_text() for line in body_text.split("\n"): - if "Bengaluru" in line: + if "Bengaluru" in line or "Koramangala" in line: for location in LOCATIONS: if re.search(location[2], line, re.IGNORECASE): return (location[0], location[1], location[3], location[4]) @@ -163,6 +179,7 @@ def generate_event_object(product_json, variant, date, start_hour, end_hour): ) end_datetime = datetime(date.year, date.month, date.day, end_hour, 0, tzinfo=IST) (location_url, address, lat, lng) = guess_location(product_json["product"]["body_html"]) + event = { "url": f"https://bluetokaicoffee.com/products/{product_json['product']['handle']}", "name": product_json["product"]["title"],