Skip to content

Instantly share code, notes, and snippets.

@MoatazAbdAlmageed
Last active July 16, 2022 20:02
Show Gist options
  • Save MoatazAbdAlmageed/842cb41c550ca4b7f3fd7cc4569ed37a to your computer and use it in GitHub Desktop.
Save MoatazAbdAlmageed/842cb41c550ca4b7f3fd7cc4569ed37a to your computer and use it in GitHub Desktop.
#!/bin/bash
# Default Command
# https://ianmuchina.com/blog/08-ytdl/
CMD="yt-dlp"
# Use yt-dlp if avaiable
command -v yt-dlp >/dev/null &&
CMD="yt-dlp" ARGS=""
# Quality Options
Q_HD="720"
Q_FHD="1080"
Q_DEFAULT="$Q_HD"
# Video
ydl() {
"$CMD" "$ARGS" \
--no-playlist \
--embed-subs \
--format "[height<=$Q_DEFAULT]" \
--output "%(uploader)s/%(title)s.%(ext)s" "$@"
}
# Video (720p)
yhd() {
"$CMD" "$ARGS" \
--no-playlist \
--embed-subs \
--format "[height<=$Q_HD]" \
--output "%(uploader)s/%(title)s.%(ext)s" "$@"
}
ypl() {
"$CMD" "$ARGS" \
--yes-playlist \
--format "[height<=$Q_DEFAULT]" \
--output "%(uploader)s/%(playlist)s/%(title)s.%(ext)s" "$@"
}
# Audio
ymp3() {
"$CMD" "$ARGS" \
--extract-audio \
--audio-format mp3 \
--no-playlist \
--embed-thumbnail \
--format "bestaudio" \
--output "$HOME/Music/%(uploader)s/%(title)s.%(ext)s" "$@"
}
# Audio Playlist
ypl3() {
"$CMD" "$ARGS" \
--extract-audio \
--audio-format mp3 \
--yes-playlist \
--embed-thumbnail \
--format "bestaudio" \
--output "$HOME/Music/%(uploader)s/%(playlist)s/%(title)s.%(ext)s" "$@"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment