Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Support [reallyfreegeoip.org](https://reallyfreegeoip.org/json/) IPv6 API
- Support [myip.la](https://api.myip.la/en?json) IPv6 API
- Support [freeipapi.com](https://freeipapi.com/api/json) IPv6 API
### Changed
- [freeipapi.com](https://freeipapi.com/api/json) IPv4 API bug fixed
- `README.md` updated
### Removed
- `IPv4HTTPAdapter` class
- `_get_json_ipv4_forced` function
Expand Down
5 changes: 3 additions & 2 deletions ipspot/ipv4.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ def _freeipapi_com_ipv4(geo: bool=False, timeout: Union[float, Tuple[float, floa
try:
data = _get_json_force_ip(url="https://freeipapi.com/api/json", timeout=timeout, version="ipv4")
result = {"status": True, "data": {"ip": data["ipAddress"], "api": "freeipapi.com"}}
tzs = data.get("timeZones", [None])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can make the default value to [] instead of [None]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 64aadd6

if geo:
geo_data = {
"city": data.get("cityName"),
Expand All @@ -367,8 +368,8 @@ def _freeipapi_com_ipv4(geo: bool=False, timeout: Union[float, Tuple[float, floa
"country_code": data.get("countryCode"),
"latitude": data.get("latitude"),
"longitude": data.get("longitude"),
"organization": None,
"timezone": data.get("timeZone")
"organization": data.get("asnOrganization"),
"timezone": tzs[0] if len(tzs) > 0 else None
}
result["data"].update(geo_data)
return result
Expand Down
2 changes: 1 addition & 1 deletion ipspot/ipv6.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def _freeipapi_com_ipv6(geo: bool=False, timeout: Union[float, Tuple[float, floa
"latitude": data.get("latitude"),
"longitude": data.get("longitude"),
"organization": data.get("asnOrganization"),
"timezone": tzs[0]
"timezone": tzs[0] if len(tzs) > 0 else None
}
result["data"].update(geo_data)
return result
Expand Down