TGV

Thalys

from sys import stdout
from time import time, sleep
import requests
import json


def get_jsonp(*args, **kwargs):
    """Helper to strip JSONP junk out of responses"""
    ans = requests.get(*args, **kwargs)
    return json.loads(ans.content.lstrip(' (\n').rstrip(' );\n'))


# Connection status of the GPRS/LTE modems (link state, networks)
print(requests.get("https://thalysnet.com/connectivity_proxy.php").json())

# Installed system (train number, sytem version)
print(get_jsonp("https://www.ombord.info/api/jsonp/system/"))

# User internet quotas
print(get_jsonp("https://www.ombord.info/api/jsonp/user/"))

# Realtime GPS infos
r = get_jsonp("https://www.ombord.info/api/jsonp/position/")
print(r)

last_speed, last_t = r['speed'], time()

while True:
    response = get_jsonp("https://www.ombord.info/api/jsonp/position/")
    t = time()
    speed = response['speed']
    acceleration = (float(speed) - float(last_speed)) / (t - last_t)
    sleep(2.5)
    last_speed, last_t = speed, t
    speed_ms = float(speed)
    stdout.write("%s km/h (%s m/s^2)              \r" % (speed_ms * 3.6, acceleration))
    stdout.flush()

ICE (TGV allemand)

Dans les ICE allemand, c'est marrant, on peut discuter en broadcastant de l'UDP dans tout le train : voir UDPirc Spécificité du réseau des différents trains