Skip to content

Instantly share code, notes, and snippets.

@andersonbosa
Last active December 1, 2023 11:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andersonbosa/03ebaa9a98fa06d81ce66ee57e8cedb6 to your computer and use it in GitHub Desktop.
Save andersonbosa/03ebaa9a98fa06d81ce66ee57e8cedb6 to your computer and use it in GitHub Desktop.
Set a timer to download videos from YouTube using `yt-dlp`. Used in Ubuntu Mantic.
#!/bin/sh
#
# Author:
# https://github.com/andersonbosa
#
# Description
# Set a timer to download videos from YouTube using `yt-dlp`.
#
# Tested:
# Used in Ubuntu Mantic.
#
# Use example:
# ./youtube_downloader.sh 10m https://www.youtube.com/watch?v=8y3Q_PnhQYo
#
# Requeriments:
# yt-dlp - https://github.com/yt-dlp/yt-dlp
#
set -e
if [ ! "$(command -v yt-dlp)" ]; then
echo 'Missing dependency! Install "yt-dlp" to use.'
echo 'Check: "https://github.com/yt-dlp/yt-dlp"'
fi
SLEEP_TIME="$1"
VIDEO_LINK="$2"
notify-send "$0" "Wating $SLEEP_TIME before download... $VIDEO_LINK"
sleep "$SLEEP_TIME"
cd ~/Videos
notify-send "$0" "Initing download..." &&
yt-dlp -f mp4 $VIDEO_LINK &&
open .
notify-send "$0" "Video '$(ls -t | head -n1)' downloaded! \nSee ~/Videos"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment