r/madeinpython • u/Fast_Entrance7839 • 21m ago
my python flight search now builds google flights links by encoding the tfs protobuf by hand
i maintain viajante, a free open source flight search in python. until 1.7.0 the google flights links it returned opened the flights home page, so you had to type the search again.
now they go to /travel/flights/search?tfs=. the tfs value is a base64 protobuf message with the airports, dates, passengers, cabin and carry-on count.
there's no .proto file for it, so tfs.py writes the bytes itself. it has a varint writer, a length-delimited writer and a constant for each field number. 13 is the origin airport, 14 is the destination and 8 is passengers.
the field numbers came from probing google flights. checked bags are field 3, and google never echoed that filter back in the probes, so the encoder only writes the zero it saw.