From 89e1752d0e4d4e39f7f38587395ed10c2ce9af73 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Sat, 20 Jan 2024 04:04:59 +0000 Subject: [PATCH] centroid: Add mopidy-youtube with yt-dlp stitched in --- machine/centroid/default.nix | 9 ++++- machine/centroid/mopidy-youtube.nix | 58 +++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 machine/centroid/mopidy-youtube.nix diff --git a/machine/centroid/default.nix b/machine/centroid/default.nix index ab48d15..7c73c67 100644 --- a/machine/centroid/default.nix +++ b/machine/centroid/default.nix @@ -43,15 +43,22 @@ "mopidy" "pipewire" # necessary to allow the system service to play sound ]; - services.mopidy = { + services.mopidy = let + mopidy-ytdlp = pkgs.callPackage ./mopidy-youtube.nix { }; + in { enable = true; extensionPackages = with pkgs; [ mopidy-musicbox-webclient + # Replace the default mopidy-youtube, which doesn't have yt-dlp or a way to inject it + mopidy-ytdlp ]; configuration = '' [file] media_dirs = /media/music|Music + + [youtube] + youtube_dl_package = yt_dlp ''; }; diff --git a/machine/centroid/mopidy-youtube.nix b/machine/centroid/mopidy-youtube.nix new file mode 100644 index 0000000..3cdb774 --- /dev/null +++ b/machine/centroid/mopidy-youtube.nix @@ -0,0 +1,58 @@ +{ lib +, fetchFromGitHub +, python3 +, mopidy +}: + +python3.pkgs.buildPythonApplication rec { + pname = "mopidy-youtube"; + version = "3.6"; + format = "setuptools"; + + src = fetchFromGitHub { + owner = "natumbri"; + repo = pname; + rev = "refs/tags/v${version}"; + hash = "sha256-Mp8eCVNGokJRwmYiZYCYRwV1QVDV02Uqfh6fGcPgJss="; + }; + + propagatedBuildInputs = with python3.pkgs; [ + beautifulsoup4 + cachetools + pykka + requests + youtube-dl # this no longer works + yt-dlp # <- added + ytmusicapi + ] ++ [ + mopidy + ]; + + nativeCheckInputs = with python3.pkgs; [ + vcrpy + pytestCheckHook + ]; + + disabledTests = [ + # Test requires a YouTube API key + "test_get_default_config" + ]; + + disabledTestPaths = [ + # Disable tests which interact with Youtube + "tests/test_api.py" + "tests/test_backend.py" + "tests/test_youtube.py" + ]; + + pythonImportsCheck = [ + "mopidy_youtube" + ]; + + meta = with lib; { + description = "Mopidy extension for playing music from YouTube"; + homepage = "https://github.com/natumbri/mopidy-youtube"; + license = licenses.asl20; + maintainers = with maintainers; [ ]; + }; +}