From adaab8b6ae45c3be14de86f235a42ec17ef88891 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Sun, 4 Aug 2024 22:56:43 +0200 Subject: [PATCH 1/2] python312Packages.aiojellyfin: init at 0.10.0 Simple asyncio library for accessing Jellyfin. --- .../python-modules/aiojellyfin/default.nix | 53 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 55 insertions(+) create mode 100644 pkgs/development/python-modules/aiojellyfin/default.nix diff --git a/pkgs/development/python-modules/aiojellyfin/default.nix b/pkgs/development/python-modules/aiojellyfin/default.nix new file mode 100644 index 000000000000..886346f92bbe --- /dev/null +++ b/pkgs/development/python-modules/aiojellyfin/default.nix @@ -0,0 +1,53 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + + # build-system + setuptools, + + # dependencies + aiohttp, + mashumaro, + + # tests + pytestCheckHook, + pytest-aiohttp, + pytest-cov-stub, +}: + +buildPythonPackage rec { + pname = "aiojellyfin"; + version = "0.10.0"; + pyproject = true; + + src = fetchFromGitHub { + owner = "Jc2k"; + repo = "aiojellyfin"; + rev = "v${version}"; + hash = "sha256-D4/DlhCeeI4CggW7KGauZ57fHY92JM/kZSUODyNVcNg="; + }; + + build-system = [ setuptools ]; + + dependencies = [ + aiohttp + mashumaro + ]; + + nativeCheckInputs = [ + pytestCheckHook + pytest-aiohttp + pytest-cov-stub + ]; + + pythonImportsCheck = [ "aiojellyfin" ]; + + meta = with lib; { + description = ""; + homepage = "https://github.com/Jc2k/aiojellyfin"; + changelog = "https://github.com/Jc2k/aiojellyfin/blob/${src.rev}/CHANGELOG.md"; + license = licenses.asl20; + maintainers = with maintainers; [ hexa ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index c6c3c64b0942..3be8333aabab 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -289,6 +289,8 @@ self: super: with self; { aioinflux = callPackage ../development/python-modules/aioinflux { }; + aiojellyfin = callPackage ../development/python-modules/aiojellyfin { }; + aiojobs = callPackage ../development/python-modules/aiojobs { }; aiokafka = callPackage ../development/python-modules/aiokafka { }; From 37baefd47a0f975f094f08ac11aa649ca4df513d Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Sun, 4 Aug 2024 23:11:31 +0200 Subject: [PATCH 2/2] music-assistant: 2.0.7 -> 2.1.1 https://github.com/music-assistant/server/releases/tag/2.1.0 https://github.com/music-assistant/server/releases/tag/2.1.1 --- pkgs/by-name/mu/music-assistant/ffmpeg.patch | 22 +++++++------- pkgs/by-name/mu/music-assistant/frontend.nix | 4 +-- pkgs/by-name/mu/music-assistant/package.nix | 29 ++++++++++++++----- pkgs/by-name/mu/music-assistant/providers.nix | 14 +++++---- .../mu/music-assistant/update-providers.py | 2 +- 5 files changed, 45 insertions(+), 26 deletions(-) diff --git a/pkgs/by-name/mu/music-assistant/ffmpeg.patch b/pkgs/by-name/mu/music-assistant/ffmpeg.patch index d14e16e37ea1..cb815203aa75 100644 --- a/pkgs/by-name/mu/music-assistant/ffmpeg.patch +++ b/pkgs/by-name/mu/music-assistant/ffmpeg.patch @@ -1,8 +1,8 @@ diff --git a/music_assistant/server/helpers/audio.py b/music_assistant/server/helpers/audio.py -index 42011923..1e5dc112 100644 +index 6b7b5c8e..ec3b92d7 100644 --- a/music_assistant/server/helpers/audio.py +++ b/music_assistant/server/helpers/audio.py -@@ -218,7 +218,7 @@ async def crossfade_pcm_parts( +@@ -214,7 +214,7 @@ async def crossfade_pcm_parts( await outfile.write(fade_out_part) args = [ # generic args @@ -11,7 +11,7 @@ index 42011923..1e5dc112 100644 "-hide_banner", "-loglevel", "quiet", -@@ -281,7 +281,7 @@ async def strip_silence( +@@ -277,7 +277,7 @@ async def strip_silence( ) -> bytes: """Strip silence from begin or end of pcm audio using ffmpeg.""" fmt = ContentType.from_bit_depth(bit_depth) @@ -20,16 +20,16 @@ index 42011923..1e5dc112 100644 args += [ "-acodec", fmt.name.lower(), -@@ -823,7 +823,7 @@ async def get_ffmpeg_stream( +@@ -824,7 +824,7 @@ async def get_ffmpeg_stream( async def check_audio_support() -> tuple[bool, bool, str]: """Check if ffmpeg is present (with/without libsoxr support).""" # check for FFmpeg presence -- returncode, output = await check_output("ffmpeg -version") -+ returncode, output = await check_output("@ffmpeg@ -version") +- returncode, output = await check_output("ffmpeg", "-version") ++ returncode, output = await check_output("@ffmpeg@", "-version") ffmpeg_present = returncode == 0 and "FFmpeg" in output.decode() # use globals as in-memory cache -@@ -877,7 +877,7 @@ async def get_silence( +@@ -878,7 +878,7 @@ async def get_silence( return # use ffmpeg for all other encodings args = [ @@ -38,7 +38,7 @@ index 42011923..1e5dc112 100644 "-hide_banner", "-loglevel", "quiet", -@@ -971,7 +971,7 @@ def get_ffmpeg_args( +@@ -972,7 +972,7 @@ def get_ffmpeg_args( # generic args generic_args = [ @@ -48,10 +48,10 @@ index 42011923..1e5dc112 100644 "-loglevel", loglevel, diff --git a/music_assistant/server/helpers/tags.py b/music_assistant/server/helpers/tags.py -index dc38e4c0..f4f3e2fe 100644 +index d17b55f6..b7b56c04 100644 --- a/music_assistant/server/helpers/tags.py +++ b/music_assistant/server/helpers/tags.py -@@ -368,7 +368,7 @@ async def parse_tags( +@@ -380,7 +380,7 @@ async def parse_tags( file_path = input_file if isinstance(input_file, str) else "-" args = ( @@ -60,7 +60,7 @@ index dc38e4c0..f4f3e2fe 100644 "-hide_banner", "-loglevel", "fatal", -@@ -440,7 +440,7 @@ async def get_embedded_image(input_file: str | AsyncGenerator[bytes, None]) -> b +@@ -471,7 +471,7 @@ async def get_embedded_image(input_file: str | AsyncGenerator[bytes, None]) -> b """ file_path = input_file if isinstance(input_file, str) else "-" args = ( diff --git a/pkgs/by-name/mu/music-assistant/frontend.nix b/pkgs/by-name/mu/music-assistant/frontend.nix index 1db07591408b..b889fe359618 100644 --- a/pkgs/by-name/mu/music-assistant/frontend.nix +++ b/pkgs/by-name/mu/music-assistant/frontend.nix @@ -6,12 +6,12 @@ buildPythonPackage rec { pname = "music-assistant-frontend"; - version = "2.5.15"; + version = "2.7.0"; pyproject = true; src = fetchPypi { inherit pname version; - hash = "sha256-D8VFdXgaVXSxk7c24kvb9TflFztS1zLwW4qGqV32nLo="; + hash = "sha256-KrloxxdqIwQ5NsxAGm28D5StHnw9LTqDDtcchD5X5Qk="; }; postPatch = '' diff --git a/pkgs/by-name/mu/music-assistant/package.nix b/pkgs/by-name/mu/music-assistant/package.nix index fcdd7277b758..c40ccf1a6716 100644 --- a/pkgs/by-name/mu/music-assistant/package.nix +++ b/pkgs/by-name/mu/music-assistant/package.nix @@ -11,6 +11,19 @@ let python = python3.override { self = python; packageOverrides = self: super: { + aiojellyfin = super.aiojellyfin.overridePythonAttrs rec { + version = "0.9.2"; + + src = fetchFromGitHub { + owner = "jc2k"; + repo = "aiojellyfin"; + rev = "refs/tags/v${version}"; + hash = "sha256-q+b1tKr46qq3PULPkCaQk2VoC1aaNxPK/E1Kj4PABfI="; + }; + + doCheck = false; + }; + music-assistant-frontend = self.callPackage ./frontend.nix { }; }; }; @@ -24,14 +37,14 @@ in python.pkgs.buildPythonApplication rec { pname = "music-assistant"; - version = "2.0.7"; + version = "2.1.1"; pyproject = true; src = fetchFromGitHub { owner = "music-assistant"; repo = "server"; - rev = version; - hash = "sha256-JtdlZ3hH4fRU5TjmMUlrdSSCnLrIGCuSwSSrnLgjYEs="; + rev = "refs/tags/${version}"; + hash = "sha256-ALsl2xfAFYejDEhR5/ZpeIxoHFgvz471tb4OP5xQAUE="; }; patches = [ @@ -43,8 +56,6 @@ python.pkgs.buildPythonApplication rec { ]; postPatch = '' - sed -i "/--cov/d" pyproject.toml - substituteInPlace pyproject.toml \ --replace-fail "0.0.0" "${version}" ''; @@ -71,6 +82,7 @@ python.pkgs.buildPythonApplication rec { certifi colorlog cryptography + eyed3 faust-cchardet ifaddr mashumaro @@ -87,10 +99,13 @@ python.pkgs.buildPythonApplication rec { }; nativeCheckInputs = with python.pkgs; [ - ffmpeg-headless + aiojellyfin pytest-aiohttp + pytest-cov-stub pytestCheckHook - ] ++ lib.flatten (lib.attrValues optional-dependencies); + syrupy + ] + ++ lib.flatten (lib.attrValues optional-dependencies); pythonImportsCheck = [ "music_assistant" ]; diff --git a/pkgs/by-name/mu/music-assistant/providers.nix b/pkgs/by-name/mu/music-assistant/providers.nix index 945d570dca30..702dadf127dd 100644 --- a/pkgs/by-name/mu/music-assistant/providers.nix +++ b/pkgs/by-name/mu/music-assistant/providers.nix @@ -1,10 +1,12 @@ # Do not edit manually, run ./update-providers.py { - version = "2.0.7"; + version = "2.1.1"; providers = { airplay = [ ]; + apple_music = [ + ]; # missing pywidevine builtin = [ ]; chromecast = ps: with ps; [ @@ -29,8 +31,9 @@ ]; # missing hass-client hass_players = [ ]; - jellyfin = [ - ]; # missing jellyfin_apiclient_python + jellyfin = ps: with ps; [ + aiojellyfin + ]; musicbrainz = [ ]; opensubsonic = ps: with ps; [ @@ -48,6 +51,7 @@ aioslimproto ]; snapcast = ps: with ps; [ + bidict snapcast ]; sonos = ps: with ps; [ @@ -71,8 +75,8 @@ ugp = [ ]; ytmusic = ps: with ps; [ - pytube + yt-dlp ytmusicapi - ]; + ]; # missing yt-dlp-youtube-accesstoken }; } diff --git a/pkgs/by-name/mu/music-assistant/update-providers.py b/pkgs/by-name/mu/music-assistant/update-providers.py index 301a5041a2e7..ca5d0c52b40d 100755 --- a/pkgs/by-name/mu/music-assistant/update-providers.py +++ b/pkgs/by-name/mu/music-assistant/update-providers.py @@ -102,7 +102,7 @@ async def get_provider_manifests(version: str = "master") -> List: manifests = [] with tempfile.TemporaryDirectory() as tmp: with urlopen( - f"https://github.com/music-assistant/music-assistant/archive/{version}.tar.gz" + f"https://github.com/music-assistant/music-assistant/archive/refs/tags/{version}.tar.gz" ) as response: tarfile.open(fileobj=BytesIO(response.read())).extractall( tmp, filter="data"