Skip to content

Instantly share code, notes, and snippets.

@m-bartlett
Created August 2, 2022 05:46
Show Gist options
  • Save m-bartlett/3e69102fd627069d088525f1c7dd5892 to your computer and use it in GitHub Desktop.
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.
#!/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