custom_components/bahmcloud_store/providers.py aktualisiert
This commit is contained in:
@@ -9,7 +9,7 @@ from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
UA = "BahmcloudStore/0.4.0 (Home Assistant)"
|
UA = "BahmcloudStore (Home Assistant)"
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@@ -72,12 +72,14 @@ async def _github_latest_version(hass: HomeAssistant, owner: str, repo: str) ->
|
|||||||
"User-Agent": UA,
|
"User-Agent": UA,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 1) Releases latest
|
||||||
data, _ = await _safe_json(session, f"https://api.github.com/repos/{owner}/{repo}/releases/latest", headers=headers)
|
data, _ = await _safe_json(session, f"https://api.github.com/repos/{owner}/{repo}/releases/latest", headers=headers)
|
||||||
if isinstance(data, dict):
|
if isinstance(data, dict):
|
||||||
tag = data.get("tag_name") or data.get("name")
|
tag = data.get("tag_name") or data.get("name")
|
||||||
if isinstance(tag, str) and tag.strip():
|
if isinstance(tag, str) and tag.strip():
|
||||||
return tag.strip(), "release"
|
return tag.strip(), "release"
|
||||||
|
|
||||||
|
# 2) Fallback: newest tag
|
||||||
data, _ = await _safe_json(session, f"https://api.github.com/repos/{owner}/{repo}/tags?per_page=1", headers=headers)
|
data, _ = await _safe_json(session, f"https://api.github.com/repos/{owner}/{repo}/tags?per_page=1", headers=headers)
|
||||||
if isinstance(data, list) and data:
|
if isinstance(data, list) and data:
|
||||||
tag = data[0].get("name")
|
tag = data[0].get("name")
|
||||||
@@ -130,6 +132,7 @@ async def fetch_repo_info(hass: HomeAssistant, repo_url: str) -> RepoInfo:
|
|||||||
"Accept": "application/vnd.github+json",
|
"Accept": "application/vnd.github+json",
|
||||||
"User-Agent": UA,
|
"User-Agent": UA,
|
||||||
}
|
}
|
||||||
|
|
||||||
data, _ = await _safe_json(session, f"https://api.github.com/repos/{owner}/{repo}", headers=headers)
|
data, _ = await _safe_json(session, f"https://api.github.com/repos/{owner}/{repo}", headers=headers)
|
||||||
if isinstance(data, dict):
|
if isinstance(data, dict):
|
||||||
info.description = data.get("description")
|
info.description = data.get("description")
|
||||||
|
|||||||
Reference in New Issue
Block a user