]> Git — Sourcephile - julm/julm-nix.git/blob - home-manager/profiles/yt-dlp.nix
yt-dlp: prefer 720p over 480p
[julm/julm-nix.git] / home-manager / profiles / yt-dlp.nix
1 { pkgs, lib, ... }:
2 {
3 imports = [
4 ./aria2c.nix
5 ];
6 home.packages = [
7 # error: phantomjs 1.9.8 has been dropped due to lack of maintenance and security issues
8 #pkgs.phantomjs
9 pkgs.yt-dlp
10 pkgs.ffmpeg-full
11 pkgs.podl
12 ];
13 programs.bash = {
14 initExtra = ''
15 yt-ffmpeg () {
16 yt-dlp \
17 --external-downloader ffmpeg \
18 --external-downloader-args "ffmpeg_i: $FFMPEG_FLAGS" \
19 "$@"
20 }
21 '';
22 shellAliases = {
23 yt = "yt-dlp";
24 yt-480p = "yt-subs --format-sort '+res~480,+vcodec:av01,+acodec:opus'";
25 yt-audio = "yt-dlp -f 'worstaudio[acodec=opus]/worstaudio'";
26 yt-subs = "yt-dlp --write-subs --write-auto-sub --skip-download";
27 yt-subs-fr = "yt-subs --sub-langs '-all,fr-orig,fr'";
28 };
29 };
30 xdg.configFile."yt-dlp/config".text = ''
31 #--download-archive .downloaded
32 --external-downloader aria2c
33 --embed-chapters
34 --embed-subs
35 --sub-langs all
36 --format-sort +res~720,+res~480,+vcodec:av01,+acodec:opus
37 --format ${
38 lib.concatStringsSep "/" [
39 "bestvideo+bestaudio"
40 "best"
41 ]
42 }
43 --output "%(release_date>%Y-%m-%d,upload_date>%Y-%m-%d)s - %(title).150B.%(id)s.%(format_id)s.%(ext)s"
44 --match-filter !is_live
45 --prefer-free-formats
46 --sub-format ass/srt/best
47 --sub-langs "en.*,fr,zh.*,-live_chat,-rechat"
48 --user-agent "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/110.0"
49 '';
50 }