nixos-config/users/simon/modules/youtube-dl.nix
Simon Bruder 9832f10d03
youtube-dl: Add yt-dlp
youtube-dl currently is unbearably slow (double-digit KiB/s).
2021-08-21 18:55:16 +02:00

33 lines
884 B
Nix

{ lib, pkgs, ... }:
let
# zAudioFormat because a better video format is preferred and
# cartesianProductOfSets cycles through the attributes in lexicographic order
formats = (map
({ videoFormat, zAudioFormat }: "${videoFormat}+${zAudioFormat}")
(lib.cartesianProductOfSets {
videoFormat = [ "bestvideo[vcodec^=av01]" "bestvideo[vcodec^=vp9]" "bestvideo[vcodec^=avc1]" "bestvideo" ];
zAudioFormat = [ "bestaudio[acodec^=opus]" "bestaudio[acodec^=mp4a]" "bestaudio" ];
})) ++ [ "best" ];
options = {
format = lib.concatStringsSep "/" formats;
};
textConfig = lib.concatStringsSep
"\n"
(lib.mapAttrsToList
(k: v: "--${k} ${v}")
options);
in
{
xdg.configFile = {
"youtube-dl/config".text = textConfig;
"yt-dlp/config".text = textConfig;
};
home.packages = with pkgs; [
youtube-dl
unstable.yt-dlp
];
}