blob: 9d0ca49607a7c0baa652dc834a910c742fc5fd7d (
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 "$@" \
| tee /dev/fd/3 \
| jq '[
.formats | .[] | .available_at
| select(. != null)
| (. - now)
| select(. > 0)
]|max + 0' \
| (read t && sleep $t; :)
) 3>&1
|