From 520a666b3dac2ced1d5ca97e91ce3c60e4889a74 Mon Sep 17 00:00:00 2001
From: Edward Betts <edward@4angle.com>
Date: Fri, 21 Feb 2025 17:08:48 -0500
Subject: [PATCH] Add README.md

---
 README.md | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)
 create mode 100644 README.md

diff --git a/README.md b/README.md
new file mode 100644
index 0000000..9cc9919
--- /dev/null
+++ b/README.md
@@ -0,0 +1,81 @@
+# Ferrocarril Central Monitor
+
+Check for new train schedules on the Ferrocarril Central Andino line from Lima to Huancayo.
+
+This script monitors the Ferrocarril Central Andino website (`https://ferrocarrilcentral.com.pe/appfcca/`) for available travel dates, compares them against previously seen dates, and sends an email notification when new dates are detected. Designed to run as a cron job for automated daily checks.
+
+- **Author**: Edward Betts
+- **Email**: edward@4angle.com
+- **Repository**: https://git.4angle.com/edward/ferrocarrilcentral
+- **License**: MIT
+
+## Installation
+
+1. **Clone the Repository**:
+   ```bash
+   git clone https://git.4angle.com/edward/ferrocarrilcentral.git
+   cd ferrocarrilcentral
+   ```
+
+2. **Install Dependencies**:
+   Requires Python 3 and the following packages:
+   ```bash
+   pip install requests lxml
+   ```
+
+3. **Make Executable**:
+   ```bash
+   chmod +x check.py
+   ```
+
+## Usage
+
+Run the script manually to test:
+```bash
+./check.py
+```
+
+For automated monitoring, add it to your crontab to run twice daily (e.g., 8 AM and 8 PM):
+```bash
+crontab -e
+```
+Add this line:
+```
+0 8,20 * * * /home/edward/src/ferrocarrilcentral/check.py
+```
+
+- **Interactive Mode**: Outputs informational messages (e.g., "New dates found") to stdout.
+- **Cron Mode**: Silent unless errors occur, which are logged to stdout (captured by cron).
+
+## Configuration
+
+1. **Config File**:
+   Create `~/.config/ferrocarril/config` (INI format) with your SMTP settings:
+   ```
+   [mail]
+   smtp_host = your.smtp.server
+   from_address = your.email@example.com
+   to_address = recipient@example.com
+   ```
+
+2. **Data Storage**:
+   - Previously seen dates are stored in `~/lib/data/ferrocarril_dates.json`.
+   - The script creates this file automatically on the first successful run.
+
+## How It Works
+
+1. Fetches the webpage from `https://ferrocarrilcentral.com.pe/appfcca/`.
+2. Parses available travel dates using `lxml.html`.
+3. Compares against dates in `~/lib/data/ferrocarril_dates.json`.
+4. Sends an email if new dates are found and updates the JSON file.
+
+## Requirements
+
+- Python 3.6+
+- `requests` library for HTTP requests
+- `lxml` library for HTML parsing
+- An SMTP server for email notifications
+
+## License
+
+This project is licensed under the MIT License.