-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsummary.py
More file actions
executable file
·60 lines (49 loc) · 1.46 KB
/
summary.py
File metadata and controls
executable file
·60 lines (49 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/python3
import scraper
from datetime import datetime, timedelta
import requests
import sys
import webhook
import time
import traceback
from utils import config, headers
def run():
try:
_run()
except Exception:
traceback.print_exc()
def _run(delta=0):
webhook.clear()
date = datetime.now().date() + timedelta(days=delta)
flights = []
for index, registration in enumerate(config["planes"]):
print(
f"[{index+1} / {len(config['planes'])}] {registration}",
end="",
)
sys.stdout.flush()
current = scraper.getFlights(registration.lower(),
date)
flights.extend(current)
print(f": {len(current)}")
if (index+1 != len(config['planes'])):
time.sleep(5) # ratelimit
print(f"got {len(flights)} flights")
for index, flight in enumerate(flights):
print(f"Generating map ({index + 1} of {len(flights)}) \r", end="")
sys.stdout.flush()
res = requests.get(
f"https://data-live.flightradar24.com/clickhandler/?version=1.5&flight={flight}",
headers=headers,
)
res.raise_for_status()
webhook.generateEmbed("✈️ FLight", res.json())
webhook.delta = delta
webhook.sendMessage()
print()
if __name__ == "__main__":
if len(sys.argv) <= 1:
delta = 0
else:
delta = int(sys.argv[1])
_run(delta=delta)