Refactor yt-dlp update flow and update translations

Replaces manual update check logic in DownloadSettingsDialog with a dedicated YTDLPUpdateDialog for progress tracking. Removes the 'Update yt-dlp' button and related logic from the main window. Updates translation strings in all supported languages to reflect the new update dialog flow and button labeling.
This commit is contained in:
oop7
2025-11-03 18:40:28 +02:00
parent df4a7ab49d
commit d009202230
16 changed files with 34 additions and 82 deletions
@@ -33,6 +33,7 @@ from src.core.ytsage_utils import (
get_ytdlp_version,
update_auto_update_settings,
)
from src.gui.ytsage_gui_dialogs.ytsage_dialogs_update import YTDLPUpdateDialog
from src.utils.ytsage_logger import logger
from src.utils.ytsage_localization import _
@@ -313,49 +314,11 @@ class DownloadSettingsDialog(QDialog):
return msg_box
def test_update_check(self) -> None:
"""Test the update check functionality."""
try:
# Get current version
current_version = get_ytdlp_version()
if "Error" in current_version:
msg_box = self._create_styled_message_box(
QMessageBox.Icon.Warning,
_("settings.update_check_title"),
_("settings.could_not_determine_version"),
)
msg_box.exec()
return
# Get latest version from PyPI
response = requests.get("https://pypi.org/pypi/yt-dlp/json", timeout=10)
response.raise_for_status()
latest_version = response.json()["info"]["version"]
# Clean up version strings
current_version = current_version.replace("_", ".")
latest_version = latest_version.replace("_", ".")
if version_parser.parse(latest_version) > version_parser.parse(current_version):
msg_box = self._create_styled_message_box(
QMessageBox.Icon.Information,
_("settings.update_check_title"),
_("settings.update_available_dialog", current=current_version, latest=latest_version),
)
msg_box.exec()
else:
msg_box = self._create_styled_message_box(
QMessageBox.Icon.Information,
_("settings.update_check_title"),
_("settings.up_to_date_dialog", version=current_version),
)
msg_box.exec()
except Exception as e:
msg_box = self._create_styled_message_box(
QMessageBox.Icon.Warning,
_("settings.update_check_title"),
_("settings.error_checking_updates", error=str(e)),
)
msg_box.exec()
"""Open the yt-dlp update dialog with proper progress tracking."""
# Create and show the update dialog (non-modal to prevent blocking)
dialog = YTDLPUpdateDialog(self)
dialog.setModal(False) # Make it non-modal
dialog.show() # Use show() instead of exec() to avoid blocking
def get_auto_update_settings(self) -> tuple[bool, str]:
"""Returns the auto-update settings from the dialog."""
-11
View File
@@ -581,9 +581,6 @@ class YTSageApp(QMainWindow, FormatTableMixin, VideoInfoMixin): # Inherit from
self.time_range_btn = QPushButton(_("buttons.trim_video"))
self.time_range_btn.clicked.connect(self.show_time_range_dialog)
self.update_ytdlp_btn = QPushButton(_("buttons.update"))
self.update_ytdlp_btn.clicked.connect(self.update_ytdlp)
# --- Rename Path Button to Settings Button ---
self.settings_button = QPushButton(_("buttons.download_settings")) # Renamed button
self.settings_button.clicked.connect(self.show_download_settings_dialog) # Renamed method
@@ -607,7 +604,6 @@ class YTSageApp(QMainWindow, FormatTableMixin, VideoInfoMixin): # Inherit from
download_layout.addWidget(self.about_btn)
download_layout.addWidget(self.history_btn)
download_layout.addWidget(self.time_range_btn) # New button position
download_layout.addWidget(self.update_ytdlp_btn)
download_layout.addWidget(self.settings_button)
download_layout.addWidget(self.download_btn)
download_layout.addWidget(self.pause_btn)
@@ -748,13 +744,6 @@ class YTSageApp(QMainWindow, FormatTableMixin, VideoInfoMixin): # Inherit from
clipboard = QApplication.clipboard()
self.url_input.setText(clipboard.text())
def update_ytdlp(self) -> None:
"""Show the yt-dlp update dialog with proper progress tracking"""
# Make the dialog non-modal to prevent blocking the main UI
dialog = YTDLPUpdateDialog(self)
dialog.setModal(False) # Make it non-modal
dialog.show() # Use show() instead of exec() to avoid blocking
def show_download_settings_dialog(self) -> None: # Renamed method
dialog = DownloadSettingsDialog(self.last_path, self.speed_limit_value, self.speed_limit_unit_index, self)
if dialog.exec():