Get faster Renfe Spanish Trains timetables in your terminal.
Project description
Renfe Timetables CLI
Get faster Renfe trains timetables in your terminal, with Python3.7+ support. No longer need to open the browser! Just keep using your terminal 😀
renfe-cli
is written in Rust (since v4.0.0) and published to pypi.org as a Python package (CLI and library).
See the changelog.
NOTE since I am more often using Rodalies trains I have created rodalies-cli. I hope you like it too!
DISCLAIMER: Renfe's GTFS dataset might not be in sync with autonomic train schedules (e.g. Rodalies de la Generalitat de Catalunya), hence Renfe Cercanias train types (e.g.: REGIONAL or MD type) might not be accurate. For that, please use autonomic data/apps (.e.g: rodalies-cli).
Installation
Install Python CLI package renfe-cli
pip install renfe-cli --upgrade
Usage (CLI)
The CLI uses the official and latest Renfe's GTFS dataset, from Horarios de alta velocidad, larga distancia y media distancia.
$ renfe-cli -h
Usage: renfe-cli [options]
Options:
-f ORIGIN Set From origin station
-t DESTINATION Set To destination station
-d, --day DAY Set the Day (default: today's day)
-m, --month MONTH Set the Month (default: today's month)
-y, --year YEAR Set the Year (default: today's year)
-s, --sort Option to sort the timetable by Duration
-h, --help Print this help menu
Getting the timetable
Let's show an example of minimal inputs (origin and destination stations) with specific date:
$ renfe-cli -f girona -t "puerta de atocha" -d 30
Loading GTFS data from Renfe web
Provided input 'girona' does a match with 'Estación de tren Girona'
Provided input 'puerta de atocha' does a match with 'Estación de tren Madrid-Puerta de Atocha'
Today is: 2024-9-29
Searching timetable for date: 2024-9-30
Origin station: Estación de tren Girona
Destination station: Estación de tren Madrid-Puerta de Atocha
=========================TIMETABLE=========================
Train | Departure | Arrival | Duration
-----------------------------------------------------------
AVLO | 05:46 | 09:20 | 03:34
-----------------------------------------------------------
AVE | 06:41 | 10:10 | 03:29
-----------------------------------------------------------
AVE | 08:11 | 11:45 | 03:34
-----------------------------------------------------------
AVE INT | 11:59 | 15:45 | 03:46
-----------------------------------------------------------
AVE | 15:11 | 19:12 | 04:01
-----------------------------------------------------------
AVE | 17:51 | 21:45 | 03:54
===========================================================
Usage (Library)
renfe-cli
can be imported as a python package into your project, offering utilities when willing to deal with the Renfe search web site.
$ python
Python 3.12.6 (main, Sep 8 2024, 13:18:56) [GCC 14.2.1 20240805] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import renfe_cli
>>> renfe = renfe_cli.
renfe_cli.Renfe() renfe_cli.Schedule( renfe_cli.Station( renfe_cli.main() renfe_cli.renfe_cli
>>> renfe = renfe_cli.Renfe()
Loading GTFS data from Renfe web
>>> renfe.filter_station("madrid")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Provided input 'madrid' does match with '[Station { name: "Estación de tren Madrid-Puerta de Atocha", id: "60000" }, Station { name: "Estación de tren Madrid - Atocha Cercanias", id: "18000" }, Station { name: "Estación de tren Madrid-Principe Pio", id: "10000" }, Station { name: "Estación de tren Madrid-Ramon Y Cajal", id: "97201" }, Station { name: "Estación de tren Madrid-Nuevos Ministerios", id: "18002" }, Station { name: "Estación de tren Madrid-Chamartin", id: "17000" }, Station { name: "Estación de tren Madrid-Recoletos", id: "18001" }]' -> There must be ONLY one match
>>> renfe.filter_station("girona")
Provided input 'girona' does a match with 'Station { name: "Estación de tren Girona", id: "79300" }'
<builtins.Station object at 0x77f04173d070>
>>> renfe.print_timetable()
No schedules available...won't print timetable.
>>> renfe.set_train_schedules("79300", "60000", 30, 9, 2024, False)
>>> renfe.print_timetable()
=========================TIMETABLE=========================
Train | Departure | Arrival | Duration
-----------------------------------------------------------
AVLO | 05:46 | 09:20 | 03:34
-----------------------------------------------------------
AVE | 06:41 | 10:10 | 03:29
-----------------------------------------------------------
AVE | 08:11 | 11:45 | 03:34
-----------------------------------------------------------
AVE INT | 11:59 | 15:45 | 03:46
-----------------------------------------------------------
AVE | 15:11 | 19:12 | 04:01
-----------------------------------------------------------
AVE | 17:51 | 21:45 | 03:54
===========================================================
>>> ...
Contribute or Report with Issues
If Renfe's GTFS dataset is being kept not up to date or you find any issue to be fixed or nice enhancements to have, please: create an issue.
Development
This project makes use of Rust bindings for the Python interpreter thanks to pyo3. It is already available as a dependency.
To develop, build and publish, this project makes use of maturin project. See usage.
Example of first time working with this repository:
$ git clone https://github.com/gerardcl/renfe-cli.git && cd renfe-cli
$ python -m venv .venv
$ . .venv/bin/activate
$ pip install -U pip
$ pip install -U maturin
$ maturin develop
🔗 Found pyo3 bindings with abi3 support for Python ≥ 3.7
🐍 Not using a specific python interpreter
📡 Using build options features from pyproject.toml
Compiling renfe-cli v4.1.0 (/path/to/renfe-cli)
Finished dev [unoptimized + debuginfo] target(s) in 7.07s
📦 Built wheel for abi3 Python ≥ 3.7 to /tmp/.tmpDsjowL/renfe_cli-4.1.0-cp37-abi3-linux_x86_64.whl
🛠 Installed renfe-cli-4.1.0
Maturin takes care of compiling the rust code, generating the bindings for python and installing the package for local use (as library or binary/CLI).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file renfe_cli-5.0.0.tar.gz
.
File metadata
- Download URL: renfe_cli-5.0.0.tar.gz
- Upload date:
- Size: 25.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a07486396a64ded52d4a0d921d7229898b6fff14012d66eaec4c8d53b8bbc9f1 |
|
MD5 | adbcfcffa03353d6ead12c424d1868a3 |
|
BLAKE2b-256 | 69364416d693b657546e8d58654c24f2ecc36ab5ebf24b2688df33b1d6295829 |
File details
Details for the file renfe_cli-5.0.0-cp37-abi3-win_amd64.whl
.
File metadata
- Download URL: renfe_cli-5.0.0-cp37-abi3-win_amd64.whl
- Upload date:
- Size: 2.0 MB
- Tags: CPython 3.7+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c374806ba1d549495333a6ab28321d6272e281f58348e4107effd9863cace22 |
|
MD5 | b484ac3f589708e8fe2c4422ab808596 |
|
BLAKE2b-256 | 7ea650bef8c4845677bc0003833f83aa2650d3dc4cce5cc593b213998a84f46c |
File details
Details for the file renfe_cli-5.0.0-cp37-abi3-win32.whl
.
File metadata
- Download URL: renfe_cli-5.0.0-cp37-abi3-win32.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.7+, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c140cfec89470037579e1122acbd2e19c30b18d211c21c19464f0b94a0a4742a |
|
MD5 | 1ccf9f3258b43ed1e89b59ef1476dfcf |
|
BLAKE2b-256 | 65331eed61bc707c5c62894e9efbed602eb530aaba96c40ba9b6247c3341674e |
File details
Details for the file renfe_cli-5.0.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: renfe_cli-5.0.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.4 MB
- Tags: CPython 3.7+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2f106d80699315615d7513a504ff6085d17396f6acf5612e2770b6b8f958013 |
|
MD5 | f7223b07c1b9464d21bf4ad2a2a78546 |
|
BLAKE2b-256 | 857b5bf822eeb3272dd928c03b336974526b3fd257a29ec15e71eeae74a48a94 |
File details
Details for the file renfe_cli-5.0.0-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
.
File metadata
- Download URL: renfe_cli-5.0.0-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
- Upload date:
- Size: 2.4 MB
- Tags: CPython 3.7+, manylinux: glibc 2.17+ s390x
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e48ddc0a3fe15fc13a2859f43e144f4cf955b9ef70d40ae621465d1623c57de |
|
MD5 | d6fb4e906d1a92a5bb7b766605ad3e54 |
|
BLAKE2b-256 | 55f3f83577291d114d2205568bb0e10444afd7e7c71f436b43f392d1ce478a17 |
File details
Details for the file renfe_cli-5.0.0-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
.
File metadata
- Download URL: renfe_cli-5.0.0-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.7+, manylinux: glibc 2.17+ ppc64le
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33ff3db1e47e87714312bd152d54d5381457b74ff551ff7e4959f432bba1f357 |
|
MD5 | fdb1ac1bc8e204205dcabb7db94a3b2b |
|
BLAKE2b-256 | 2b2803c045f3d8152d9a48b78565d88b8a97fd004a8aaec4c726a297efd046ec |
File details
Details for the file renfe_cli-5.0.0-cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
.
File metadata
- Download URL: renfe_cli-5.0.0-cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 2.3 MB
- Tags: CPython 3.7+, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2988784cbd706c9b9d62f4505f88d592bd3c08e24d316ff25d3f6f0765aaabfd |
|
MD5 | e7348d373e1f0f22c2fe9fa406518f91 |
|
BLAKE2b-256 | 03c6510f1cc947c1e678e131d9cb4f3e16bbadd8c1ca9be38482ded59d6c0450 |
File details
Details for the file renfe_cli-5.0.0-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
.
File metadata
- Download URL: renfe_cli-5.0.0-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.7+, manylinux: glibc 2.17+ ARMv7l
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52b2e39cf89a63378353ef272e02328d08a183750f3a66462d9ad1ebcf4017a3 |
|
MD5 | 688926831934069f50c87440011851f9 |
|
BLAKE2b-256 | 81934549b77a8f3e3c9444e560a955a7fde49c546dba53c14f9d005fbbd7601f |
File details
Details for the file renfe_cli-5.0.0-cp37-abi3-macosx_11_0_arm64.whl
.
File metadata
- Download URL: renfe_cli-5.0.0-cp37-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 2.0 MB
- Tags: CPython 3.7+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e57532a58380608992bbc9cfd8cf3b77b9ecd85694f3973afa98254d385cd7e |
|
MD5 | 29be7bf2559630d12957a74d8a78edfd |
|
BLAKE2b-256 | b89be3ee9e075300fbc7e42f2f687ca23912f82b4f02bec8b7d842fc56b25365 |
File details
Details for the file renfe_cli-5.0.0-cp37-abi3-macosx_10_12_x86_64.whl
.
File metadata
- Download URL: renfe_cli-5.0.0-cp37-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.7+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5b44cfaec2f3ec474201942d5027c33e9362df0a012df14dc4f02d40100b6da |
|
MD5 | 4b68f6a289ed0baa7e5c0e642bbe403f |
|
BLAKE2b-256 | 32afafe1e2b7e438aa145d6389b3da2b348612709b6a19ae94330923a09bd368 |