1{
2 lib,
3 fetchFromGitHub,
4 pythonPackages,
5 mopidy,
6 pkgs,
7 extraPkgs ? pkgs: [ ],
8}:
9
10pythonPackages.buildPythonApplication rec {
11 pname = "mopidy-youtube";
12 version = "3.7";
13 pyproject = true;
14
15 src = fetchFromGitHub {
16 owner = "natumbri";
17 repo = "mopidy-youtube";
18 tag = "v${version}";
19 hash = "sha256-iFt7r8Ljymc+grNJiOClTHkZOeo7AcYpcNc8tLMPROk=";
20 };
21
22 postPatch = ''
23 substituteInPlace mopidy_youtube/youtube.py \
24 --replace-fail 'youtube_dl_package = "youtube_dl"' 'youtube_dl_package = "yt_dlp"'
25 substituteInPlace tests/conftest.py \
26 --replace-fail 'import youtube_dl' 'import yt_dlp' \
27 --replace-fail 'patcher = mock.patch.object(youtube, "youtube_dl", spec=youtube_dl)' \
28 'patcher = mock.patch.object(youtube, "youtube_dl", spec=yt_dlp)' \
29 --replace-fail '"youtube_dl_package": "youtube_dl",' '"youtube_dl_package": "yt_dlp",'
30 '';
31
32 build-system = [
33 pythonPackages.setuptools
34 ];
35
36 dependencies = [
37 mopidy
38 pythonPackages.beautifulsoup4
39 pythonPackages.cachetools
40 pythonPackages.pykka
41 pythonPackages.requests
42 pythonPackages.ytmusicapi
43 pythonPackages.yt-dlp
44 ]
45 ++ extraPkgs pkgs; # should we remove this? If we do, don't forget to also change the docs!
46
47 nativeCheckInputs = with pythonPackages; [
48 vcrpy
49 pytestCheckHook
50 ];
51
52 disabledTests = [
53 # Test requires a YouTube API key
54 "test_get_default_config"
55 ];
56
57 disabledTestPaths = [
58 # Disable tests which interact with Youtube
59 "tests/test_api.py"
60 "tests/test_backend.py"
61 "tests/test_youtube.py"
62 ];
63
64 pythonImportsCheck = [ "mopidy_youtube" ];
65
66 meta = with lib; {
67 description = "Mopidy extension for playing music from YouTube";
68 homepage = "https://github.com/natumbri/mopidy-youtube";
69 license = licenses.asl20;
70 maintainers = [ ];
71 };
72}