updates: filter versions by channel semver pattern
This commit is contained in:
@@ -1006,6 +1006,22 @@ def _version_sort_key(version: str) -> tuple[int, ...]:
|
||||
return tuple(parts[:4])
|
||||
|
||||
|
||||
def _is_stable_version(version: str) -> bool:
|
||||
return bool(re.match(r"^\d+\.\d+\.\d+$", str(version or "").strip()))
|
||||
|
||||
|
||||
def _is_nightly_version(version: str) -> bool:
|
||||
return bool(re.match(r"^\d+\.\d+\.\d+-nightly$", str(version or "").strip()))
|
||||
|
||||
|
||||
def _filter_versions_for_channel(channel: int, versions: list[str]) -> list[str]:
|
||||
if channel == UPDATE_CHANNEL_MAIN:
|
||||
return [v for v in versions if _is_stable_version(v)]
|
||||
if channel == UPDATE_CHANNEL_NIGHTLY:
|
||||
return [v for v in versions if _is_nightly_version(v)]
|
||||
return list(versions)
|
||||
|
||||
|
||||
def _resolve_update_info_url() -> str:
|
||||
channel = _selected_update_channel()
|
||||
if channel == UPDATE_CHANNEL_NIGHTLY:
|
||||
@@ -3368,10 +3384,11 @@ def _apply_update_channel(*, silent: bool = False) -> bool:
|
||||
if xbmc is None: # pragma: no cover - outside Kodi
|
||||
return False
|
||||
info_url = _resolve_update_info_url()
|
||||
channel = _selected_update_channel()
|
||||
_sync_update_version_settings()
|
||||
applied = _update_repository_source(info_url)
|
||||
installed_version = _get_setting_string("update_installed_version").strip() or "0.0.0"
|
||||
versions = _fetch_repo_versions(info_url)
|
||||
versions = _filter_versions_for_channel(channel, _fetch_repo_versions(info_url))
|
||||
target_version = versions[0] if versions else "-"
|
||||
|
||||
install_result = False
|
||||
@@ -3454,7 +3471,7 @@ def _show_version_selector() -> None:
|
||||
channel = _selected_update_channel()
|
||||
_sync_update_version_settings()
|
||||
|
||||
versions = _fetch_repo_versions(info_url)
|
||||
versions = _filter_versions_for_channel(channel, _fetch_repo_versions(info_url))
|
||||
if not versions:
|
||||
xbmcgui.Dialog().notification("Updates", "Keine Versionen im Repo gefunden.", xbmcgui.NOTIFICATION_ERROR, 4000)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user