#!/bin/bash

#download and process an array of URLs (any list of videos)
# use this option if you get any relevant errors from youtube:  --cookies-from-browser chrome
 
declare -a arrVideos=(  
"https://www.youtube.com/watch?v=r_rPkQ4Pzis" 
"https://www.youtube.com/watch?v=u1oKtpe1qgs"
);

# download all the videos first
for i in "${arrVideos[@]}"; do
  /Library/Frameworks/Python.framework/Versions/3.13/bin/yt-dlp --no-check-certificate "$i";
done

# Then process em
for i in *.mkv *.mp4 *.webm; do 
  if [ -f "$i" ] 
  then  
    name=`echo "$i" | cut -d'.' -f1`;
    echo -e "\033[1;31m working on: $i  \033[0m"
    ffmpeg -i "$i" "${name}.mp4";
    rm "$i";
  fi
done
 
open .