FlightRadarAPI 1.5.1__tar.gz → 1.5.2__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.
Files changed (21) hide show
  1. {flightradarapi-1.5.1 → flightradarapi-1.5.2}/.gitignore +5 -0
  2. {flightradarapi-1.5.1 → flightradarapi-1.5.2}/FlightRadarAPI/__init__.py +1 -1
  3. {flightradarapi-1.5.1 → flightradarapi-1.5.2}/FlightRadarAPI/api.py +28 -14
  4. {flightradarapi-1.5.1 → flightradarapi-1.5.2}/FlightRadarAPI/request.py +11 -0
  5. {flightradarapi-1.5.1 → flightradarapi-1.5.2}/PKG-INFO +2 -2
  6. flightradarapi-1.5.1/.tool-versions +0 -1
  7. {flightradarapi-1.5.1 → flightradarapi-1.5.2}/FlightRadar24/__init__.py +0 -0
  8. {flightradarapi-1.5.1 → flightradarapi-1.5.2}/FlightRadarAPI/core.py +0 -0
  9. {flightradarapi-1.5.1 → flightradarapi-1.5.2}/FlightRadarAPI/entities/__init__.py +0 -0
  10. {flightradarapi-1.5.1 → flightradarapi-1.5.2}/FlightRadarAPI/entities/airport.py +0 -0
  11. {flightradarapi-1.5.1 → flightradarapi-1.5.2}/FlightRadarAPI/entities/entity.py +0 -0
  12. {flightradarapi-1.5.1 → flightradarapi-1.5.2}/FlightRadarAPI/entities/flight.py +0 -0
  13. {flightradarapi-1.5.1 → flightradarapi-1.5.2}/FlightRadarAPI/errors.py +0 -0
  14. {flightradarapi-1.5.1 → flightradarapi-1.5.2}/FlightRadarAPI/flight_tracker_config.py +0 -0
  15. {flightradarapi-1.5.1 → flightradarapi-1.5.2}/FlightRadarAPI/parsers.py +0 -0
  16. {flightradarapi-1.5.1 → flightradarapi-1.5.2}/FlightRadarAPI/py.typed +0 -0
  17. {flightradarapi-1.5.1 → flightradarapi-1.5.2}/FlightRadarAPI/zones.py +0 -0
  18. {flightradarapi-1.5.1 → flightradarapi-1.5.2}/LICENSE +0 -0
  19. {flightradarapi-1.5.1 → flightradarapi-1.5.2}/Makefile +0 -0
  20. {flightradarapi-1.5.1 → flightradarapi-1.5.2}/README.md +0 -0
  21. {flightradarapi-1.5.1 → flightradarapi-1.5.2}/pyproject.toml +0 -0
@@ -19,6 +19,11 @@ coverage.xml
19
19
  # Node.js
20
20
  node_modules/
21
21
 
22
+ # Version managers (local dev only)
23
+ .tool-versions
24
+ .python-version
25
+ .nvmrc
26
+
22
27
  # Editors / OS
23
28
  .idea/
24
29
  .vscode/
@@ -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.5.1"
15
+ __version__ = "1.5.2"
16
16
 
17
17
  from .api import FlightRadar24API
18
18
  from .core import Countries
@@ -14,6 +14,13 @@ from .flight_tracker_config import FlightTrackerConfig
14
14
  from .parsers import parse_airlines_html, parse_airports_html
15
15
  from .request import APIClient, RetryPolicy
16
16
 
17
+ # Some FR24 live-feed backends answer 200 with a well-formed envelope but no
18
+ # flight entries -- indistinguishable from a legitimately empty result. The
19
+ # "AWSALB" cookie then pins the session to that backend, so dropping it is what
20
+ # makes the load balancer re-roll on retry.
21
+ FEED_STICKY_COOKIES = ("AWSALB", "AWSALBCORS")
22
+ FEED_EMPTY_RETRIES = 4
23
+
17
24
 
18
25
  class FlightRadar24API:
19
26
  """
@@ -342,24 +349,31 @@ class FlightRadar24API:
342
349
  if registration is not None: request_params["reg"] = registration
343
350
  if aircraft_type is not None: request_params["type"] = aircraft_type
344
351
 
345
- # Get all flights from Data Live FlightRadar24.
346
- response = self.__client.request(
347
- Core.real_time_flight_tracker_data_url,
348
- params=request_params,
349
- headers=Core.json_headers,
350
- timeout=self.timeout,
351
- )
352
- content = response.get_json_content()
353
-
354
352
  flights: List[Flight] = list()
355
353
 
356
- for flight_id, flight_info in content.items():
354
+ for _ in range(FEED_EMPTY_RETRIES + 1):
355
+ # Get all flights from Data Live FlightRadar24.
356
+ response = self.__client.request(
357
+ Core.real_time_flight_tracker_data_url,
358
+ params=request_params,
359
+ headers=Core.json_headers,
360
+ timeout=self.timeout,
361
+ )
362
+ content = response.get_json_content()
357
363
 
358
364
  # Get flights only.
359
- if not flight_id[0].isnumeric():
360
- continue
361
-
362
- flights.append(Flight(flight_id, flight_info))
365
+ flights = [
366
+ Flight(flight_id, flight_info)
367
+ for flight_id, flight_info in content.items()
368
+ if flight_id[0].isnumeric()
369
+ ]
370
+
371
+ # "full_count": 0 means the feed really has nothing to report.
372
+ if flights or not content.get("full_count"):
373
+ break
374
+
375
+ for cookie_name in FEED_STICKY_COOKIES:
376
+ self.__client.delete_cookie(cookie_name)
363
377
 
364
378
  if details:
365
379
  with ThreadPoolExecutor(max_workers=self.max_workers) as executor:
@@ -122,6 +122,17 @@ class APIClient:
122
122
  """Clear all cookies from the session."""
123
123
  self.__session.cookies.clear()
124
124
 
125
+ def delete_cookie(self, name: str) -> None:
126
+ """Drop a single cookie, leaving the rest of the jar intact.
127
+
128
+ Sheds load-balancer stickiness without discarding the login session,
129
+ which lives in the same jar.
130
+ """
131
+ try:
132
+ del self.__session.cookies[name]
133
+ except KeyError:
134
+ pass
135
+
125
136
 
126
137
  class APIRequest:
127
138
  """
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: FlightRadarAPI
3
- Version: 1.5.1
3
+ Version: 1.5.2
4
4
  Summary: SDK for FlightRadar24
5
5
  Project-URL: Homepage, https://github.com/JeanExtreme002/FlightRadarAPI
6
6
  Project-URL: Source Code, https://github.com/JeanExtreme002/FlightRadarAPI
@@ -1 +0,0 @@
1
- python 3.11.0
File without changes
File without changes
File without changes