Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. HEIGHT=15
  4. WIDTH=40
  5. CHOICE_HEIGHT=4
  6. BACKTITLE="Youtube-DL"
  7. TITLE="Choose format"
  8. MENU="Choose one option:"
  9.  
  10. OPTIONS=(1 "Normal video"
  11. 2 "Best video (ffmpeg)"
  12. 3 "Audio only")
  13.  
  14. MODE=$(dialog --clear \
  15. --backtitle "$BACKTITLE" \
  16. --title "$TITLE" \
  17. --menu "$MENU" \
  18. $HEIGHT $WIDTH $CHOICE_HEIGHT \
  19. "${OPTIONS[@]}" \
  20. 2>&1 >/dev/tty)
  21.  
  22. clear
  23. case $MODE in
  24. 1)
  25. CHOICE_HEIGHT=5
  26. TITLE="Choose resolution"
  27. OPTIONS=(720 "720p"
  28. 480 "480p"
  29. 360 "360p"
  30. 1 "Others")
  31. RES=$(dialog --clear \
  32. --backtitle "$BACKTITLE" \
  33. --title "$TITLE" \
  34. --menu "$MENU" \
  35. $HEIGHT $WIDTH $CHOICE_HEIGHT \
  36. "${OPTIONS[@]}" \
  37. 2>&1 >/dev/tty)
  38.  
  39. if [ "$RES" = "1" ]
  40. then
  41. RES=$(dialog --clear \
  42. --backtitle "$BACKTITLE" \
  43. --title "Enter resolution" \
  44. --inputbox "Custom resolution : " \
  45. $HEIGHT $WIDTH \
  46. 2>&1 >/dev/tty)
  47. fi
  48. youtube-dl -f "best[height <=? $RES]" $1
  49. ;;
  50. 2)
  51. CHOICE_HEIGHT=5
  52. TITLE="Choose resolution"
  53. OPTIONS=(720 "720p"
  54. 480 "480p"
  55. 360 "360p"
  56. 1 "Others")
  57. RES=$(dialog --clear \
  58. --backtitle "$BACKTITLE" \
  59. --title "$TITLE" \
  60. --menu "$MENU" \
  61. $HEIGHT $WIDTH $CHOICE_HEIGHT \
  62. "${OPTIONS[@]}" \
  63. 2>&1 >/dev/tty)
  64.  
  65. if [ "$RES" = "1" ]
  66. then
  67. RES=$(dialog --clear \
  68. --backtitle "$BACKTITLE" \
  69. --title "Enter resolution" \
  70. --inputbox "Custom resolution : " \
  71. $HEIGHT $WIDTH \
  72. 2>&1 >/dev/tty)
  73. fi
  74. youtube-dl -f "bestvideo[height <=? $RES]+bestaudio" $1
  75. ;;
  76. 3)
  77. youtube-dl -x --audio-format "mp3" --audio-quality 0 $1
  78. ;;
  79. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement