summaryrefslogtreecommitdiff
path: root/app/scrapers/liquid-room.ts
diff options
context:
space:
mode:
Diffstat (limited to 'app/scrapers/liquid-room.ts')
-rw-r--r--app/scrapers/liquid-room.ts101
1 files changed, 42 insertions, 59 deletions
diff --git a/app/scrapers/liquid-room.ts b/app/scrapers/liquid-room.ts
index b497759..f577ee6 100644
--- a/app/scrapers/liquid-room.ts
+++ b/app/scrapers/liquid-room.ts
@@ -1,9 +1,3 @@
-/**
- * Liquid Room (恵比寿) — https://www.liquidroom.net/schedule
- *
- * The schedule page lists events with JSON-LD or HTML data.
- * Structure: <div class="p-schedule__item"> contains date, title, etc.
- */
import * as cheerio from "cheerio";
import type { Scraper, VenueMeta } from "./base";
import type { EventInput } from "~/lib/db.server";
@@ -24,64 +18,53 @@ export const scraper: Scraper = {
const $ = cheerio.load(html);
const events: EventInput[] = [];
- $("article.p-schedule__item, .schedule-list__item, .c-event-item").each(
- (_, el) => {
- const $el = $(el);
+ $("article").each((_, el) => {
+ const $el = $(el);
- const title =
- $el.find(".p-schedule__title, .event-title, h3, h2").first().text().trim();
- if (!title) return;
+ const href = $el.find("a.s_link").attr("href") ?? "";
+ // Date is encoded in the URL: e.g. /schedule/eventname_20260501
+ const dateMatch = href.match(/_(\d{4})(\d{2})(\d{2})$/);
+ if (!dateMatch) return;
+ const date = `${dateMatch[1]}-${dateMatch[2]}-${dateMatch[3]}`;
- const dateStr =
- $el.find(".p-schedule__date, .event-date, time").first().text().trim() ||
- $el.find("time").attr("datetime") ||
- "";
- const date = parseJapaneseDate(dateStr);
- if (!date) return;
+ const h2 = $el.find("h2").first().text().trim();
+ if (!h2) return;
- const artist =
- $el.find(".p-schedule__artist, .artist").first().text().trim() || null;
- const startTime =
- $el.find(".p-schedule__time, .open-time").first().text().trim().match(/\d{2}:\d{2}/)?.[0] ?? null;
- const ticketUrl =
- $el.find("a[href*='ticket'], a[href*='eplus'], a[href*='pia']").first().attr("href") ?? null;
- const imageUrl =
- $el.find("img").first().attr("src") ?? null;
- const sourceUrl =
- $el.find("a").first().attr("href") ?? null;
+ const subtitle = $el.find("p.subtitle").first().text().trim();
+ // h2 is the artist/band name; subtitle (if present) is the event title
+ const title = subtitle || h2;
+ const artist = subtitle ? h2 : null;
- events.push({
- venue_id: venue.id,
- title,
- artist,
- date,
- start_time: startTime,
- ticket_url: ticketUrl,
- image_url: imageUrl ? absoluteUrl(imageUrl, venue.url) : null,
- source_url: sourceUrl ? absoluteUrl(sourceUrl, venue.url) : null,
- });
- }
- );
+ const openTime =
+ $el
+ .find("dl")
+ .filter((_, dl) => $(dl).find("dt").text().includes("OPEN"))
+ .find("dd")
+ .text()
+ .trim()
+ .match(/\d{2}:\d{2}/)?.[0] ?? null;
+
+ const startTime =
+ $el
+ .find("dl")
+ .filter((_, dl) => $(dl).find("dt").text().includes("START"))
+ .find("dd")
+ .text()
+ .trim()
+ .match(/\d{2}:\d{2}/)?.[0] ?? null;
+
+ events.push({
+ venue_id: venue.id,
+ title,
+ artist,
+ date,
+ open_time: openTime,
+ start_time: startTime,
+ image_url: $el.find("div.left img").attr("src") ?? null,
+ source_url: href,
+ });
+ });
return events;
},
};
-
-function parseJapaneseDate(raw: string): string | null {
- // Handles "2025.06.15" "2025/06/15" "2025年06月15日" "06.15" formats
- const m =
- raw.match(/(\d{4})[./年](\d{1,2})[./月](\d{1,2})/) ||
- raw.match(/(\d{1,2})[./月](\d{1,2})/);
- if (!m) return null;
- if (m.length === 4) {
- return `${m[1]}-${m[2].padStart(2, "0")}-${m[3].padStart(2, "0")}`;
- }
- const year = new Date().getFullYear();
- return `${year}-${m[1].padStart(2, "0")}-${m[2].padStart(2, "0")}`;
-}
-
-function absoluteUrl(url: string, base: string): string {
- if (url.startsWith("http")) return url;
- if (url.startsWith("/")) return base + url;
- return base + "/" + url;
-}