Add support for non-proxy capable locations

This commit is contained in:
codeking 2025-11-18 02:40:41 +01:00
parent e4c38df1d9
commit b2e260475b
2 changed files with 13 additions and 3 deletions

View file

@ -15,6 +15,8 @@ _table_definition: str = """
'time_zone' varchar, 'time_zone' varchar,
'operator_id' int, 'operator_id' int,
'provider_name' varchar, 'provider_name' varchar,
'is_proxy_capable' bool,
'is_wireguard_capable' bool,
UNIQUE(code, country_code) UNIQUE(code, country_code)
""" """
@ -44,6 +46,14 @@ class Location(Model):
default=None, default=None,
metadata=config(exclude=Exclude.ALWAYS) 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( operator: Optional[Operator] = field(
default=None, default=None,
metadata=config(exclude=Exclude.ALWAYS) metadata=config(exclude=Exclude.ALWAYS)
@ -87,7 +97,7 @@ class Location(Model):
@staticmethod @staticmethod
def save_many(locations): def save_many(locations):
Model._create_table_if_not_exists(table_name=_table_name, table_definition=_table_definition) 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 @staticmethod
def factory(cursor, row): def factory(cursor, row):
@ -96,4 +106,4 @@ class Location(Model):
@staticmethod @staticmethod
def tuple_factory(location): 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

View file

@ -72,7 +72,7 @@ class WebServiceApiService:
if response.status_code == requests.codes.ok: if response.status_code == requests.codes.ok:
for location in response.json()['data']: 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 return locations