Guest User

Untitled

a guest
May 27th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. # Copyright (c) 2018 José Rafael dos Santos
  4. #
  5. # Permission is hereby granted, free of charge, to any person obtaining a copy
  6. # of this software and associated documentation files (the "Software"), to deal
  7. # in the Software without restriction, including without limitation the rights
  8. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. # copies of the Software, and to permit persons to whom the Software is
  10. # furnished to do so, subject to the following conditions:
  11. #
  12. # The above copyright notice and this permission notice shall be included in
  13. # all copies or substantial portions of the Software.
  14. #
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. # THE SOFTWARE.
  22.  
  23. video_url=$(zenity --entry --title "Watch YouTube Video" --text="Type in the video URL")
  24. video_resolution=$(zenity --list --title "Video quality" --text="Pick the video quality" --column "Video quality" "1080p" "720p" "480p" "360p" "240p")
  25.  
  26. video_width=0
  27. video_height=0
  28.  
  29. if [ "1080p" == $video_resolution ] ; then
  30. video_width=1920
  31. video_height=1080
  32. elif [ "720p" == $video_resolution ] ; then
  33. video_width=1280
  34. video_height=720
  35. elif [ "480p" == $video_resolution ] ; then
  36. video_width=854
  37. video_height=480
  38. elif [ "360p" == $video_resolution ] ; then
  39. video_width=640
  40. video_height=360
  41. elif [ "240p" == $video_resolution ] ; then
  42. video_width=426
  43. video_height=240
  44. fi
  45.  
  46. exec mpv --ytdl-format="bestvideo[ext=mp4][width<=$video_width][height<=$video_height]+bestaudio[ext=m4a]/best[ext=mp4]/best" $video_url
Add Comment
Please, Sign In to add comment