mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2025-10-13 12:22:04 +00:00
linted changes
This commit is contained in:
parent
a599cdafa3
commit
f1f17f1344
1 changed files with 11 additions and 12 deletions
|
@ -278,47 +278,46 @@ class ConnectionManager(object):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# Host from EndpointAddress - IPv6 friendly
|
# Host from EndpointAddress - IPv6 friendly
|
||||||
if endpoint.startswith('['):
|
if endpoint.startswith("["):
|
||||||
right_bracket = endpoint.find(']')
|
right_bracket = endpoint.find("]")
|
||||||
if right_bracket != -1:
|
if right_bracket != -1:
|
||||||
host = endpoint[1:right_bracket]
|
host = endpoint[1:right_bracket]
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
if endpoint.count(':') > 1:
|
if endpoint.count(":") > 1:
|
||||||
# Raw IPv6
|
# Raw IPv6
|
||||||
host = endpoint
|
host = endpoint
|
||||||
else:
|
else:
|
||||||
# IPv4 hostname strip option
|
# IPv4 hostname strip option
|
||||||
host = endpoint.rsplit(':', 1)[0] if ':' in endpoint else endpoint
|
host = endpoint.rsplit(":", 1)[0] if ":" in endpoint else endpoint
|
||||||
|
|
||||||
# Getting the port from the address
|
# Getting the port from the address
|
||||||
port = None
|
port = None
|
||||||
if addr.startswith('['):
|
if addr.startswith("["):
|
||||||
right_bracket = addr.find(']')
|
right_bracket = addr.find("]")
|
||||||
has_port = (
|
has_port = (
|
||||||
right_bracket != -1
|
right_bracket != -1
|
||||||
and right_bracket + 1 < len(addr)
|
and right_bracket + 1 < len(addr)
|
||||||
and addr[right_bracket + 1] == ':'
|
and addr[right_bracket + 1] == ":"
|
||||||
)
|
)
|
||||||
if has_port:
|
if has_port:
|
||||||
port_str = addr[right_bracket + 2:]
|
port_str = addr[right_bracket + 2 :]
|
||||||
if port_str.isdigit():
|
if port_str.isdigit():
|
||||||
port = int(port_str)
|
port = int(port_str)
|
||||||
else:
|
else:
|
||||||
# Non-bracketed: allow exactly one colon for host:port
|
# Non-bracketed: allow exactly one colon for host:port
|
||||||
if addr.count(':') == 1:
|
if addr.count(":") == 1:
|
||||||
port_str = addr.rsplit(':', 1)[1]
|
port_str = addr.rsplit(":", 1)[1]
|
||||||
if port_str.isdigit():
|
if port_str.isdigit():
|
||||||
port = int(port_str)
|
port = int(port_str)
|
||||||
|
|
||||||
if port is None:
|
if port is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
combined = f"[{host}]:{port}" if ':' in host else f"{host}:{port}"
|
combined = f"[{host}]:{port}" if ":" in host else f"{host}:{port}"
|
||||||
return self._normalize_address(combined)
|
return self._normalize_address(combined)
|
||||||
|
|
||||||
|
|
||||||
def _normalize_address(self, address):
|
def _normalize_address(self, address):
|
||||||
# TODO: Try HTTPS first, then HTTP if that fails.
|
# TODO: Try HTTPS first, then HTTP if that fails.
|
||||||
if "://" not in address:
|
if "://" not in address:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue