Windows-Patch-Pakete heissen jetzt Playtube-vX.Y.Z-win64-patch.play statt .zip (technisch weiterhin ein ganz normales ZIP-Archiv - Windows/Python schauen beim Entpacken auf die Magic Bytes, nicht auf die Endung). Playtube registriert .play beim ersten Start als Windows-Dateizuordnung (HKCU, keine Admin-Rechte noetig), sodass eine manuell heruntergeladene Patchdatei per Doppelklick installiert werden kann, ohne dass Playtube selbst etwas herunterladen muss: - shortcuts.py: ensure_play_file_association() registriert ProgID + DefaultIcon + shell/open/command und stoesst SHChangeNotify an, damit die Zuordnung sofort greift. - updater.py: UpdateInstaller akzeptiert jetzt optional local_archive_path statt einer download_url und ueberspringt dann den Download komplett. - main.py: erkennt eine .play-Datei als Kommandozeilenargument (Doppelklick- Start) und uebergibt sie an MainWindow.install_local_patch(). - release.yml: Windows-Patch wird als .zip gepackt und anschliessend zu .play umbenannt; _find_platform_asset() sucht fuer Windows-Patches jetzt nach .play statt .zip. Co-Authored-By: Claude Sonnet 5 <[email protected]>
82 lines
2.9 KiB
Python
82 lines
2.9 KiB
Python
"""Playtube - eigenstaendiger YouTube- & YouTube-Music-Player mit Discord Rich Presence.
|
|
|
|
Start: python main.py (oder die gepackte Playtube.exe, siehe packaging/README)
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Branding-Schritte MUESSEN vor dem Import von QtWebEngine passieren.
|
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
from playtube import __version__, app_id # noqa: E402
|
|
from playtube.config import APP_NAME, clear_cache_on_update, load_config # noqa: E402
|
|
from playtube.shortcuts import ( # noqa: E402
|
|
ensure_play_file_association,
|
|
ensure_start_menu_shortcut,
|
|
)
|
|
|
|
app_id.set_app_user_model_id()
|
|
app_id.configure_webengine_process_path()
|
|
|
|
# High-DPI, sauberes GPU-Verhalten und (in Kombination mit den Sec-CH-UA-Headern in
|
|
# playtube/browser.py) ein moeglichst "normales" Chrome-Fingerprint, damit Google-Login
|
|
# das eingebettete QtWebEngine nicht als Embedded-WebView blockiert.
|
|
os.environ.setdefault(
|
|
"QTWEBENGINE_CHROMIUM_FLAGS",
|
|
"--disable-features=WinRetrieveSuggestionsOnlyOnDemand "
|
|
"--disable-blink-features=AutomationControlled",
|
|
)
|
|
|
|
from PySide6.QtCore import Qt # noqa: E402
|
|
from PySide6.QtGui import QIcon # noqa: E402
|
|
from PySide6.QtWidgets import QApplication # noqa: E402
|
|
|
|
from playtube.mainwindow import MainWindow # noqa: E402
|
|
|
|
|
|
def _pending_local_patch() -> str | None:
|
|
"""Falls Playtube per Doppelklick auf eine ".play"-Patchdatei gestartet wurde
|
|
(siehe shortcuts.ensure_play_file_association), liefert den Pfad dazu."""
|
|
for arg in sys.argv[1:]:
|
|
if arg.lower().endswith(".play") and Path(arg).is_file():
|
|
return str(Path(arg).resolve())
|
|
return None
|
|
|
|
|
|
def main() -> int:
|
|
QApplication.setAttribute(Qt.ApplicationAttribute.AA_ShareOpenGLContexts, True)
|
|
app = QApplication(sys.argv)
|
|
app.setApplicationName(APP_NAME)
|
|
app.setApplicationDisplayName(APP_NAME)
|
|
app.setOrganizationName(APP_NAME)
|
|
app.setQuitOnLastWindowClosed(False) # Tray haelt die App am Leben
|
|
|
|
icon_path = Path(__file__).resolve().parent / "assets" / "icon.ico"
|
|
if icon_path.exists():
|
|
app.setWindowIcon(QIcon(str(icon_path)))
|
|
|
|
config = load_config()
|
|
# Cache leeren, wenn seit dem letzten Start ein Update installiert wurde (Login
|
|
# bleibt erhalten, siehe clear_cache_on_update); Startmenue-Verknuepfung fehlt sonst
|
|
# komplett, da Playtube als portables ZIP ohne Installer ausgeliefert wird.
|
|
clear_cache_on_update(__version__)
|
|
ensure_start_menu_shortcut(APP_NAME)
|
|
ensure_play_file_association(APP_NAME)
|
|
|
|
window = MainWindow(config)
|
|
window.show()
|
|
|
|
# Playtube wurde per Doppelklick auf eine heruntergeladene .play-Patchdatei
|
|
# gestartet -> direkt installieren statt selbst etwas herunterzuladen.
|
|
local_patch = _pending_local_patch()
|
|
if local_patch:
|
|
window.install_local_patch(local_patch)
|
|
|
|
return app.exec()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|