FlightRadarAPI 1.3.30__tar.gz → 1.3.32__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {flightradarapi-1.3.30 → flightradarapi-1.3.32}/FlightRadar24/__init__.py +1 -1
- {flightradarapi-1.3.30 → flightradarapi-1.3.32}/FlightRadar24/api.py +21 -18
- {flightradarapi-1.3.30 → flightradarapi-1.3.32}/FlightRadar24/request.py +3 -1
- {flightradarapi-1.3.30 → flightradarapi-1.3.32}/PKG-INFO +1 -1
- {flightradarapi-1.3.30 → flightradarapi-1.3.32}/.flake8 +0 -0
- {flightradarapi-1.3.30 → flightradarapi-1.3.32}/.gitignore +0 -0
- {flightradarapi-1.3.30 → flightradarapi-1.3.32}/FlightRadar24/core.py +0 -0
- {flightradarapi-1.3.30 → flightradarapi-1.3.32}/FlightRadar24/entities/__init__.py +0 -0
- {flightradarapi-1.3.30 → flightradarapi-1.3.32}/FlightRadar24/entities/airport.py +0 -0
- {flightradarapi-1.3.30 → flightradarapi-1.3.32}/FlightRadar24/entities/entity.py +0 -0
- {flightradarapi-1.3.30 → flightradarapi-1.3.32}/FlightRadar24/entities/flight.py +0 -0
- {flightradarapi-1.3.30 → flightradarapi-1.3.32}/FlightRadar24/errors.py +0 -0
- {flightradarapi-1.3.30 → flightradarapi-1.3.32}/LICENSE +0 -0
- {flightradarapi-1.3.30 → flightradarapi-1.3.32}/README.md +0 -0
- {flightradarapi-1.3.30 → flightradarapi-1.3.32}/pyproject.toml +0 -0
- {flightradarapi-1.3.30 → flightradarapi-1.3.32}/requirements.txt +0 -0
- {flightradarapi-1.3.30 → flightradarapi-1.3.32}/tests/conftest.py +0 -0
- {flightradarapi-1.3.30 → flightradarapi-1.3.32}/tests/package.py +0 -0
- {flightradarapi-1.3.30 → flightradarapi-1.3.32}/tests/test_api.py +0 -0
- {flightradarapi-1.3.30 → flightradarapi-1.3.32}/tests/util.py +0 -0
|
@@ -12,7 +12,7 @@ https://www.flightradar24.com/terms-and-conditions
|
|
|
12
12
|
"""
|
|
13
13
|
|
|
14
14
|
__author__ = "Jean Loui Bernard Silva de Jesus"
|
|
15
|
-
__version__ = "1.3.
|
|
15
|
+
__version__ = "1.3.32"
|
|
16
16
|
|
|
17
17
|
from .api import FlightRadar24API, FlightTrackerConfig
|
|
18
18
|
from .entities import Airport, Entity, Flight
|
|
@@ -37,7 +37,7 @@ class FlightRadar24API(object):
|
|
|
37
37
|
Main class of the FlightRadarAPI
|
|
38
38
|
"""
|
|
39
39
|
|
|
40
|
-
def __init__(self, user: Optional[str] = None, password: Optional[str] = None):
|
|
40
|
+
def __init__(self, user: Optional[str] = None, password: Optional[str] = None, timeout: int = 10):
|
|
41
41
|
"""
|
|
42
42
|
Constructor of the FlightRadar24API class.
|
|
43
43
|
|
|
@@ -49,12 +49,14 @@ class FlightRadar24API(object):
|
|
|
49
49
|
|
|
50
50
|
if user is not None and password is not None:
|
|
51
51
|
self.login(user, password)
|
|
52
|
+
|
|
53
|
+
self.timeout: int = timeout
|
|
52
54
|
|
|
53
55
|
def get_airlines(self) -> List[Dict]:
|
|
54
56
|
"""
|
|
55
57
|
Return a list with all airlines.
|
|
56
58
|
"""
|
|
57
|
-
response = APIRequest(Core.airlines_data_url, headers=Core.json_headers)
|
|
59
|
+
response = APIRequest(Core.airlines_data_url, headers=Core.json_headers, timeout=self.timeout)
|
|
58
60
|
return response.get_content()["rows"]
|
|
59
61
|
|
|
60
62
|
def get_airline_logo(self, iata: str, icao: str) -> Optional[Tuple[bytes, str]]:
|
|
@@ -66,7 +68,7 @@ class FlightRadar24API(object):
|
|
|
66
68
|
first_logo_url = Core.airline_logo_url.format(iata, icao)
|
|
67
69
|
|
|
68
70
|
# Try to get the image by the first URL option.
|
|
69
|
-
response = APIRequest(first_logo_url, headers=Core.image_headers, exclude_status_codes=[403,])
|
|
71
|
+
response = APIRequest(first_logo_url, headers=Core.image_headers, exclude_status_codes=[403,], timeout=self.timeout)
|
|
70
72
|
status_code = response.get_status_code()
|
|
71
73
|
|
|
72
74
|
if not str(status_code).startswith("4"):
|
|
@@ -75,7 +77,7 @@ class FlightRadar24API(object):
|
|
|
75
77
|
# Get the image by the second airline logo URL.
|
|
76
78
|
second_logo_url = Core.alternative_airline_logo_url.format(icao)
|
|
77
79
|
|
|
78
|
-
response = APIRequest(second_logo_url, headers=Core.image_headers)
|
|
80
|
+
response = APIRequest(second_logo_url, headers=Core.image_headers, timeout=self.timeout)
|
|
79
81
|
status_code = response.get_status_code()
|
|
80
82
|
|
|
81
83
|
if not str(status_code).startswith("4"):
|
|
@@ -99,7 +101,7 @@ class FlightRadar24API(object):
|
|
|
99
101
|
|
|
100
102
|
return airport
|
|
101
103
|
|
|
102
|
-
response = APIRequest(Core.airport_data_url.format(code), headers=Core.json_headers)
|
|
104
|
+
response = APIRequest(Core.airport_data_url.format(code), headers=Core.json_headers, timeout=self.timeout)
|
|
103
105
|
content = response.get_content()
|
|
104
106
|
|
|
105
107
|
if not content or not isinstance(content, dict) or not content.get("details"):
|
|
@@ -129,7 +131,7 @@ class FlightRadar24API(object):
|
|
|
129
131
|
request_params["page"] = page
|
|
130
132
|
|
|
131
133
|
# Request details from the FlightRadar24.
|
|
132
|
-
response = APIRequest(Core.api_airport_data_url, request_params, Core.json_headers, exclude_status_codes=[400,])
|
|
134
|
+
response = APIRequest(Core.api_airport_data_url, request_params, Core.json_headers, exclude_status_codes=[400,], timeout=self.timeout)
|
|
133
135
|
content: Dict = response.get_content()
|
|
134
136
|
|
|
135
137
|
if response.get_status_code() == 400 and content.get("errors"):
|
|
@@ -155,14 +157,14 @@ class FlightRadar24API(object):
|
|
|
155
157
|
"""
|
|
156
158
|
Return airport disruptions.
|
|
157
159
|
"""
|
|
158
|
-
response = APIRequest(Core.airport_disruptions_url, headers=Core.json_headers)
|
|
160
|
+
response = APIRequest(Core.airport_disruptions_url, headers=Core.json_headers, timeout=self.timeout)
|
|
159
161
|
return response.get_content()
|
|
160
162
|
|
|
161
163
|
def get_airports(self) -> List[Airport]:
|
|
162
164
|
"""
|
|
163
165
|
Return a list with all airports.
|
|
164
166
|
"""
|
|
165
|
-
response = APIRequest(Core.airports_data_url, headers=Core.json_headers)
|
|
167
|
+
response = APIRequest(Core.airports_data_url, headers=Core.json_headers, timeout=self.timeout)
|
|
166
168
|
|
|
167
169
|
airports: List[Airport] = list()
|
|
168
170
|
|
|
@@ -184,7 +186,7 @@ class FlightRadar24API(object):
|
|
|
184
186
|
|
|
185
187
|
cookies = self.__login_data["cookies"]
|
|
186
188
|
|
|
187
|
-
response = APIRequest(Core.bookmarks_url, headers=headers, cookies=cookies)
|
|
189
|
+
response = APIRequest(Core.bookmarks_url, headers=headers, cookies=cookies, timeout=self.timeout)
|
|
188
190
|
return response.get_content()
|
|
189
191
|
|
|
190
192
|
def get_bounds(self, zone: Dict[str, float]) -> str:
|
|
@@ -261,7 +263,7 @@ class FlightRadar24API(object):
|
|
|
261
263
|
if "origin" in headers:
|
|
262
264
|
headers.pop("origin") # Does not work for this request.
|
|
263
265
|
|
|
264
|
-
response = APIRequest(flag_url, headers=headers)
|
|
266
|
+
response = APIRequest(flag_url, headers=headers, timeout=self.timeout)
|
|
265
267
|
status_code = response.get_status_code()
|
|
266
268
|
|
|
267
269
|
if not str(status_code).startswith("4"):
|
|
@@ -273,7 +275,7 @@ class FlightRadar24API(object):
|
|
|
273
275
|
|
|
274
276
|
:param flight: A Flight instance
|
|
275
277
|
"""
|
|
276
|
-
response = APIRequest(Core.flight_data_url.format(flight.id), headers=Core.json_headers)
|
|
278
|
+
response = APIRequest(Core.flight_data_url.format(flight.id), headers=Core.json_headers, timeout=self.timeout)
|
|
277
279
|
return response.get_content()
|
|
278
280
|
|
|
279
281
|
def get_flights(
|
|
@@ -306,7 +308,7 @@ class FlightRadar24API(object):
|
|
|
306
308
|
if aircraft_type: request_params["type"] = aircraft_type
|
|
307
309
|
|
|
308
310
|
# Get all flights from Data Live FlightRadar24.
|
|
309
|
-
response = APIRequest(Core.real_time_flight_tracker_data_url, request_params, Core.json_headers)
|
|
311
|
+
response = APIRequest(Core.real_time_flight_tracker_data_url, request_params, Core.json_headers, timeout=self.timeout)
|
|
310
312
|
response = response.get_content()
|
|
311
313
|
|
|
312
314
|
flights: List[Flight] = list()
|
|
@@ -352,6 +354,7 @@ class FlightRadar24API(object):
|
|
|
352
354
|
response = APIRequest(
|
|
353
355
|
Core.historical_data_url.format(flight.id, file_type, timestamp),
|
|
354
356
|
headers=Core.json_headers, cookies=self.__login_data["cookies"],
|
|
357
|
+
timeout=self.timeout
|
|
355
358
|
)
|
|
356
359
|
|
|
357
360
|
content = response.get_content()
|
|
@@ -370,21 +373,21 @@ class FlightRadar24API(object):
|
|
|
370
373
|
"""
|
|
371
374
|
Return the most tracked data.
|
|
372
375
|
"""
|
|
373
|
-
response = APIRequest(Core.most_tracked_url, headers=Core.json_headers)
|
|
376
|
+
response = APIRequest(Core.most_tracked_url, headers=Core.json_headers, timeout=self.timeout)
|
|
374
377
|
return response.get_content()
|
|
375
378
|
|
|
376
379
|
def get_volcanic_eruptions(self) -> Dict:
|
|
377
380
|
"""
|
|
378
381
|
Return boundaries of volcanic eruptions and ash clouds impacting aviation.
|
|
379
382
|
"""
|
|
380
|
-
response = APIRequest(Core.volcanic_eruption_data_url, headers=Core.json_headers)
|
|
383
|
+
response = APIRequest(Core.volcanic_eruption_data_url, headers=Core.json_headers, timeout=self.timeout)
|
|
381
384
|
return response.get_content()
|
|
382
385
|
|
|
383
386
|
def get_zones(self) -> Dict[str, Dict]:
|
|
384
387
|
"""
|
|
385
388
|
Return all major zones on the globe.
|
|
386
389
|
"""
|
|
387
|
-
response = APIRequest(Core.zones_data_url, headers=Core.json_headers)
|
|
390
|
+
response = APIRequest(Core.zones_data_url, headers=Core.json_headers, timeout=self.timeout)
|
|
388
391
|
zones = response.get_content()
|
|
389
392
|
|
|
390
393
|
if "version" in zones:
|
|
@@ -396,7 +399,7 @@ class FlightRadar24API(object):
|
|
|
396
399
|
"""
|
|
397
400
|
Return the search result.
|
|
398
401
|
"""
|
|
399
|
-
response = APIRequest(Core.search_data_url.format(query, limit), headers=Core.json_headers)
|
|
402
|
+
response = APIRequest(Core.search_data_url.format(query, limit), headers=Core.json_headers, timeout=self.timeout)
|
|
400
403
|
results = response.get_content().get("results", [])
|
|
401
404
|
stats = response.get_content().get("stats", {})
|
|
402
405
|
|
|
@@ -431,7 +434,7 @@ class FlightRadar24API(object):
|
|
|
431
434
|
"type": "web"
|
|
432
435
|
}
|
|
433
436
|
|
|
434
|
-
response = APIRequest(Core.user_login_url, headers=Core.json_headers, data=data)
|
|
437
|
+
response = APIRequest(Core.user_login_url, headers=Core.json_headers, data=data, timeout=self.timeout)
|
|
435
438
|
status_code = response.get_status_code()
|
|
436
439
|
content = response.get_content()
|
|
437
440
|
|
|
@@ -455,7 +458,7 @@ class FlightRadar24API(object):
|
|
|
455
458
|
cookies = self.__login_data["cookies"]
|
|
456
459
|
self.__login_data = None
|
|
457
460
|
|
|
458
|
-
response = APIRequest(Core.user_login_url, headers=Core.json_headers, cookies=cookies)
|
|
461
|
+
response = APIRequest(Core.user_login_url, headers=Core.json_headers, cookies=cookies, timeout=self.timeout)
|
|
459
462
|
return str(response.get_status_code()).startswith("2")
|
|
460
463
|
|
|
461
464
|
def set_flight_tracker_config(
|
|
@@ -27,6 +27,7 @@ class APIRequest(object):
|
|
|
27
27
|
url: str,
|
|
28
28
|
params: Optional[Dict] = None,
|
|
29
29
|
headers: Optional[Dict] = None,
|
|
30
|
+
timeout: int = 30,
|
|
30
31
|
data: Optional[Dict] = None,
|
|
31
32
|
cookies: Optional[Dict] = None,
|
|
32
33
|
exclude_status_codes: List[int] = list()
|
|
@@ -46,6 +47,7 @@ class APIRequest(object):
|
|
|
46
47
|
self.request_params = {
|
|
47
48
|
"params": params,
|
|
48
49
|
"headers": headers,
|
|
50
|
+
"timeout": timeout,
|
|
49
51
|
"data": data,
|
|
50
52
|
"cookies": cookies
|
|
51
53
|
}
|
|
@@ -53,7 +55,7 @@ class APIRequest(object):
|
|
|
53
55
|
request_method = requests.get if data is None else requests.post
|
|
54
56
|
|
|
55
57
|
if params: url += "?" + "&".join(["{}={}".format(k, v) for k, v in params.items()])
|
|
56
|
-
self.__response = request_method(url, headers=headers, cookies=cookies, data=data)
|
|
58
|
+
self.__response = request_method(url, headers=headers, cookies=cookies, data=data, timeout=timeout)
|
|
57
59
|
|
|
58
60
|
if self.get_status_code() == 520:
|
|
59
61
|
raise CloudflareError(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|