Advertisement
AlabamaHit

Download Youtube (All 3)

Mar 9th, 2025 (edited)
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.20 KB | Source Code | 0 0
  1. #!/bin/bash
  2.  
  3. # Ask for the YouTube URL
  4. read -p "Enter the YouTube URL: " URL
  5.  
  6. # If no URL is provided, exit the script
  7. if [ -z "$URL" ]; then
  8.     echo "No URL provided. Exiting..."
  9.     exit 1
  10. fi
  11.  
  12. # Use yt-dlp to get the video title and sanitize it to create a folder name
  13. VIDEO_TITLE=$(yt-dlp -e "$URL" | sed 's/[^a-zA-Z0-9]/_/g')
  14.  
  15. # Create the folder with the video title
  16. mkdir -p "$VIDEO_TITLE"
  17.  
  18. # Download the video and audio (best video + best audio)
  19. yt-dlp -f bestvideo+bestaudio --write-thumbnail --output "$VIDEO_TITLE/%(title)s.%(ext)s" "$URL"
  20.  
  21. # Download the audio as MP3
  22. yt-dlp -f bestaudio --extract-audio --audio-format mp3 --output "$VIDEO_TITLE/%(title)s.%(ext)s" "$URL"
  23.  
  24. # Move thumbnail to the folder (yt-dlp saves it as default name, let's move it to 'thumbnail.jpg')
  25. mv *.jpg "$VIDEO_TITLE/thumbnail.jpg" 2>/dev/null
  26.  
  27. echo "Download complete! Video, audio (MP3), and thumbnail are saved in the '$VIDEO_TITLE' folder."
  28.  
  29.  
  30. ############
  31. # README!! #
  32. ############
  33.  
  34. : '
  35.  
  36. NO SUDO!
  37. This does not need to be ran as admin.
  38.  
  39. Just run the script, enter the url. It will create a folder in same directory.
  40. It will put all 3 files there. The Video, MP3, Thumbnail. All in one shot.
  41.  
  42. '
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement