Advertisement
v1ral_ITS

dlGUI

Jun 27th, 2018
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 26.30 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. ########
  3. function ByE (){
  4.     printf "\033c"
  5.     echo -e ""
  6.     echo -e '\E[1;31m'"It's "'\E[1;32m'"funny "'\E[1;33m'"how"'\E[1;35m'" the"'\E[1;36m'" colors"'\E[1;31m'" of"'\E[1;32m'" the"'\E[1;33m'" real"'\E[1;35m'" world"'\E[1;36m'" only"
  7.     echo -e '\E[1;31m'"seem"'\E[1;32m'" really"'\E[1;33m'" real"'\E[1;36m'" when"'\E[1;31m'" you"'\E[1;32m'" viddy"'\E[1;33m'" them"'\E[1;35m'" on"'\E[1;36m'" the"'\E[1;31m'" screen"
  8.     tput sgr0
  9.     echo -e ""
  10.     echo -e "Alex, A Clockwork Orange"
  11.     sleep 1
  12.     printf "\033c"
  13.     exit 0
  14. }
  15. ########
  16. function HelP (){
  17.     printf "\033c"
  18.     if ! type less >/dev/null 2>&1; then
  19.     printf "\033c"
  20.     echo -e ""
  21.     echo -e "PMYTD requires file pager \"less\" to display HELP document"
  22.     echo -e "Please install the package \"less\" via the package manager"
  23.     echo -e "For more information on \"less\" please visit it's homepage"
  24.     echo -e "http://www.greenwoodsoftware.com/less/"
  25.     echo -e ""
  26.     read -rsp $'Press any key to return to PMYTD MENU...\n' -n1
  27.     MenU
  28.     fi
  29.     printf "%s\n" "Having problems downloading videos?" "" "YouTube and other video sharing sites continually change their APIs so it's" "advised to keep youtube-dl updated to the latest available version. You can" "check for updates via the PMYTD MENU by running 'Check for updates' option." "" "" "Is YouTube the only supported site?" "" "PMYTD is built with YouTube in mind so at present it only supports YouTube." "" "" "Why can't I get videos in 4K-1080P?" "" "If your system doesn't have either, FFmpeg or Libav installed you won't" "be able to download videos in their highest available resolutions. 720P" "is the highest resolution available without FFmpeg or Libav. To be able" "to download videos in 4K-1080P, you need to open your package manager &" "install either the package 'ffmpeg' or the package 'libav-tools'. There" "is no need to install both of these packages. Hint: We prefer 'ffmpeg'." "" "" "Why can't I play my 4K-1080P video?" "" "You will need a decent computer for playing 4K-1080P videos. Check that" "your hardware is capable of playing 4K-1080P videos. If the hardware is" "adequate then make sure the driver for the graphics card is up-to-date." "Also you'll need a good software to play 4K-1080P videos. We prefer mpv" "on Linux, MPC-HC on Windows and mpv on OS X. In our experience mplayer2" "& VLC both have issues playing 4K-1080P videos downloaded from YouTube." "" "" "Press 'q' to return to PMYTD MENU" "" | less -RM
  30.     MenU
  31. }
  32. ########
  33. function UpdatE (){
  34.     printf "\033c"
  35.     wget --spider --user-agent="Mozilla/5.0 Gecko/20100101" --timeout=30 -q "https://rg3.github.io/youtube-dl/" -O /dev/null || { printf "\033c"; echo -e ""; echo -e "Can't connect to youtube-dl download server site"; echo -e "Make sure the internet connection is up & active"; echo -e ""; read -rsp $'Press any key to return to PMYTD MENU...\n' -n1; MenU; }
  36.     ytdlcv=$(youtube-dl --version)
  37.     ytdllv=$(wget -O- -q "https://rg3.github.io/youtube-dl/update/LATEST_VERSION")
  38.     if [ "$ytdlcv" == "$ytdllv" ]; then
  39.     printf "\033c"
  40.     echo -e ""
  41.     echo -e "Installed version of youtube-dl - $ytdlcv"
  42.     echo -e "Available version of youtube-dl - $ytdllv"
  43.     echo -e ""
  44.     echo -e "youtube-dl is up-to-date"
  45.     echo -e ""
  46.     read -rsp $'Press any key to return to PMYTD MENU...\n' -n1
  47.     MenU
  48.     else
  49.     printf "\033c"
  50.     echo -e ""
  51.     echo -e "Installed version of youtube-dl - $ytdlcv"
  52.     echo -e "Available version of youtube-dl - $ytdllv"
  53.     echo -e ""
  54.     echo -e "youtube-dl update is available"
  55.     echo -e ""
  56.     echo -e "01 Update youtube-dl"
  57.     echo -e "02 Back to main menu"
  58.     echo -e ""
  59.     echo -e "Enter your choice: "
  60.     echo -e ""
  61.     read -er choice
  62.     case $choice in
  63.         01 | 1)
  64.         printf "\033c"
  65.         flytdl=$(which youtube-dl)
  66.         if [ -w "$flytdl" ]; then
  67.             youtube-dl -U || { printf "\033c"; echo -e ""; echo -e "Failed to update youtube-dl"; echo -e "You can try to update later"; echo -e ""; read -rsp $'Press any key to return to PMYTD MENU...\n' -n1; MenU; }
  68.             echo -e ""
  69.             read -rsp $'Press any key to return to PMYTD MENU...\n' -n1
  70.             MenU
  71.         else
  72.             printf "\033c"
  73.             echo -e ""
  74.             echo -e "Superuser privilege required to update youtube-dl"
  75.             echo -e "Select your prefered privilege escalation method: "
  76.             echo -e ""
  77.             echo -e "01 sudo"
  78.             echo -e "02 su"
  79.             echo -e ""
  80.             echo -e "Enter your choice: "
  81.             echo -e ""
  82.             read -er choice
  83.             case $choice in
  84.             01 | 1)
  85.                 printf "\033c"
  86.                 sudo youtube-dl -U || { printf "\033c"; echo -e ""; echo -e "Failed to update youtube-dl"; echo -e "You can try to update later"; echo -e ""; read -rsp $'Press any key to return to PMYTD MENU...\n' -n1; MenU; }
  87.                 echo -e ""
  88.                 read -rsp $'Press any key to return to PMYTD MENU...\n' -n1
  89.                 MenU
  90.                 ;;
  91.             02 | 2)
  92.                 printf "\033c"
  93.                 su -c 'youtube-dl -U' || { printf "\033c"; echo -e ""; echo -e "Failed to update youtube-dl"; echo -e "You can try to update later"; echo -e ""; read -rsp $'Press any key to return to PMYTD MENU...\n' -n1; MenU; }
  94.                 echo -e ""
  95.                 read -rsp $'Press any key to return to PMYTD MENU...\n' -n1
  96.                 MenU
  97.                 ;;
  98.             *)
  99.                 printf "\033c"
  100.                 echo -e ""
  101.                 echo -e "\"$choice\" is an invalid option!!!"
  102.                 echo -e ""
  103.                 echo -e "Correct options to choose are from 1-2"
  104.                 echo -e ""
  105.                 echo -e "To pick \"sudo\" press \"1\" & hit \"Enter\" key"
  106.                 echo -e "To select \"su\" press \"2\" & hit \"Enter\" key"
  107.                 echo -e ""
  108.                 read -rsp $'Press any key to try again...\n' -n1
  109.                 UpdatE
  110.                 ;;
  111.             esac
  112.         fi
  113.         ;;
  114.         02 | 2)
  115.         MenU
  116.         ;;
  117.         *)
  118.         printf "\033c"
  119.         echo -e ""
  120.         echo -e "\"$choice\" is an invalid option!!!"
  121.         echo -e ""
  122.         echo -e "Correct options to choose are from 1-2"
  123.         echo -e ""
  124.         echo -e "To update \"youtube-dl\" press \"1\" & hit \"Enter\" key"
  125.         echo -e "To go back to the menu press \"2\" & hit \"Enter\" key"
  126.         echo -e ""
  127.         read -rsp $'Press any key to try again...\n' -n1
  128.         UpdatE
  129.         ;;
  130.     esac
  131.     fi
  132. }
  133. ########
  134. function AplS(){
  135.     printf "\033c"
  136.     if ! type ffmpeg >/dev/null 2>&1; then
  137.     if ! type avconv >/dev/null 2>&1; then
  138.         printf "\033c"
  139.         echo -e ""
  140.         echo -e "PMYTD requires either \"ffmpeg\" or \"avconv\" to extract MP3 from video"
  141.         echo -e "It seems you don't have either of them installed presently on system"
  142.         echo -e "Please install either \"ffmpeg\" or \"libav-tools\" from package manager"
  143.         echo -e "Visit respective home pages of \"FFmpeg\" and \"Libav\" for further info"
  144.         echo -e "https://ffmpeg.org/"
  145.         echo -e "http://libav.org/"
  146.         echo -e ""
  147.         read -rsp $'Press any key to return to PMYTD MENU...\n' -n1
  148.         MenU
  149.     fi
  150.     fi
  151.     printf "\033c"
  152.     if type ffmpeg >/dev/null 2>&1; then
  153.     if ! ffmpeg -encoders | grep libmp3lame >/dev/null 2>&1; then
  154.         printf "\033c"
  155.         echo -e ""
  156.         echo -e "MP3 encoding library \"libmp3lame\" not found"
  157.         echo -e "Install the package \"lame\" via package manager"
  158.         echo -e ""
  159.         read -rsp $'Press any key to return to PMYTD MENU...\n' -n1
  160.         MenU
  161.     fi
  162.     fi
  163.     printf "\033c"
  164.     if type avconv >/dev/null 2>&1; then
  165.     if ! avconv -encoders | grep libmp3lame >/dev/null 2>&1; then
  166.         printf "\033c"
  167.         echo -e ""
  168.         echo -e "MP3 encoding library \"libmp3lame\" not found"
  169.         echo -e "Install the package \"lame\" via package manager"
  170.         echo -e ""
  171.         read -rsp $'Press any key to return to PMYTD MENU...\n' -n1
  172.         MenU
  173.     fi
  174.     fi
  175.     printf "\033c"
  176.     printf "%s\n" "" "Enter the youtube playlist link: " ""
  177.     read -er link
  178.     ytlnk1="https://www.youtube.com/playlist?list="
  179.     ytlnk2="$link"
  180.     ytlnk3=$(python -c "import sys, urllib as ul; print ul.unquote_plus(sys.argv[1])" "$ytlnk2" | sed -r 's/.*list=([a-zA-Z0-9\_\-]*).*/\1/')
  181.     ytlnk="$ytlnk1$ytlnk3"
  182.     printf "\033c"
  183.     wget --spider --user-agent="Mozilla/5.0 Gecko/20100101" --timeout=30 -q "www.youtube.com" -O /dev/null
  184.     RETVAL=$?
  185.     case "$RETVAL" in
  186.     0)
  187.         printf "\033c"
  188.         if wget --spider --user-agent="Mozilla/5.0 Gecko/20100101" --timeout=30 -q "$ytlnk" -O /dev/null; then
  189.         printf "\033c"
  190.         youtube-dl --ignore-config --continue --console-title --no-warnings --user-agent "Mozilla/5.0 Gecko/20100101" --no-check-certificate --youtube-skip-dash-manifest --yes-playlist --ignore-errors --format bestaudio/best --extract-audio --audio-format "mp3" --audio-quality 0 --output "$DLD_DIR" "$ytlnk" --restrict-filenames || { printf "\033c"; echo -e ""; echo -e "Audio download has failed, Something went wrong!"; echo -e "Make sure the internet connection is up & active"; echo -e ""; read -rsp $'Press any key to return to PMYTD MENU...\n' -n1; MenU; }
  191.         echo -e ""
  192.         echo -e "Successfully completed the download task"
  193.         echo -e ""
  194.         read -rsp $'Press any key to return to PMYTD MENU...\n' -n1
  195.         MenU
  196.         else
  197.         printf "\033c"
  198.         echo -e ""
  199.         echo -e "Failed to get required information on playlist link"
  200.         echo -e "Make sure the playlist link exists and is reachable"
  201.         echo -e "Check that the videos are available in your country"
  202.         echo -e ""
  203.         read -rsp $'Press any key to return to PMYTD MENU...\n' -n1
  204.         MenU
  205.         fi
  206.         ;;
  207.     *)
  208.         printf "\033c"
  209.         echo -e ""
  210.         echo -e "Your internet connection seems inactive or down"
  211.         echo -e "PMYTD can't function without access to \"YouTube\""
  212.         echo -e "Please check your internet settings & try later"
  213.         echo -e ""
  214.         read -rsp $'Press any key to return to PMYTD MENU...\n' -n1
  215.         MenU
  216.         ;;
  217.     esac
  218. }
  219. ########
  220. function VplS(){
  221.     printf "\033c"
  222.     printf "%s\n" "" "Enter the youtube playlist link: " ""
  223.     read -er link
  224.     ytlnk1="https://www.youtube.com/playlist?list="
  225.     ytlnk2="$link"
  226.     ytlnk3=$(python -c "import sys, urllib as ul; print ul.unquote_plus(sys.argv[1])" "$ytlnk2" | sed -r 's/.*list=([a-zA-Z0-9\_\-]*).*/\1/')
  227.     ytlnk="$ytlnk1$ytlnk3"
  228.     printf "\033c"
  229.     wget --spider --user-agent="Mozilla/5.0 Gecko/20100101" --timeout=30 -q "www.youtube.com" -O /dev/null
  230.     RETVAL=$?
  231.     case "$RETVAL" in
  232.     0)
  233.         printf "\033c"
  234.         if ! wget --spider --user-agent="Mozilla/5.0 Gecko/20100101" --timeout=30 -q "$ytlnk" -O /dev/null; then
  235.         printf "\033c"
  236.         echo -e ""
  237.         echo -e "Failed to get required information on playlist link"
  238.         echo -e "Make sure the playlist link exists and is reachable"
  239.         echo -e "Check that the videos are available in your country"
  240.         echo -e ""
  241.         read -rsp $'Press any key to return to PMYTD MENU...\n' -n1
  242.         MenU
  243.         fi
  244.         printf "\033c"
  245.         if ! type ffmpeg >/dev/null 2>&1; then
  246.         if ! type avconv >/dev/null 2>&1; then
  247.             printf "\033c"
  248.             youtube-dl --ignore-config --continue --console-title --no-warnings --user-agent "Mozilla/5.0 Gecko/20100101" --no-check-certificate --youtube-skip-dash-manifest --yes-playlist --ignore-errors --format best --output "$DLD_DIR" "$ytlnk" --restrict-filenames || { printf "\033c"; echo -e ""; echo -e "Video download has failed, Something went wrong!"; echo -e "Make sure the internet connection is up & active"; echo -e ""; read -rsp $'Press any key to return to PMYTD MENU...\n' -n1; MenU; }
  249.             echo -e ""
  250.             echo -e "Successfully completed the download task"
  251.             echo -e ""
  252.             read -rsp $'Press any key to return to PMYTD MENU...\n' -n1
  253.             MenU
  254.         fi
  255.         fi
  256.         printf "\033c"
  257.         youtube-dl --ignore-config --continue --console-title --no-warnings --user-agent "Mozilla/5.0 Gecko/20100101" --no-check-certificate --youtube-skip-dash-manifest --yes-playlist --ignore-errors --format bestvideo+bestaudio/best --output "$DLD_DIR" "$ytlnk" --restrict-filenames || { printf "\033c"; echo -e ""; echo -e "Video download has failed, Something went wrong!"; echo -e "Make sure the internet connection is up & active"; echo -e ""; read -rsp $'Press any key to return to PMYTD MENU...\n' -n1; MenU; }
  258.         echo -e ""
  259.         echo -e "Successfully completed the download task"
  260.         echo -e ""
  261.         read -rsp $'Press any key to return to PMYTD MENU...\n' -n1
  262.         MenU
  263.         ;;
  264.     *)
  265.         printf "\033c"
  266.         echo -e ""
  267.         echo -e "Your internet connection seems inactive or down"
  268.         echo -e "PMYTD can't function without access to \"YouTube\""
  269.         echo -e "Please check your internet settings & try later"
  270.         echo -e ""
  271.         read -rsp $'Press any key to return to PMYTD MENU...\n' -n1
  272.         MenU
  273.         ;;
  274.     esac
  275. }
  276. ########
  277. function AudiO (){
  278.     printf "\033c"
  279.     if ! type ffmpeg >/dev/null 2>&1; then
  280.     if ! type avconv >/dev/null 2>&1; then
  281.         printf "\033c"
  282.         echo -e ""
  283.         echo -e "PMYTD requires either \"ffmpeg\" or \"avconv\" to extract MP3 from video"
  284.         echo -e "It seems you don't have either of them installed presently on system"
  285.         echo -e "Please install either \"ffmpeg\" or \"libav-tools\" from package manager"
  286.         echo -e "Visit respective home pages of \"FFmpeg\" and \"Libav\" for further info"
  287.         echo -e "https://ffmpeg.org/"
  288.         echo -e "http://libav.org/"
  289.         echo -e ""
  290.         read -rsp $'Press any key to return to PMYTD MENU...\n' -n1
  291.         MenU
  292.     fi
  293.     fi
  294.     printf "\033c"
  295.     if type ffmpeg >/dev/null 2>&1; then
  296.     if ! ffmpeg -encoders | grep libmp3lame >/dev/null 2>&1; then
  297.         printf "\033c"
  298.         echo -e ""
  299.         echo -e "MP3 encoding library \"libmp3lame\" not found"
  300.         echo -e "Install the package \"lame\" via package manager"
  301.         echo -e ""
  302.         read -rsp $'Press any key to return to PMYTD MENU...\n' -n1
  303.         MenU
  304.     fi
  305.     fi
  306.     printf "\033c"
  307.     if type avconv >/dev/null 2>&1; then
  308.     if ! avconv -encoders | grep libmp3lame >/dev/null 2>&1; then
  309.         printf "\033c"
  310.         echo -e ""
  311.         echo -e "MP3 encoding library \"libmp3lame\" not found"
  312.         echo -e "Install the package \"lame\" via package manager"
  313.         echo -e ""
  314.         read -rsp $'Press any key to return to PMYTD MENU...\n' -n1
  315.         MenU
  316.     fi
  317.     fi
  318.     printf "\033c"
  319.     printf "%s\n" "" "Enter the youtube video link: " ""
  320.     read -er link
  321.     ytlnk1="https://www.youtube.com/watch?v="
  322.     ytlnk2="$link"
  323.     ytlnk3=$(python -c "import sys, urllib as ul; print ul.unquote_plus(sys.argv[1])" "$ytlnk2" | sed -r 's/.*v=([a-zA-Z0-9\_\-]*).*/\1/')
  324.     ytlnk="$ytlnk1$ytlnk3"
  325.     printf "\033c"
  326.     wget --spider --user-agent="Mozilla/5.0 Gecko/20100101" --timeout=30 -q "www.youtube.com" -O /dev/null
  327.     RETVAL=$?
  328.     case "$RETVAL" in
  329.     0)
  330.         printf "\033c"
  331.         if wget --spider --user-agent="Mozilla/5.0 Gecko/20100101" --timeout=30 -q "$ytlnk" -O /dev/null; then
  332.         printf "\033c"
  333.         youtube-dl --ignore-config --continue --console-title --no-warnings --user-agent "Mozilla/5.0 Gecko/20100101" --no-check-certificate --youtube-skip-dash-manifest --no-playlist --format bestaudio/best --extract-audio --audio-format "mp3" --audio-quality 0 --output "$DLD_DIR" "$ytlnk" --restrict-filenames || { printf "\033c"; echo -e ""; echo -e "Audio download has failed, Something went wrong!"; echo -e "Make sure the internet connection is up & active"; echo -e ""; read -rsp $'Press any key to return to PMYTD MENU...\n' -n1; MenU; }
  334.         echo -e ""
  335.         echo -e "Successfully completed the download task"
  336.         echo -e ""
  337.         read -rsp $'Press any key to return to PMYTD MENU...\n' -n1
  338.         MenU
  339.         else
  340.         printf "\033c"
  341.         echo -e ""
  342.         echo -e "Failed to get required information on video link"
  343.         echo -e "Make sure the video link exists and is reachable"
  344.         echo -e "Check that the video is available in your region"
  345.         echo -e ""
  346.         read -rsp $'Press any key to return to PMYTD MENU...\n' -n1
  347.         MenU
  348.         fi
  349.         ;;
  350.     *)
  351.         printf "\033c"
  352.         echo -e ""
  353.         echo -e "Your internet connection seems inactive or down"
  354.         echo -e "PMYTD can't function without access to \"YouTube\""
  355.         echo -e "Please check your internet settings & try later"
  356.         echo -e ""
  357.         read -rsp $'Press any key to return to PMYTD MENU...\n' -n1
  358.         MenU
  359.         ;;
  360.     esac
  361. }
  362. ########
  363. function FormaT (){
  364.     printf "\033c"
  365.     printf "%s\n" "" "Enter the youtube video link: " ""
  366.     read -er link
  367.     ytlnk1="https://www.youtube.com/watch?v="
  368.     ytlnk2="$link"
  369.     ytlnk3=$(python -c "import sys, urllib as ul; print ul.unquote_plus(sys.argv[1])" "$ytlnk2" | sed -r 's/.*v=([a-zA-Z0-9\_\-]*).*/\1/')
  370.     ytlnk="$ytlnk1$ytlnk3"
  371.     printf "\033c"
  372.     wget --spider --user-agent="Mozilla/5.0 Gecko/20100101" --timeout=30 -q "www.youtube.com" -O /dev/null
  373.     RETVAL=$?
  374.     case "$RETVAL" in
  375.     0)
  376.         printf "\033c"
  377.         if wget --spider --user-agent="Mozilla/5.0 Gecko/20100101" --timeout=30 -q "$ytlnk" -O /dev/null; then
  378.         printf "\033c"
  379.         echo -e ""
  380.         echo -e "01 Automatically download video in the best available quality"
  381.         echo -e "02 Manually pick video resolution-quality-format and download"
  382.         echo -e ""
  383.         echo -e "Enter your choice: "
  384.         echo -e ""
  385.         read -er choice
  386.         case $choice in
  387.             01 | 1)
  388.             printf "\033c"
  389.             if ! type ffmpeg >/dev/null 2>&1; then
  390.                 if ! type avconv >/dev/null 2>&1; then
  391.                 printf "\033c"
  392.                 youtube-dl --ignore-config --continue --console-title --no-warnings --user-agent "Mozilla/5.0 Gecko/20100101" --no-check-certificate --youtube-skip-dash-manifest --no-playlist --format best --output "$DLD_DIR" "$ytlnk" --restrict-filenames || { printf "\033c"; echo -e ""; echo -e "Video download has failed, Something went wrong!"; echo -e "Make sure the internet connection is up & active"; echo -e ""; read -rsp $'Press any key to return to PMYTD MENU...\n' -n1; MenU; }
  393.                 echo -e ""
  394.                 echo -e "Successfully completed the download task"
  395.                 echo -e ""
  396.                 read -rsp $'Press any key to return to PMYTD MENU...\n' -n1
  397.                 MenU
  398.                 fi
  399.             fi
  400.             printf "\033c"
  401.             youtube-dl --ignore-config --continue --console-title --no-warnings --user-agent "Mozilla/5.0 Gecko/20100101" --no-check-certificate --youtube-skip-dash-manifest --no-playlist --format bestvideo+bestaudio --output "$DLD_DIR" "$ytlnk" --restrict-filenames || { printf "\033c"; echo -e ""; echo -e "Video download has failed, Something went wrong!"; echo -e "Make sure the internet connection is up & active"; echo -e ""; read -rsp $'Press any key to return to PMYTD MENU...\n' -n1; MenU; }
  402.             echo -e ""
  403.             echo -e "Successfully completed the download task"
  404.             echo -e ""
  405.             read -rsp $'Press any key to return to PMYTD MENU...\n' -n1
  406.             MenU
  407.             ;;
  408.             02 | 2)
  409.             printf "\033c"
  410.             youtube-dl --ignore-config --no-warnings --user-agent "Mozilla/5.0 Gecko/20100101" --no-check-certificate --youtube-skip-dash-manifest --no-playlist --list-formats "$ytlnk" | sed -e '/only/d' -e '0,/Available/d' || { printf "\033c"; echo -e ""; echo -e "Failed to get required information on video link"; echo -e "Make sure the internet connection is up & active"; echo -e ""; read -rsp $'Press any key to return to PMYTD MENU...\n' -n1; MenU; }
  411.             printf "%s\n" "" "Enter your desired video format code from the above list: " ""
  412.             read -er list
  413.             printf "\033c"
  414.             youtube-dl --ignore-config --continue --console-title --no-warnings --user-agent "Mozilla/5.0 Gecko/20100101" --no-check-certificate --youtube-skip-dash-manifest --no-playlist --format "$list" --output "$DLD_DIR" "$ytlnk" --restrict-filenames || { printf "\033c"; echo -e ""; echo -e "Video download has failed, Something went wrong!"; echo -e "Make sure the internet connection is up & active"; echo -e ""; read -rsp $'Press any key to return to PMYTD MENU...\n' -n1; MenU; }
  415.             echo -e ""
  416.             echo -e "Successfully completed the download task"
  417.             echo -e ""
  418.             read -rsp $'Press any key to return to PMYTD MENU...\n' -n1
  419.             MenU
  420.             ;;
  421.             *)
  422.             printf "\033c"
  423.             echo -e ""
  424.             echo -e "\"$choice\" is an invalid option!!!"
  425.             echo -e ""
  426.             echo -e "Correct options to choose are from 1-2"
  427.             echo -e ""
  428.             echo -e "To download video with best quality press \"1\" & hit \"Enter\" key"
  429.             echo -e "To manually select video resolution press \"2\" & hit \"Enter\" key"
  430.             echo -e ""
  431.             read -rsp $'Press any key to try again...\n' -n1
  432.             FormaT
  433.             ;;
  434.         esac
  435.         else
  436.         printf "\033c"
  437.         echo -e ""
  438.         echo -e "Failed to get required information on video link"
  439.         echo -e "Make sure the video link exists and is reachable"
  440.         echo -e "Check that the video is available in your region"
  441.         echo -e ""
  442.         read -rsp $'Press any key to return to PMYTD MENU...\n' -n1
  443.         MenU
  444.         fi
  445.         ;;
  446.     *)
  447.         printf "\033c"
  448.         echo -e ""
  449.         echo -e "Your internet connection seems inactive or down"
  450.         echo -e "PMYTD can't function without access to \"YouTube\""
  451.         echo -e "Please check your internet settings & try later"
  452.         echo -e ""
  453.         read -rsp $'Press any key to return to PMYTD MENU...\n' -n1
  454.         MenU
  455.         ;;
  456.     esac
  457. }
  458. ########
  459. function MenU (){
  460.     printf "\033c"
  461.     if type xdg-user-dir >/dev/null 2>&1; then
  462.     DIR_CHECK="$(xdg-user-dir DOWNLOAD)"
  463.     if [ "${DIR_CHECK}" != "${HOME}" ]; then
  464.         DIR="${DIR_CHECK}"
  465.         test -d "$DIR" || mkdir -p "$DIR"
  466.         DLD_DIR="${DIR}/%(title)s.%(ext)s"
  467.     else
  468.         DIR="${HOME}/Downloads"
  469.         test -d "${DIR}" || mkdir -p "${DIR}"
  470.         DLD_DIR="${DIR}/%(title)s.%(ext)s"
  471.     fi
  472.     fi
  473.     printf "\033c"
  474.     echo -e "** PMYTD<>MENU ****************************"
  475.     echo -e ""
  476.     echo -e "01 Download a video"
  477.     echo -e "02 Download & extract audio from a video"
  478.     echo -e "03 Download an entire youtube playlist"
  479.     echo -e "04 Download & extract audio from a playlist"
  480.     echo -e "05 Check for updates"
  481.     echo -e "06 Help"
  482.     echo -e "07 Quit PMYTD"
  483.     echo -e ""
  484.     echo -e "*******************************************"
  485.     echo -e "   Enter your choice: "
  486.     echo -e ""
  487.     read -er choice
  488.     case $choice in
  489.     01 | 1)
  490.         FormaT
  491.         ;;
  492.     02 | 2)
  493.         AudiO
  494.         ;;
  495.     03 | 3)
  496.         VplS
  497.         ;;
  498.     04 | 4)
  499.         AplS
  500.         ;;
  501.     05 | 5)
  502.         UpdatE
  503.         ;;
  504.     06 | 6)
  505.         HelP
  506.         ;;
  507.     07 | 7)
  508.         ByE
  509.         ;;
  510.     *)
  511.         printf "\033c"
  512.         echo -e ""
  513.         echo -e "\"$choice\" is an invalid option!!!"
  514.         echo -e ""
  515.         echo -e "Correct options to choose are from 1-2-3-4-5-6-7"
  516.         echo -e ""
  517.         echo -e "To download a video press \"1\" & hit \"Enter\" key"
  518.         echo -e "To download only the audio press \"2\" & hit \"Enter\" key"
  519.         echo -e "To download an entire playlist press  \"3\" & hit \"Enter\" key"
  520.         echo -e "To download only the audio from a playlist press \"4\" & hit \"Enter\" key"
  521.         echo -e "To check for youtube-dl updates press \"5\" & hit \"Enter\" key"
  522.         echo -e "To get help on using PMYTD press \"6\" & hit \"Enter\" key"
  523.         echo -e "To exit from PMYTD  press \"7\" & hit \"Enter\" key"
  524.         echo -e ""
  525.         read -rsp $'Press any key to try again...\n' -n1
  526.         MenU
  527.         ;;
  528.     esac
  529. }
  530. ########
  531. function DepChk (){
  532.     printf "\033c"
  533.     type python >/dev/null 2>&1 || { printf "\033c"; echo -e ""; for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; echo -e ""; echo -e '\e[38;5;82m'"A required PMYTD dependency \"Python\" is unavailable"; echo -e '\e[38;5;82m'"\"Python\" is available for almost all linux distros."; echo -e '\e[38;5;82m'"Please install \"python\" using your package manager."; echo -e '\e[38;5;82m'"Please visit the homepage of \"Python\" for more info"; echo -e '\e[38;5;82m'"https://www.python.org/"; echo -e ""; for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; echo -e ""; tput sgr0; exit 1; }
  534.     type wget >/dev/null 2>&1 || { printf "\033c"; echo -e ""; for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; echo -e ""; echo -e '\e[38;5;82m'"A required PMYTD dependency \"Wget\" is unavailable"; echo -e '\e[38;5;82m'"\"Wget\" is available for almost all linux distros."; echo -e '\e[38;5;82m'"Please install \"wget\" using your package manager."; echo -e '\e[38;5;82m'"Please visit the homepage of \"Wget\" for more info"; echo -e '\e[38;5;82m'"https://www.gnu.org/software/wget/"; echo -e ""; for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; echo -e ""; tput sgr0; exit 1; }
  535.     if ! type youtube-dl >/dev/null 2>&1; then
  536.     printf "\033c"
  537.     echo -e ""
  538.     echo -e "PMYTD requires youtube-dl but it's unavailable"
  539.     echo -e ""
  540.     echo -e "Press \"Y\" to download and install youtube-dl"
  541.     echo -e "Press \"N\" to leave without making any change"
  542.     echo -e ""
  543.     echo -e "Enter your choice: "
  544.     echo -e ""
  545.     read -er choice
  546.     case $choice in
  547.         Y | y)
  548.         printf "\033c"
  549.         echo -e ""
  550.         echo -e "Superuser privileges needed to install youtube-dl"
  551.         echo -e "Select your prefered privilege escalation method: "
  552.         echo -e ""
  553.         echo -e "01 sudo"
  554.         echo -e "02 su"
  555.         echo -e ""
  556.         echo -e "Enter your choice: "
  557.         echo -e ""
  558.         read -er choice
  559.         case $choice in
  560.             01 | 1)
  561.             printf "\033c"
  562.             wget --spider --user-agent="Mozilla/5.0 Gecko/20100101" --timeout=30 -q "https://rg3.github.io/youtube-dl/" -O /dev/null || { printf "\033c"; echo -e ""; echo -e "Can't connect to youtube-dl download server site"; echo -e "Make sure the internet connection is up & active"; echo -e ""; exit 1; }
  563.             sudo sh -c 'wget --user-agent="Mozilla/5.0 Gecko/20100101" --quiet --timeout=30 "https://yt-dl.org/downloads/latest/youtube-dl" --output-document "/usr/local/bin/youtube-dl"' || { printf "\033c"; echo -e ""; echo -e "Failed to install youtube-dl"; echo -e "Please try the install later"; echo -e ""; exit 1; }
  564.             sudo sh -c 'chmod 755 "/usr/local/bin/youtube-dl"' || { printf "\033c"; echo -e ""; echo -e "Failed to install youtube-dl"; echo -e "Please try the install later"; echo -e ""; exit 1; }
  565.             MenU
  566.             ;;
  567.             02 | 2)
  568.             printf "\033c"
  569.             wget --spider --user-agent="Mozilla/5.0 Gecko/20100101" --timeout=30 -q "https://rg3.github.io/youtube-dl/" -O /dev/null || { printf "\033c"; echo -e ""; echo -e "Can't connect to youtube-dl download server site"; echo -e "Make sure the internet connection is up & active"; echo -e ""; exit 1; }
  570.             su -c 'wget --user-agent="Mozilla/5.0 Gecko/20100101" --quiet --timeout=30 "https://yt-dl.org/downloads/latest/youtube-dl" --output-document "/usr/local/bin/youtube-dl"' || { printf "\033c"; echo -e ""; echo -e "Failed to install youtube-dl"; echo -e "Please try the install later"; echo -e ""; exit 1; }
  571.             su -c 'chmod 755 "/usr/local/bin/youtube-dl"' || { printf "\033c"; echo -e ""; echo -e "Failed to install youtube-dl"; echo -e "Please try the install later"; echo -e ""; exit 1; }
  572.             MenU
  573.             ;;
  574.             *)
  575.             printf "\033c"
  576.             echo -e ""
  577.             echo -e "\"$choice\" is an invalid option!!!"
  578.             echo -e ""
  579.             echo -e "Correct options to choose are from 1-2"
  580.             echo -e ""
  581.             echo -e "To pick \"sudo\" press \"1\" & hit \"Enter\" key"
  582.             echo -e "To select \"su\" press \"2\" & hit \"Enter\" key"
  583.             echo -e ""
  584.             read -rsp $'Press any key to try again...\n' -n1
  585.             DepChk
  586.             ;;
  587.         esac
  588.         ;;
  589.         N | n)
  590.         printf "\033c"
  591.         exit 1
  592.         ;;
  593.         *)
  594.         printf "\033c"
  595.         echo -e ""
  596.         echo -e "\"$choice\" is an invalid option!!!"
  597.         echo -e ""
  598.         echo -e "Correct options to choose are from Y-N"
  599.         echo -e ""
  600.         echo -e "To install \"youtube-dl\" press \"Y\" & hit \"Enter\" key"
  601.         echo -e "To leave \"PMYTD\" script press \"N\" & hit \"Enter\" key"
  602.         echo -e ""
  603.         read -rsp $'Press any key to try again...\n' -n1
  604.         DepChk
  605.         ;;
  606.     esac
  607.     else
  608.     MenU
  609.     fi
  610. }
  611. while :
  612. do
  613.     DepChk
  614. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement