Files
garbage-truck/README.md
2026-07-13 18:27:26 +08:00

64 lines
2.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 新北市垃圾車提醒 CLI
垃圾車快到你家清運點時終端響鈴macOS 原生通知提醒你。
單檔、純 Python 標準函式庫、零相依。資料來自[新北市資料開放平臺](https://data.ntpc.gov.tw/)(政府資料開放授權條款第 1 版,商用 OK
## 需求
- Python 3macOS 內建即可)
- macOS 才有原生通知;其他平台只有終端響鈴
## 用法
### 1. 找清運點
用路線、里、點名或行政區關鍵字搜,拿到 `lineid` 和經緯度:
```
./garbage.py find 三和路4段191巷
```
```
lineid= 241009 rank= 2 16:26 三重區慈生里 三和路4段191巷67號 (25.079740,121.484319)
```
### 2. 開始盯
把你家那個清運點的經緯度和 `lineid` 餵進去:
```
./garbage.py watch --lat 25.079740 --lng 121.484319 --line 241009
```
每 120 秒打一次即時 API算最近出勤車輛的距離。進到 300 公尺就提醒,車開遠後自動重置以便下一趟再提醒。`Ctrl-C` 結束。
| 參數 | 預設 | 說明 |
|------|------|------|
| `--lat` / `--lng` | 必填 | 你的清運點經緯度 |
| `--line` | 無 | 只看這個 lineid**強烈建議填**,否則拿全市所有車比距離,雜訊大) |
| `--radius` | `300` | 提醒距離(公尺) |
| `--interval` | `120` | 輪詢秒數API 本身 2 分鐘更新一次) |
想背景常駐:`./garbage.py watch ... &`,或交給 `launchd``cron`
### demo
```
./garbage.py demo
```
距離計算自我測試。
## 注意
- 即時 API **只顯示目前出勤中的車**,離峰/收班時段會抓到 0 筆,這是正常的。
- 政府伺服器憑證缺欄位,程式關閉了 TLS 憑證驗證(公開唯讀資料,風險僅止於被餵假座標)。
## 資料來源
- 即時動態:`28ab4122-60e1-4065-98e5-abccb69aaca6`
- 表定路線:`edc3ad26-8ae7-4916-a00b-bc6048d19bf8`
格式可換 `/json``/csv``/xml`,用 `page``size` 分頁。其他 endpoint 見 <https://data.ntpc.gov.tw/openapi>。