YTMusic: Auto update dependencies for frequently breaking packages (#2311)
authorMarvin Schenkel <marvinschenkel@gmail.com>
Sun, 10 Aug 2025 11:28:20 +0000 (13:28 +0200)
committerGitHub <noreply@github.com>
Sun, 10 Aug 2025 11:28:20 +0000 (13:28 +0200)
Chore(deps): Bump ruff from 0.12.5 to 0.12.7 (#2299)

Bumps [ruff](https://github.com/astral-sh/ruff) from 0.12.5 to 0.12.7.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](https://github.com/astral-sh/ruff/compare/0.12.5...0.12.7)

---
updated-dependencies:
- dependency-name: ruff
  dependency-version: 0.12.7
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
music_assistant/providers/ytmusic/__init__.py
music_assistant/providers/ytmusic/manifest.json
requirements_all.txt

index 05647335c4e4da18b73171f178fbaaaa9e174650..0b021633cbc0d866c4226bdd9fe234ca78753df7 100644 (file)
@@ -3,6 +3,7 @@
 from __future__ import annotations
 
 import asyncio
+import importlib
 import logging
 from collections.abc import AsyncGenerator
 from contextlib import suppress
@@ -11,7 +12,6 @@ from io import StringIO
 from typing import TYPE_CHECKING, Any
 from urllib.parse import unquote
 
-import yt_dlp
 from aiohttp import ClientConnectorError
 from duration_parser import parse as parse_str_duration
 from music_assistant_models.config_entries import ConfigEntry, ConfigValueType
@@ -52,6 +52,7 @@ from ytmusicapi.helpers import get_authorization, sapisid_from_cookie
 
 from music_assistant.constants import CONF_USERNAME, VERBOSE_LOG_LEVEL
 from music_assistant.controllers.cache import use_cache
+from music_assistant.helpers.util import install_package
 from music_assistant.models.music_provider import MusicProvider
 
 from .helpers import (
@@ -115,6 +116,7 @@ YT_PERSONAL_PLAYLISTS = (
     "RDTMAK5uy_mZtXeU08kxXJOUhL0ETdAuZTh1z7aAFAo",  # Archive Mix
 )
 YTM_PREMIUM_CHECK_TRACK_ID = "dQw4w9WgXcQ"
+PACKAGES_TO_INSTALL = ("yt-dlp", "bgutil-ytdlp-pot-provider")
 
 SUPPORTED_FEATURES = {
     ProviderFeature.LIBRARY_ARTISTS,
@@ -194,6 +196,7 @@ class YoutubeMusicProvider(MusicProvider):
     async def handle_async_init(self) -> None:
         """Set up the YTMusic provider."""
         logging.getLogger("yt_dlp").setLevel(self.logger.level + 10)
+        await self._install_packages()
         self._cookie = self.config.get_value(CONF_COOKIE)
         self._po_token_server_url = (
             self.config.get_value(CONF_PO_TOKEN_SERVER_URL) or DEFAULT_PO_TOKEN_SERVER_URL
@@ -920,6 +923,7 @@ class YoutubeMusicProvider(MusicProvider):
         """Figure out the stream URL to use and return the highest quality."""
 
         def _extract_best_stream_url_format() -> dict[str, Any]:
+            yt_dlp = importlib.import_module("yt_dlp")
             url = f"{YTM_DOMAIN}/watch?v={item_id}"
             ydl_opts = {
                 "quiet": self.logger.level > logging.DEBUG,
@@ -1013,3 +1017,11 @@ class YoutubeMusicProvider(MusicProvider):
                 )
             )
         return result
+
+    async def _install_packages(self) -> None:
+        """Install frequently changing packages dynamically."""
+        # NOTE: Google breaks things quite often which requires us to update
+        # some packages very frequently. Installing them dynamically prevents
+        # us from having to update MA to ensure this provider works.
+        for package_name in PACKAGES_TO_INSTALL:
+            await install_package(package_name)
index 1b04803d85a4611121a6e50475d71143b943ee75..7f2df11ee4d6bd06d6e0cc8f46ecdd5e2e080f26 100644 (file)
@@ -7,9 +7,7 @@
   "codeowners": ["@MarvinSchenkel"],
   "requirements": [
     "ytmusicapi==1.10.3",
-    "yt-dlp==2025.6.30",
-    "duration-parser==1.0.1",
-    "bgutil-ytdlp-pot-provider==1.1.0"
+    "duration-parser==1.0.1"
   ],
   "documentation": "https://music-assistant.io/music-providers/youtube-music/",
   "multi_instance": true
index 79cdaa0cbd144855c447b081e7bf12ff901e6fd5..aad444da353f513c8819eff6095ff5514bece2a1 100644 (file)
@@ -16,7 +16,6 @@ aiosqlite==0.21.0
 alexapy==1.29.5
 async-upnp-client==0.45.0
 audible==0.10.0
-bgutil-ytdlp-pot-provider==1.1.0
 bidict==0.23.1
 certifi==2025.7.14
 chardet>=5.2.0
@@ -57,6 +56,5 @@ sxm==0.2.8
 unidecode==1.4.0
 websocket-client==1.8.0
 xmltodict==0.14.2
-yt-dlp==2025.6.30
 ytmusicapi==1.10.3
 zeroconf==0.147.0