Add support for non-proxy capable locations
This commit is contained in:
parent
e4c38df1d9
commit
b2e260475b
2 changed files with 13 additions and 3 deletions
|
|
@ -15,6 +15,8 @@ _table_definition: str = """
|
|||
'time_zone' varchar,
|
||||
'operator_id' int,
|
||||
'provider_name' varchar,
|
||||
'is_proxy_capable' bool,
|
||||
'is_wireguard_capable' bool,
|
||||
UNIQUE(code, country_code)
|
||||
"""
|
||||
|
||||
|
|
@ -44,6 +46,14 @@ class Location(Model):
|
|||
default=None,
|
||||
metadata=config(exclude=Exclude.ALWAYS)
|
||||
)
|
||||
is_proxy_capable: Optional[bool] = field(
|
||||
default=None,
|
||||
metadata=config(exclude=Exclude.ALWAYS)
|
||||
)
|
||||
is_wireguard_capable: Optional[bool] = field(
|
||||
default=None,
|
||||
metadata=config(exclude=Exclude.ALWAYS)
|
||||
)
|
||||
operator: Optional[Operator] = field(
|
||||
default=None,
|
||||
metadata=config(exclude=Exclude.ALWAYS)
|
||||
|
|
@ -87,7 +97,7 @@ class Location(Model):
|
|||
@staticmethod
|
||||
def save_many(locations):
|
||||
Model._create_table_if_not_exists(table_name=_table_name, table_definition=_table_definition)
|
||||
Model._insert_many('INSERT INTO locations VALUES(?, ?, ?, ?, ?, ?, ?, ?)', Location.tuple_factory, locations)
|
||||
Model._insert_many('INSERT INTO locations VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', Location.tuple_factory, locations)
|
||||
|
||||
@staticmethod
|
||||
def factory(cursor, row):
|
||||
|
|
@ -96,4 +106,4 @@ class Location(Model):
|
|||
|
||||
@staticmethod
|
||||
def tuple_factory(location):
|
||||
return location.id, location.country_code, location.country_name, location.code, location.name, location.time_zone, location.operator_id, location.provider_name
|
||||
return location.id, location.country_code, location.country_name, location.code, location.name, location.time_zone, location.operator_id, location.provider_name, location.is_proxy_capable, location.is_wireguard_capable
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class WebServiceApiService:
|
|||
|
||||
if response.status_code == requests.codes.ok:
|
||||
for location in response.json()['data']:
|
||||
locations.append(Location(location['country']['code'], location['code'], location['id'], location['country']['name'], location['name'], location['time_zone']['code'], location['operator_id'], location['provider']['name']))
|
||||
locations.append(Location(location['country']['code'], location['code'], location['id'], location['country']['name'], location['name'], location['time_zone']['code'], location['operator_id'], location['provider']['name'], location['is_proxy_capable'], location['is_wireguard_capable']))
|
||||
|
||||
return locations
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue