From 15451f7715f25c0aff2a475df8062c5d36dff133 Mon Sep 17 00:00:00 2001 From: oop7 <110548351+oop7@users.noreply.github.com> Date: Sat, 29 Nov 2025 13:31:57 +0200 Subject: [PATCH] Switch update checks from GitHub API to PyPI Update logic in updater dialog and main app to fetch latest version info from PyPI instead of GitHub API, avoiding rate limiting issues. Changelog is now fetched from GitHub only as a fallback, improving reliability of update checks. --- .../ytsage_dialogs_updater.py | 8 ++--- src/gui/ytsage_gui_main.py | 30 ++++++++++++++----- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/gui/ytsage_gui_dialogs/ytsage_dialogs_updater.py b/src/gui/ytsage_gui_dialogs/ytsage_dialogs_updater.py index c86d1ba..82c61aa 100644 --- a/src/gui/ytsage_gui_dialogs/ytsage_dialogs_updater.py +++ b/src/gui/ytsage_gui_dialogs/ytsage_dialogs_updater.py @@ -629,13 +629,13 @@ class UpdaterTabWidget(QWidget): update_target = new_channel if new_channel == "stable" and current_channel == "nightly": - # Get the latest stable version tag - logger.info("Fetching latest stable version tag...") + # Get the latest stable version tag from PyPI (no rate limiting) + logger.info("Fetching latest stable version tag from PyPI...") try: import requests - response = requests.get("https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest", timeout=10) + response = requests.get("https://pypi.org/pypi/yt-dlp/json", timeout=10) response.raise_for_status() - latest_tag = response.json().get("tag_name", "") + latest_tag = response.json()["info"]["version"] if latest_tag: update_target = f"stable@{latest_tag}" logger.info(f"Latest stable version tag: {latest_tag}") diff --git a/src/gui/ytsage_gui_main.py b/src/gui/ytsage_gui_main.py index d869a74..c985f03 100644 --- a/src/gui/ytsage_gui_main.py +++ b/src/gui/ytsage_gui_main.py @@ -1087,20 +1087,36 @@ class YTSageApp(QMainWindow, FormatTableMixin, VideoInfoMixin): # Inherit from def check_for_updates(self) -> None: try: - # Get the latest release info from GitHub + # Get the latest version info from PyPI (no rate limiting unlike GitHub API) response = requests.get( - "https://api.github.com/repos/oop7/YTSage/releases/latest", - headers={"Accept": "application/vnd.github.v3+json"}, + "https://pypi.org/pypi/ytsage/json", + timeout=10, ) response.raise_for_status() - latest_release = response.json() - latest_version = latest_release["tag_name"].lstrip("v") + pypi_data = response.json() + latest_version = pypi_data["info"]["version"] # Compare versions if version.parse(latest_version) > version.parse(self.version): - changelog = latest_release.get("body", "No changelog available.") # Get changelog body - self.show_update_dialog(latest_version, latest_release["html_url"], changelog) # Pass changelog + release_url = "https://github.com/oop7/YTSage/releases/latest" + + # Try to fetch changelog from GitHub (with fallback if rate-limited) + changelog = "View the full changelog on the [GitHub Releases](https://github.com/oop7/YTSage/releases) page." + try: + gh_response = requests.get( + "https://api.github.com/repos/oop7/YTSage/releases/latest", + headers={"Accept": "application/vnd.github.v3+json"}, + timeout=5, + ) + if gh_response.status_code == 200: + gh_data = gh_response.json() + changelog = gh_data.get("body", changelog) + except Exception: + # Silently fallback to static message if GitHub API fails (rate limit, etc.) + pass + + self.show_update_dialog(latest_version, release_url, changelog) except Exception as e: logger.exception(f"Failed to check for updates: {e}")