Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- HEIGHT=15
- WIDTH=40
- CHOICE_HEIGHT=4
- BACKTITLE="Youtube-DL"
- TITLE="Choose format"
- MENU="Choose one option:"
- OPTIONS=(1 "Normal video"
- 2 "Best video (ffmpeg)"
- 3 "Audio only")
- MODE=$(dialog --clear \
- --backtitle "$BACKTITLE" \
- --title "$TITLE" \
- --menu "$MENU" \
- $HEIGHT $WIDTH $CHOICE_HEIGHT \
- "${OPTIONS[@]}" \
- 2>&1 >/dev/tty)
- clear
- case $MODE in
- 1)
- CHOICE_HEIGHT=5
- TITLE="Choose resolution"
- OPTIONS=(720 "720p"
- 480 "480p"
- 360 "360p"
- 1 "Others")
- RES=$(dialog --clear \
- --backtitle "$BACKTITLE" \
- --title "$TITLE" \
- --menu "$MENU" \
- $HEIGHT $WIDTH $CHOICE_HEIGHT \
- "${OPTIONS[@]}" \
- 2>&1 >/dev/tty)
- if [ "$RES" = "1" ]
- then
- RES=$(dialog --clear \
- --backtitle "$BACKTITLE" \
- --title "Enter resolution" \
- --inputbox "Custom resolution : " \
- $HEIGHT $WIDTH \
- 2>&1 >/dev/tty)
- fi
- youtube-dl -f "best[height <=? $RES]" $1
- ;;
- 2)
- CHOICE_HEIGHT=5
- TITLE="Choose resolution"
- OPTIONS=(720 "720p"
- 480 "480p"
- 360 "360p"
- 1 "Others")
- RES=$(dialog --clear \
- --backtitle "$BACKTITLE" \
- --title "$TITLE" \
- --menu "$MENU" \
- $HEIGHT $WIDTH $CHOICE_HEIGHT \
- "${OPTIONS[@]}" \
- 2>&1 >/dev/tty)
- if [ "$RES" = "1" ]
- then
- RES=$(dialog --clear \
- --backtitle "$BACKTITLE" \
- --title "Enter resolution" \
- --inputbox "Custom resolution : " \
- $HEIGHT $WIDTH \
- 2>&1 >/dev/tty)
- fi
- youtube-dl -f "bestvideo[height <=? $RES]+bestaudio" $1
- ;;
- 3)
- youtube-dl -x --audio-format "mp3" --audio-quality 0 $1
- ;;
- esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement