blob: 7d335887e680952bd0dc28312e83030d389b5fc2 (
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
|
#!/bin/bash
# Wrapper for mpv playing an internet video with yt-dlp that lets you select the
# video format to download. Useful when launching e.g. YouTube videos, which
# often have a very high resolution default format that would buffer a lot.
# USAGE: yt-dl-choose <url>
# Opens a dmenu menu with available audio+video formats.
# NOTE: only displays formats that have both audio and video, which have limited
# quality. For highest resolution, we'd also need to provide options for
# combined formats with separate audio and video streams.
# NOTE: when given a video in a YouTube playlist, will only play that video.
NO_PLAYLIST=1
if [[ $# -ne 1 ]]; then
echo "USAGE: yt-dl-choose <url>"
fi
URL="$1"
if [[ $NO_PLAYLIST ]]; then
URL=`echo "$URL" | sed -e 's/&list=.*&/\&/'`
fi
formats=`yt-dlp --list-formats $URL \
| grep -v "audio only" \
| grep -v "video only" \
| grep -v mhtml \
| sed '0,/---------/d' `
format=`echo "$formats" | dmenu | cut -d' ' -f1`
if [ -z "$format" ]; then
exit 0;
fi
mpv --ytdl-format=$format $1
|