#!/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 # 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 " 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