Created
April 12, 2024 08:45
-
-
Save kidpixo/7bb40d29f269205472e573e981ea86d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#------------------------------------------------ | |
# Name : yt-streamer | |
# Input : youtube URL | |
# Purpose : stream url video from youtube to mpv. see: | |
# https://github.com/ytdl-org/yt-dlp/issues/2124#issuecomment-32429104 | |
# Dependencies : yt-dlp, mpv | |
#------------------------------------------------ | |
yt-streamer() { | |
# add help option == print and exit | |
if [[ "$1" == "-h" ]] || [[ -z "$1" ]] | |
then | |
echo "yt-streamer ():" | |
echo "├─ Description : Stream URL video to mpv via yt-dlp." | |
echo "└─ Usage : yt-streamer ${GREEN}URL${RESET} ${RED}OPTIONS${RESET}" | |
echo " └─ ${RED}OPTIONS${RESET} : passed to yt-dlp, ${GREEN}default${RESET} '-f \"bestaudio/best\"'" | |
echo | |
return 0 | |
else | |
# # caputure all other arguments after 1st URL | |
local ytdl_args="${@:1}" | |
# local ytdl_args="${@:1}" | |
# # check if format is passed, if not add default format | |
# if [[ ! $ytdl_args =~ "-f " ]]; then | |
# ytdl_args=" -f \"bestaudio/best\" \"$ytdl_args\"" | |
# fi | |
yt-dlp -o - -f "bestaudio/best" "${ytdl_args}" | mpv - | |
echo "yt-dlp -o --f \"bestaudio/best\" \"${ytdl_args}\" | mpv -" # debug command | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment