Skip to content

Instantly share code, notes, and snippets.

@carbone
Last active December 4, 2022 22:28
Show Gist options
  • Select an option

  • Save carbone/c261765b63a27d409e874a96db55faa8 to your computer and use it in GitHub Desktop.

Select an option

Save carbone/c261765b63a27d409e874a96db55faa8 to your computer and use it in GitHub Desktop.
#!/bin/bash
folder="$HOME/Desktop/mp3s"
echo "Many sites are supported. Check this list: https://github.com/yt-dlp/yt-dlp/blob/master/supportedsites.md"
echo -n "Enter URL and press [ENTER]: "
read url
list='&list='
if [[ "$url" == *"$list"* ]]; then
echo -n "This looks like a playlist. Do you want to download the playlist or just one song? [p/s]: "
read choice
fi
if [ "$choice" == "s" ]; then
temp=$url
url=$(echo $temp | cut -d "&" -f1)
fi
yt-dlp -f 'ba' -x --audio-format mp3 $url -o '%(title)s.%(ext)s' --print after_move:filepath --restrict-filenames --paths $folder > $folder/temp.txt
filepath=$(tr '\r' '\n' <$folder/temp.txt | tail -1)
rm $folder/temp.txt
echo -n "Open Transcribe? [y/n]"
read trans
if [ "$trans" = "y" ]; then
open -a Transcribe! $filepath
else
open -R $filepath
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment