Created
August 2, 2022 05:46
-
-
Save m-bartlett/3e69102fd627069d088525f1c7dd5892 to your computer and use it in GitHub Desktop.
Convert a list of YouTube URLs to a single playlist. Open a single tab to watch all the videos instead of opening each video manually.
This file contains hidden or 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
#!/usr/bin/env bash | |
# Usage: | |
# Multiple args: $ youtube-playlist https://youtu.be/############ https://youtu.be/############ ... | |
# Single delimited arg: $ youtube-playlist 'https://youtu.be/############ https://youtu.be/############ ...' | |
youtube-playlist() { | |
local urls=( $(IFS=$'\n'; <<<"$*" grep -o 'v=.*' | cut -f 2 -d=) ) | |
local comma_separated="$(IFS=,; echo "${urls[*]}")" | |
echo "http://www.youtube.com/watch_videos?video_ids=${comma_separated}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment