blob: 3f1fb16e6cf141adea903c7079c01574b18f02c3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
{ 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:
# <name> <url>
# <name> <url>
# # Comment
# <name> <url>
# ...
#
VIDEOS="$HOME/Videos/Channel"
mkdir -p "$VIDEOS"
touch "$VIDEOS/.channels"
cat "$VIDEOS/.channels" | sed "s/\W*#.*//;/^\W*$/d" | while IFS="" read -r entry ; 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 "$VIDEOS/$name/.archive" \
-o "$VIDEOS/$name/%(channel)s - %(title)s.%(ext)s" \
"$url"
done
'';
in pkgs.symlinkJoin {
name = "yt";
paths = [
yt
yt-hugger
];
}
|