forked from sp1r/railnation-client
/
collect.py
21 lines (15 loc) · 837 Bytes
/
collect.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import argparse
from server import ServerCaller
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Collect all train spotters')
parser.add_argument('session_id', help='The current PHPSESSID')
parser.add_argument('--server', default='s1.railnation.de', help='The server where the session is active')
args = parser.parse_args()
# let's go
api = ServerCaller(args.server, args.session_id)
# train spotters
spotters = api.call('TrainSpotterInterface', 'getWaitingAndCollected', short_call=1236)
print(f'Found {len(spotters["Body"]["Waiting"]["TrainSpotter"])} train spotters')
collected_spotters = list(
api.bulk_call('TrainSpotterInterface', 'collect', spotters['Body']['Waiting']['TrainSpotter']))
print(f'Collected {len(collected_spotters)} train spotters')