blob: 63a78a74fd01598407ef7109a04bdeab37787731 (
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
|
#!/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
video_formats=`yt-dlp --list-formats $URL \
| grep "video only" \
| grep -v mhtml`
echo "video formats are:\n$video_formats"
video_format=`echo "$video_formats" | dmenu | cut -d' ' -f1`
if [ -z "$video_format" ]; then
exit 0;
fi
mpv --ytdl-format="$video_format+bestaudio" $URL
|