FlightRadarAPI 1.3.17__tar.gz → 1.3.19__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.17 → flightradarapi-1.3.19}/FlightRadar24/__init__.py +1 -1
- {flightradarapi-1.3.17 → flightradarapi-1.3.19}/FlightRadar24/api.py +25 -5
- {flightradarapi-1.3.17 → flightradarapi-1.3.19}/PKG-INFO +1 -1
- {flightradarapi-1.3.17 → flightradarapi-1.3.19}/.gitignore +0 -0
- {flightradarapi-1.3.17 → flightradarapi-1.3.19}/FlightRadar24/core.py +0 -0
- {flightradarapi-1.3.17 → flightradarapi-1.3.19}/FlightRadar24/entities/__init__.py +0 -0
- {flightradarapi-1.3.17 → flightradarapi-1.3.19}/FlightRadar24/entities/airport.py +0 -0
- {flightradarapi-1.3.17 → flightradarapi-1.3.19}/FlightRadar24/entities/entity.py +0 -0
- {flightradarapi-1.3.17 → flightradarapi-1.3.19}/FlightRadar24/entities/flight.py +0 -0
- {flightradarapi-1.3.17 → flightradarapi-1.3.19}/FlightRadar24/errors.py +0 -0
- {flightradarapi-1.3.17 → flightradarapi-1.3.19}/FlightRadar24/request.py +0 -0
- {flightradarapi-1.3.17 → flightradarapi-1.3.19}/LICENSE +0 -0
- {flightradarapi-1.3.17 → flightradarapi-1.3.19}/README.md +0 -0
- {flightradarapi-1.3.17 → flightradarapi-1.3.19}/pyproject.toml +0 -0
- {flightradarapi-1.3.17 → flightradarapi-1.3.19}/requirements.txt +0 -0
- {flightradarapi-1.3.17 → flightradarapi-1.3.19}/tests/package.py +0 -0
- {flightradarapi-1.3.17 → flightradarapi-1.3.19}/tests/test_api.py +0 -0
- {flightradarapi-1.3.17 → flightradarapi-1.3.19}/tests/util.py +0 -0
|
@@ -13,7 +13,7 @@ https://www.flightradar24.com/terms-and-conditions
|
|
|
13
13
|
"""
|
|
14
14
|
|
|
15
15
|
__author__ = "Jean Loui Bernard Silva de Jesus"
|
|
16
|
-
__version__ = "1.3.
|
|
16
|
+
__version__ = "1.3.19"
|
|
17
17
|
|
|
18
18
|
from .api import FlightRadar24API, FlightTrackerConfig
|
|
19
19
|
from .entities import Airport, Entity, Flight
|
|
@@ -88,6 +88,9 @@ class FlightRadar24API(object):
|
|
|
88
88
|
:param code: ICAO or IATA of the airport
|
|
89
89
|
:param details: If True, it returns an Airport instance with detailed information.
|
|
90
90
|
"""
|
|
91
|
+
if 4 < len(code) or len(code) < 3:
|
|
92
|
+
raise ValueError(f"The code '{code}' is invalid. It must be the IATA or ICAO of the airport.")
|
|
93
|
+
|
|
91
94
|
if details:
|
|
92
95
|
airport = Airport()
|
|
93
96
|
|
|
@@ -100,9 +103,9 @@ class FlightRadar24API(object):
|
|
|
100
103
|
content = response.get_content()
|
|
101
104
|
|
|
102
105
|
if not content or not isinstance(content, dict) or not content.get("details"):
|
|
103
|
-
raise AirportNotFoundError(f"Could not find an airport by the code '{code}'.")
|
|
106
|
+
raise AirportNotFoundError(f"Could not find an airport by the code '{code}'.")
|
|
104
107
|
|
|
105
|
-
return Airport(info=content["details"])
|
|
108
|
+
return Airport(info = content["details"])
|
|
106
109
|
|
|
107
110
|
def get_airport_details(self, code: str, flight_limit: int = 100, page: int = 1) -> Dict:
|
|
108
111
|
"""
|
|
@@ -112,6 +115,9 @@ class FlightRadar24API(object):
|
|
|
112
115
|
:param flight_limit: Limit of flights related to the airport
|
|
113
116
|
:param page: Page of result to display
|
|
114
117
|
"""
|
|
118
|
+
if 4 < len(code) or len(code) < 3:
|
|
119
|
+
raise ValueError(f"The code '{code}' is invalid. It must be the IATA or ICAO of the airport.")
|
|
120
|
+
|
|
115
121
|
request_params = {"format": "json"}
|
|
116
122
|
|
|
117
123
|
if self.__login_data is not None:
|
|
@@ -126,10 +132,24 @@ class FlightRadar24API(object):
|
|
|
126
132
|
response = APIRequest(Core.api_airport_data_url, request_params, Core.json_headers, exclude_status_codes=[400,])
|
|
127
133
|
content: Dict = response.get_content()
|
|
128
134
|
|
|
129
|
-
if response.get_status_code() == 400 and
|
|
130
|
-
|
|
135
|
+
if response.get_status_code() == 400 and content.get("errors"):
|
|
136
|
+
errors = content["errors"]["errors"]["parameters"]
|
|
137
|
+
|
|
138
|
+
if errors.get("limit"):
|
|
139
|
+
raise ValueError(errors["limit"]["notBetween"])
|
|
140
|
+
|
|
141
|
+
raise AirportNotFoundError(f"Could not find an airport by the code '{code}'.", errors)
|
|
142
|
+
|
|
143
|
+
result = content["result"]["response"]
|
|
144
|
+
|
|
145
|
+
# Check whether it received data of an airport.
|
|
146
|
+
data = result.get("airport", dict()).get("pluginData", dict())
|
|
131
147
|
|
|
132
|
-
|
|
148
|
+
if not "details" in data and len(data.get("runways", [])) == 0 and len(data) <= 3:
|
|
149
|
+
raise AirportNotFoundError(f"Could not find an airport by the code '{code}'.")
|
|
150
|
+
|
|
151
|
+
# Return the airport details.
|
|
152
|
+
return result
|
|
133
153
|
|
|
134
154
|
def get_airports(self) -> List[Airport]:
|
|
135
155
|
"""
|
|
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
|