From d59a94a647ce81ca1999e13b981cc9917bae0790 Mon Sep 17 00:00:00 2001 From: Law Wai Chun Date: Sun, 10 Dec 2023 10:13:20 +0800 Subject: [PATCH] Update source domain & prepare for gmb differentiation --- package.json | 4 ++-- src/index.ts | 33 +++++++++++++++++++++++++++++++-- src/lightRail.ts | 4 ++-- src/lrtfeeder.ts | 4 ++-- src/type.ts | 5 ++++- 5 files changed, 41 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index d3cb80f..af43294 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hk-bus-eta", - "version": "3.1.0", + "version": "3.1.1", "description": "Query the ETA (Estimated Time of Arrival) of HK Bus/Minibus/MTR/Lightrail", "main": "dist/index.js", "module": "esm/index.js", @@ -40,7 +40,7 @@ "bugs": { "url": "https://github.com/hkbus/hk-bus-eta/issues" }, - "homepage": "https://hk-bus-eta.chunlaw.io/", + "homepage": "https://hk-bus-eta.hkbus.app/", "devDependencies": { "@types/jest": "^29.5.4", "jest": "^29.6.4", diff --git a/src/index.ts b/src/index.ts index f765066..3af15a5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -68,6 +68,33 @@ export async function fetchEtas({ bound: bound.mtr, }), ); + } else if (company_id === "gmbHki" && stops.gmbHki) { + _etas = _etas.concat( + await gmb({ + stopId: stops.gmbHki[seq], + gtfsId, + seq, + bound: bound.gmbHki, + }), + ); + } else if (company_id === "gmbKln" && stops.gmbKln) { + _etas = _etas.concat( + await gmb({ + stopId: stops.gmbKln[seq], + gtfsId, + seq, + bound: bound.gmbKln, + }), + ); + } else if (company_id === "gmbNt" && stops.gmbNt) { + _etas = _etas.concat( + await gmb({ + stopId: stops.gmbNt[seq], + gtfsId, + seq, + bound: bound.gmbNt, + }), + ); } } @@ -84,13 +111,15 @@ export async function fetchEtas({ export async function fetchEtaDb(): Promise { return fetch( - "https://hkbus.github.io/hk-bus-crawling/routeFareList.min.json", + "https://data.hkbus.app/routeFareList.min.json", + // or https://hkbus.github.io/hk-bus-crawling/routeFareList.min.json ).then((r) => r.json()); } export async function fetchEtaDbMd5(): Promise { return fetch( - "https://hkbus.github.io/hk-bus-crawling/routeFareList.md5", + "https://data.hkbus.app/routeFareList.md5", + // or https://hkbus.github.io/hk-bus-crawling/routeFareList.md5 ).then((r) => r.text()); } diff --git a/src/lightRail.ts b/src/lightRail.ts index a216ded..24d23af 100644 --- a/src/lightRail.ts +++ b/src/lightRail.ts @@ -66,8 +66,8 @@ export default function fetchEtas({ .join("")}`, }, dest: { - zh: '', - en: '', + zh: "", + en: "", }, co: "lightRail", }; diff --git a/src/lrtfeeder.ts b/src/lrtfeeder.ts index 3fe628d..6b78c79 100644 --- a/src/lrtfeeder.ts +++ b/src/lrtfeeder.ts @@ -66,8 +66,8 @@ export default function fetchEtas({ : ""), }, dest: { - zh: '', - en: '', + zh: "", + en: "", }, co: "lrtfeeder", }, diff --git a/src/type.ts b/src/type.ts index 07e1e27..af1ebbe 100644 --- a/src/type.ts +++ b/src/type.ts @@ -5,7 +5,10 @@ export type Company = | "lrtfeeder" | "gmb" | "lightRail" - | "mtr"; + | "mtr" + | "gmbHki" + | "gmbKln" + | "gmbNt"; export type Terminal = { en: string;