Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add handling MTR ETA API isdelay #8

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

desmondlsl
Copy link
Contributor

@desmondlsl desmondlsl commented Oct 26, 2024

MTR ETA API has a field isdelay. This field is currently unused on our end. This PR adds handling the isdelay field.

This PR appends " - Delay/ Incident/ Special Service"/ " - 延誤/事故/特別服務" in the remark

Note

It seems that isdelay is a line-level property, even though some stations in that line are actually not directly affected. See example below.
I am open to the remark suffix. Please refer to hkbus/hk-independent-bus-eta#207 for UI preview.

https://opendata.mtr.com.hk/doc/Next_Train_DataDictionary_v1.6.pdf
Isdelay (optional)
Strings
Indicate if the train is delayed.
Value:
"Y" = train is delayed
“N” = train is running on time


Sample MTR ETA API response payload during

為配合今年十月二十六日深夜在欣澳與東涌站之間進行的大型路軌改道工程,往來東涌與欣澳站的列車服務,將於當晚提前於晚上約十一時許停止

由東涌站往香港站的最後一班列車將於約十一時零一分開出
由香港站往東涌站的最後一班列車將於約十一時零七分開出,列車約於十一時三十五分抵達東涌站後,介乎欣澳與東涌站的列車服務就會停止

新聞稿:配合東涌綫延綫大型路軌改道工程 十月二十六日來往東涌至欣澳站的列車服務將於晚上十一時許終止 https://www.mtr.com.hk/archive/corporate/en/press_release/PR-24-047-C.pdf

TCL-TSY is also marked isdelay, although it is not one of the directly affected station.

{
    "status": 1,
    "message": "successful",
    "sys_time": "2024-10-26 22:30:00",
    "curr_time": "2024-10-26 22:30:00",
    "data": {
        "TCL-TSY": {
            "curr_time": "2024-10-26 22:30:00",
            "sys_time": "2024-10-26 22:30:00",
            "UP": [
                {
                    "ttnt": "2",
                    "valid": "Y",
                    "plat": "3",
                    "time": "2024-10-26 22:30:00",
                    "source": "-",
                    "dest": "TUC",
                    "seq": "1"
                },
                {
                    "ttnt": "11",
                    "valid": "Y",
                    "plat": "3",
                    "time": "2024-10-26 22:41:00",
                    "source": "-",
                    "dest": "TUC",
                    "seq": "2"
                },
                {
                    "ttnt": "21",
                    "valid": "Y",
                    "plat": "3",
                    "time": "2024-10-26 22:51:00",
                    "source": "+",
                    "dest": "TUC",
                    "seq": "3"
                },
                {
                    "ttnt": "32",
                    "valid": "Y",
                    "plat": "3",
                    "time": "2024-10-26 23:02:00",
                    "source": "+",
                    "dest": "TUC",
                    "seq": "4"
                }
            ],
            "DOWN": [
                {
                    "ttnt": "8",
                    "valid": "Y",
                    "plat": "4",
                    "time": "2024-10-26 22:37:00",
                    "source": "-",
                    "dest": "HOK",
                    "seq": "1"
                },
                {
                    "ttnt": "17",
                    "valid": "Y",
                    "plat": "4",
                    "time": "2024-10-26 22:47:00",
                    "source": "+",
                    "dest": "HOK",
                    "seq": "2"
                },
                {
                    "ttnt": "27",
                    "valid": "Y",
                    "plat": "4",
                    "time": "2024-10-26 22:57:00",
                    "source": "+",
                    "dest": "HOK",
                    "seq": "3"
                },
                {
                    "ttnt": "36",
                    "valid": "Y",
                    "plat": "4",
                    "time": "2024-10-26 23:06:00",
                    "source": "+",
                    "dest": "HOK",
                    "seq": "4"
                }
            ]
        }
    },
    "isdelay": "Y"
}

Response after this PR:

[
    {
        "eta": "2024-10-26T22:37:00+08:00",
        "remark": {
            "zh": "4號月台 - 延誤/事故/特別服務",
            "en": "Platform 4 - Delay/ Incident/ Special Service"
        },
        "dest": {
            "zh": "香港",
            "en": "Hong Kong"
        },
        "co": "mtr"
    },
    {
        "eta": "2024-10-26T22:47:00+08:00",
        "remark": {
            "zh": "4號月台 - 延誤/事故/特別服務",
            "en": "Platform 4 - Delay/ Incident/ Special Service"
        },
        "dest": {
            "zh": "香港",
            "en": "Hong Kong"
        },
        "co": "mtr"
    },
    {
        "eta": "2024-10-26T22:57:00+08:00",
        "remark": {
            "zh": "4號月台 - 延誤/事故/特別服務",
            "en": "Platform 4 - Delay/ Incident/ Special Service"
        },
        "dest": {
            "zh": "香港",
            "en": "Hong Kong"
        },
        "co": "mtr"
    },
    {
        "eta": "2024-10-26T23:06:00+08:00",
        "remark": {
            "zh": "4號月台 - 延誤/事故/特別服務",
            "en": "Platform 4 - Delay/ Incident/ Special Service"
        },
        "dest": {
            "zh": "香港",
            "en": "Hong Kong"
        },
        "co": "mtr"
    }
]

@desmondlsl desmondlsl changed the title add mtr isdelay Add handling MTR ETA API isdelay Oct 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant