release: 0.1.61

This commit is contained in:
2026-02-23 21:56:58 +01:00
parent 22b9ae9c31
commit ae01c79555
9 changed files with 638 additions and 177 deletions

View File

@@ -8,8 +8,16 @@ from __future__ import annotations
from typing import Optional
_LAST_RESOLVE_ERROR = ""
def get_last_error() -> str:
return str(_LAST_RESOLVE_ERROR or "")
def resolve(url: str) -> Optional[str]:
global _LAST_RESOLVE_ERROR
_LAST_RESOLVE_ERROR = ""
if not url:
return None
try:
@@ -23,12 +31,14 @@ def resolve(url: str) -> Optional[str]:
hmf = hosted(url)
valid = getattr(hmf, "valid_url", None)
if callable(valid) and not valid():
_LAST_RESOLVE_ERROR = "invalid url"
return None
resolver = getattr(hmf, "resolve", None)
if callable(resolver):
result = resolver()
return str(result) if result else None
except Exception:
except Exception as exc:
_LAST_RESOLVE_ERROR = str(exc or "")
pass
try:
@@ -36,8 +46,8 @@ def resolve(url: str) -> Optional[str]:
if callable(resolve_fn):
result = resolve_fn(url)
return str(result) if result else None
except Exception:
except Exception as exc:
_LAST_RESOLVE_ERROR = str(exc or "")
return None
return None