{ pkgs }: let yt = pkgs.writeShellScriptBin "yt" '' jq="${pkgs.jq}/bin/jq" VIDEO_PATH="$HOME/Videos/Random" mkdir -p "$VIDEO_PATH" json="$(${pkgs.ytfzf}/bin/ytfzf -t --type=video --thumbnail-quality=medium -I vj)" title="$(echo "$json" | jq .[0].title -r)" channel="$(echo "$json" | jq .[0].channel -r)" url="$(echo "$json" | jq .[0].url -r)" cd "$VIDEO_PATH" || exit 1 ${pkgs.yt-dlp}/bin/yt-dlp --write-subs --sub-langs "en.*" --embed-chapters --embed-subs -f "bv*[height<=480]+ba/b[height<=480] / wv*+ba/w" -o "$channel - $title.%(ext)s" "$url" ${pkgs.mpv}/bin/mpv "$channel - $title."* ''; yt-hugger = pkgs.writeShellScriptBin "yt-hugger" '' # # This script download all videos from youtube channels specified in .channels # file into path specified in VIDEOS. # # Channel File Format: # # # # Comment # # ... # VIDEOS="$HOME/Videos/Channel" mkdir -p "$VIDEOS" touch "$VIDEOS/.channels" channels="$(cat "$VIDEOS/.channels" | sed "/^#/d")" [ -z "$channels" ] && echo "Channels file is empty" && exit 1 for entry in "$channels"; do name="''${entry% *}" url="''${entry##* }" ${pkgs.yt-dlp}/bin/yt-dlp \ -f 'bv*[height>=720]+ba' \ --sub-langs "en.*" --embed-subs \ --embed-chapters --embed-thumbnail --embed-metadata \ --download-archive "$name/.archive" \ -o "$name/%(channel)s - %(title)s.%(ext)s" \ "$url" done ''; in pkgs.symlinkJoin { name = "yt"; paths = [ yt yt-hugger ]; }