blob: 6c05e26ba65e09e44471c466a6e20bb742d47173 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#!/bin/sh
# pass this in the command-line
#--script-opts ytdl_hook-ytdl_path=/path/to/this-file/yt-dlp-and-sleep.sh
# or, in configuration ~/.config/mpv/mpv.conf
#script-opts=ytdl_hook-ytdl_path=/path/to/this-file/yt-dlp-and-sleep.sh
(
yt-dlp "$@" 3>&- \
| tee /dev/fd/3 \
| jq '[
.formats | .[] | .available_at
| select(. != null)
| (. - now)
| select(. > 0)
]|max + 0' 2>/dev/null \
| (read t && sleep $t; :)
) 3>&1
|