From dce843e98018baffd6a7d2d157d3362d1395fb0f Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Tue, 4 Apr 2023 10:23:25 +0200 Subject: ... --- user-profiles/mpv/default.nix | 211 +++++++++++++++++++++++------------------- user-profiles/yt-dlp.nix | 34 +++---- 2 files changed, 132 insertions(+), 113 deletions(-) (limited to 'user-profiles') diff --git a/user-profiles/mpv/default.nix b/user-profiles/mpv/default.nix index 9c9d077b..908a4de3 100644 --- a/user-profiles/mpv/default.nix +++ b/user-profiles/mpv/default.nix @@ -1,108 +1,125 @@ { config, lib, userName, pkgs, sources, ... }: { - home-manager.users.${userName}.programs.mpv = { - enable = true; - bindings = { - # "CTRL+n" = "af toggle \"lavfi=[dynaudnorm=f=100:g=31:s=20.0]\""; - }; - config = { - ytdl = true; - subs-with-matching-audio = false; - audio-display = false; - osd-font = "Fira Sans"; - sub-font = "Fira Sans"; - # vo = "gpu"; - hwdec = "auto"; - force-window = "yes"; - # af = "lavfi=[dynaudnorm=f=100:g=31:s=20.0]"; - script-opts = lib.concatStringsSep "," [ - "osc-layout=topbar" - "vidscale=no" - "deadzonesize=0.9" - "ytdl_hook-ytdl_path=${pkgs.yt-dlp}/bin/yt-dlp" - "chapterskip-skip=sponsor;intro;endcard;interact" - "chapterskip-categories=sponsor>%[SponsorBlock%]: .*Sponsor.*;intro>%[SponsorBlock%]: .*Intro Animation.*;endcard>%[SponsorBlock%]: .*Endcards.*;interact>%[SponsorBlock%]: .*Interaction Reminder.*" - "sub_select-config=${pkgs.writeTextDir "sub-select.json" (builtins.toJSON [ - { - alang = "*"; - slang = "forced"; - } - { - alang = ["jpn" "ja"]; - slang = "eng?"; - blacklist = [ "sign" ]; - } - { - alang = ["jpn" "ja"]; - slang = "und"; - blacklist = [ "sign" ]; - } - { - alang = ["eng?" "deu?"]; - slang = "no"; - } - { - alang = "*"; - slang = "eng?"; - } - { - alang = "*"; - slang = "und"; - } - ])}" - ]; - }; - scripts = [ - (pkgs.stdenv.mkDerivation (sources.mpv-reload // rec { - installPhase = '' - install -d $out/share/mpv/scripts - install -m 0644 reload.lua $out/share/mpv/scripts/${passthru.scriptName} - ''; + home-manager.users.${userName} = { + programs.mpv = { + enable = true; + bindings = { + # "CTRL+n" = "af toggle \"lavfi=[dynaudnorm=f=100:g=31:s=20.0]\""; + }; + config = { + ytdl = true; + subs-with-matching-audio = false; + audio-display = false; + osd-font = "Fira Sans"; + sub-font = "Fira Sans"; + # vo = "gpu"; + hwdec = "auto"; + force-window = "yes"; + # af = "lavfi=[dynaudnorm=f=100:g=31:s=20.0]"; + script-opts = lib.concatStringsSep "," [ + "osc-layout=topbar" + "vidscale=no" + "deadzonesize=0.9" + "ytdl_hook-ytdl_path=${pkgs.yt-dlp}/bin/yt-dlp" + "chapterskip-skip=sponsor;intro;endcard;interact" + "chapterskip-categories=sponsor>%[SponsorBlock%]: .*Sponsor.*;intro>%[SponsorBlock%]: .*Intro Animation.*;endcard>%[SponsorBlock%]: .*Endcards.*;interact>%[SponsorBlock%]: .*Interaction Reminder.*" + "sub_select-config=${pkgs.writeTextDir "sub-select.json" (builtins.toJSON [ + { + alang = "*"; + slang = "forced"; + } + { + alang = ["jpn" "ja"]; + slang = "eng?"; + blacklist = [ "sign" ]; + } + { + alang = ["jpn" "ja"]; + slang = "und"; + blacklist = [ "sign" ]; + } + { + alang = ["eng?" "deu?"]; + slang = "no"; + } + { + alang = "*"; + slang = "eng?"; + } + { + alang = "*"; + slang = "und"; + } + ])}" + ]; + }; + scripts = [ + (pkgs.stdenv.mkDerivation (sources.mpv-reload // rec { + installPhase = '' + install -d $out/share/mpv/scripts + install -m 0644 reload.lua $out/share/mpv/scripts/${passthru.scriptName} + ''; + + passthru.scriptName = "reload.lua"; + })) + (pkgs.stdenv.mkDerivation (sources.mpv-createchapter // rec { + installPhase = '' + install -d $out/share/mpv/scripts + install -m 0644 createchapter.lua $out/share/mpv/scripts/${passthru.scriptName} + ''; - passthru.scriptName = "reload.lua"; - })) - (pkgs.stdenv.mkDerivation (sources.mpv-createchapter // rec { - installPhase = '' - install -d $out/share/mpv/scripts - install -m 0644 createchapter.lua $out/share/mpv/scripts/${passthru.scriptName} - ''; + passthru.scriptName = "createchapter.lua"; + })) + (pkgs.stdenv.mkDerivation (sources.mpv-autosave // rec { + installPhase = '' + install -d $out/share/mpv/scripts + install -m 0644 autosave.lua $out/share/mpv/scripts/${passthru.scriptName} + ''; - passthru.scriptName = "createchapter.lua"; - })) - (pkgs.stdenv.mkDerivation (sources.mpv-autosave // rec { - installPhase = '' - install -d $out/share/mpv/scripts - install -m 0644 autosave.lua $out/share/mpv/scripts/${passthru.scriptName} - ''; + passthru.scriptName = "autosave.lua"; + })) + (pkgs.stdenv.mkDerivation (sources.mpv-mpris // rec { + installPhase = '' + install -d $out/share/mpv/scripts + install -m 0644 mpris.so $out/share/mpv/scripts/${passthru.scriptName} + ''; - passthru.scriptName = "autosave.lua"; - })) - (pkgs.stdenv.mkDerivation (sources.mpv-mpris // rec { - installPhase = '' - install -d $out/share/mpv/scripts - install -m 0644 mpris.so $out/share/mpv/scripts/${passthru.scriptName} - ''; + nativeBuildInputs = with pkgs; [ pkg-config glib mpv ]; - nativeBuildInputs = with pkgs; [ pkg-config glib mpv ]; + passthru.scriptName = "mpris.so"; + })) + (pkgs.stdenv.mkDerivation (sources.mpv-chapterskip // rec { + installPhase = '' + install -d $out/share/mpv/scripts + install -m 0644 chapterskip.lua $out/share/mpv/scripts/${passthru.scriptName} + ''; - passthru.scriptName = "mpris.so"; - })) - (pkgs.stdenv.mkDerivation (sources.mpv-chapterskip // rec { - installPhase = '' - install -d $out/share/mpv/scripts - install -m 0644 chapterskip.lua $out/share/mpv/scripts/${passthru.scriptName} - ''; + passthru.scriptName = "chapterskip.lua"; + })) + (pkgs.stdenv.mkDerivation (sources.mpv-subselect // rec { + installPhase = '' + install -d $out/share/mpv/scripts + install -m 0644 sub-select.lua $out/share/mpv/scripts/${passthru.scriptName} + ''; - passthru.scriptName = "chapterskip.lua"; - })) - (pkgs.stdenv.mkDerivation (sources.mpv-subselect // rec { - installPhase = '' - install -d $out/share/mpv/scripts - install -m 0644 sub-select.lua $out/share/mpv/scripts/${passthru.scriptName} - ''; + passthru.scriptName = "sub-select.lua"; + })) + (pkgs.stdenv.mkDerivation (sources.mpv-youtube-quality // rec { + patches = [ + (pkgs.fetchpatch { url = "https://github.com/jgreco/mpv-youtube-quality/pull/31.patch"; hash = "sha256-2aTTkW48uRe8XC1ZQ8J5T9sUmZ5F3YAoYCMxqEs2AY8="; }) + (pkgs.fetchpatch { url = "https://github.com/jgreco/mpv-youtube-quality/pull/20.patch"; hash = "sha256-X5BwDsxziYbeiQvrBt8+IS+6oH1i0LvaaYtugL790gg="; }) + ]; + + installPhase = '' + install -d $out/share/mpv/scripts + install -m 0644 youtube-quality.lua $out/share/mpv/scripts/${passthru.scriptName} + ''; + + passthru.scriptName = "youtube-quality.lua"; + })) + ]; + }; - passthru.scriptName = "sub-select.lua"; - })) - ]; + xdg.configFile."mpv/youtube-dl".source = "${pkgs.yt-dlp}/bin/yt-dlp"; }; } diff --git a/user-profiles/yt-dlp.nix b/user-profiles/yt-dlp.nix index 0af42786..1a30ab5a 100644 --- a/user-profiles/yt-dlp.nix +++ b/user-profiles/yt-dlp.nix @@ -1,21 +1,23 @@ { config, lib, userName, pkgs, ... }: { home-manager.users.${userName} = { - home.packages = with pkgs; [ yt-dlp ]; - xdg.configFile."yt-dlp/config".text = '' - --cookies-from-browser firefox - --mark-watched - --format ${lib.concatStringsSep "/" [ - "bestvideo[width<=3840][height<=2160][fps<=60]+bestaudio" - "best[width<=3840][height<=2160][fps<=60]" - "best" - ]} - --sub-langs all,-live_chat - --prefer-free-formats - --embed-metadata - --downloader ${pkgs.aria2}/bin/aria2c - --sponsorblock-mark all - --restrict-filenames - ''; + programs.yt-dlp = { + enable = true; + settings = { + cookies-from-browser = "firefox"; + mark-watched = true; + format = lib.concatStringsSep "/" [ + "bestvideo[width<=3840][height<=2160][fps<=60]+bestaudio" + "best[width<=3840][height<=2160][fps<=60]" + "best" + ]; + sub-langs = "all,-live_chat,-rechat"; + prefer-free-formats = true; + embed-metadata = true; + downloader = "${pkgs.aria2}/bin/aria2c"; + sponsorblock-mark = "all"; + restrict-filenames = true; + }; + }; }; } -- cgit v1.2.3