alias install_no="sudo pacman -Sy"
alias install_ya="yay -S --noconfirm"
alias backupvps="rsync -avhzr --delete --progress --rsh='ssh -p22' user@ip:/ --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found","/swapfile","/boot/*"} /to/dir/"


# Compress a video with CUDA acceleration (GPU from NVIDIA is required)
function reducevideo {
  ffmpeg -hwaccel cuda -i "$1" -c:v libx265 -vtag hvc1 -c:a copy "$2"
}

alias reducevideo="reducevideo"


# Download videos from YouTube in full HD. Creates an JSON file with all the information about the video, includes the chapters, and more.
function ytdl {
  yt-dlp \
  --check-formats \
  --progress \
  --ignore-errors \
  --format "bv*[height<1080][ext=mp4]+ba" \
  --merge-output mkv \
  --write-info-json \
  --write-annotations \
  --write-thumbnail \
  --convert-thumbnails jpg \
  --add-metadata \
  --convert-thumbnail jpg \
  --embed-thumbnail \
  --embed-chapters \
  --embed-info-json \
  --restrict-filenames \
  --concurrent-fragments 3 \
  --sponsorblock-mark all,-preview,-filler,-interaction \
  -o "/to/dir/%(channel)s/%(upload_date>%Y-%m-%d)s - %(title)s.%(ext)s" "$1"

  notify-send "Video file saved."
}

alias ytdl="ytdl"


# Download a video from YouTube and convert it to a MP3 file. Embed the cover to the file.
function ytdla {
  yt-dlp \
  --check-formats \
  --progress \
  --ignore-errors \
  --write-info-json \
  --no-call-home \
  --add-metadata \
  --audio-format "mp3" \
  --extract-audio \
  --format bestaudio/best \
  --embed-thumbnail \
  --restrict-filenames \
  --concurrent-fragments 3 \
  -o "/to/dir/%(uploader)s/%(upload_date>%Y-%m-%d)s - %(title)s (%(id)s).%(ext)s" "$1"

  notify-send "Audio filed saved."
}

alias ytdla="ytdla"


# Compress an image by reducing size and quality and remove all metadata. Inspired from Telegram.
function reduceimage {
  convert -resize 2000x2000 -quality 70 "$1".jpg "$1"-r.webp
  exiftool -overwrite_original -all= "$1"-r.webp
}

alias reduceimage="reduceimage"