From: Marcel van der Veldt Date: Fri, 16 May 2025 23:05:02 +0000 (+0200) Subject: Remove dependency on cchardet X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=ce545c64278d2c7f8228a7183ae243ae80b88d92;p=music-assistant-server.git Remove dependency on cchardet --- diff --git a/music_assistant/helpers/util.py b/music_assistant/helpers/util.py index 64d38117..8aa995d2 100644 --- a/music_assistant/helpers/util.py +++ b/music_assistant/helpers/util.py @@ -22,7 +22,7 @@ from types import TracebackType from typing import TYPE_CHECKING, Any, ParamSpec, Self, TypeVar, cast from urllib.parse import urlparse -import cchardet as chardet +import chardet import ifaddr from zeroconf import IPVersion @@ -32,6 +32,7 @@ from music_assistant.helpers.process import check_output if TYPE_CHECKING: from collections.abc import Iterator + from chardet.resultdict import ResultDict from zeroconf.asyncio import AsyncServiceInfo from music_assistant.mass import MusicAssistant @@ -567,7 +568,7 @@ async def close_async_generator(agen: AsyncGenerator[Any, None]) -> None: async def detect_charset(data: bytes, fallback: str = "utf-8") -> str: """Detect charset of raw data.""" try: - detected: dict[str, Any] = await asyncio.to_thread(chardet.detect, data) + detected: ResultDict = await asyncio.to_thread(chardet.detect, data) if detected and detected["encoding"] and detected["confidence"] > 0.75: assert isinstance(detected["encoding"], str) # for type checking return detected["encoding"] diff --git a/pyproject.toml b/pyproject.toml index 72696d08..6a21994b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,7 +20,7 @@ dependencies = [ "certifi==2025.4.26", "colorlog==6.9.0", "cryptography==44.0.3", - "faust-cchardet>=2.1.18", + "chardet>=5.2.0", "ifaddr==0.2.0", "mashumaro==3.15", "music-assistant-frontend==2.15.1", diff --git a/requirements_all.txt b/requirements_all.txt index f1a473ca..1973448c 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -17,12 +17,12 @@ audible==0.10.0 bgutil-ytdlp-pot-provider==0.8.3 bidict==0.23.1 certifi==2025.4.26 +chardet>=5.2.0 colorlog==6.9.0 cryptography==44.0.3 deezer-python-async==0.3.0 defusedxml==0.7.1 duration-parser==1.0.1 -faust-cchardet>=2.1.18 hass-client==1.2.0 ibroadcastaio==0.4.0 ifaddr==0.2.0