You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Bare IPv6 addressing does not seem to work out of the box for me. Neither does prefixing it with a protocol, due to a too primitive regex.
To Reproduce
Try adding a IPv6 address as a server.
Expected behavior
Adds the server URL as expected
Desktop (please complete the following information):
OS: Linux
Version: develop
Error Messages
Server URL: https://[2001:db8:85a3:8d3:1319:8a2e:370:7348]:443/
Username: 123
Password:
Traceback (most recent call last):
File "jellyfin-mpv-shim/./run.py", line 23, in <module>
main()
File "jellyfin-mpv-shim/jellyfin_mpv_shim/mpv_shim.py", line 79, in main
user_interface.login_servers()
File "jellyfin-mpv-shim/jellyfin_mpv_shim/cli_mgr.py", line 11, in login_servers
clientManager.cli_connect()
File "jellyfin-mpv-shim/jellyfin_mpv_shim/clients.py", line 54, in cli_connect
is_logged_in = self.login(server, username, password)
File "jellyfin-mpv-shim/jellyfin_mpv_shim/clients.py", line 121, in login
protocol, ipv6_host, ipv4_host, port, path = path_regex.match(server).groups()
AttributeError: 'NoneType' object has no attribute 'groups'
Proposed Fix
diff --git a/jellyfin_mpv_shim/clients.py b/jellyfin_mpv_shim/clients.py
index cff9e93..cb9606e 100644
--- a/jellyfin_mpv_shim/clients.py
+++ b/jellyfin_mpv_shim/clients.py
@@ -15,7 +15,7 @@ import logging
import re
log = logging.getLogger("clients")
-path_regex = re.compile("^(https?://)?([^/:]+)(:[0-9]+)?(/.*)?$")
+path_regex = re.compile("^(https?://)?(?:(\[[^/]+\])|([^/:]+))(:[0-9]+)?(/.*)?$")
from typing import Optional
@@ -118,7 +118,7 @@ class ClientManager(object):
if server.endswith("/"):
server = server[:-1]
- protocol, host, port, path = path_regex.match(server).groups()
+ protocol, ipv6_host, ipv4_host, port, path = path_regex.match(server).groups()
if not protocol:
log.warning("Adding http:// because it was not provided.")
@@ -131,7 +131,7 @@ class ClientManager(object):
)
port = ":8096"
- server = "".join(filter(bool, (protocol, host, port, path)))
+ server = "".join(filter(bool, (protocol, ipv6_host, ipv4_host, port, path)))
client = self.client_factory()
client.auth.connect_to_address(server)
This adds an outer capture group where the host previously was and first tries to match any url starting with [ (see https://en.wikipedia.org/wiki/IPv6_address#Literal_IPv6_addresses_in_network_resource_identifiers) until it encounters a / (compared to either / or : previously which would not work in the case of IPv6) or end of string. If the url does not start with [, then it falls back to previous hostname matching.
This works on my end as expected.
The text was updated successfully, but these errors were encountered:
Describe the bug
Bare IPv6 addressing does not seem to work out of the box for me. Neither does prefixing it with a protocol, due to a too primitive regex.
To Reproduce
Try adding a IPv6 address as a server.
Expected behavior
Adds the server URL as expected
Desktop (please complete the following information):
Error Messages
Proposed Fix
This adds an outer capture group where the host previously was and first tries to match any url starting with
[
(see https://en.wikipedia.org/wiki/IPv6_address#Literal_IPv6_addresses_in_network_resource_identifiers) until it encounters a/
(compared to either/
or:
previously which would not work in the case of IPv6) or end of string. If the url does not start with[
, then it falls back to previous hostname matching.This works on my end as expected.
The text was updated successfully, but these errors were encountered: