TrashRat

Grabbit! YT downloader

Feb 19th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.34 KB | None | 0 0
  1. """
  2. A youtube downloader/ripper that uses youtube-dl.exe and ffmpeg.exe to convert and download video.
  3. I know there's a youtube-dl python module and i don't have to pipe it to the terminal using subprocess,
  4. but this is easier and i figured this one out first!
  5. Hamfisted by your humble and gracious overlord, REED 2/19/19
  6. """
  7.  
  8. from subprocess import call
  9. import colorama
  10. from colorama import Fore, Back, Style
  11. colorama.init()
  12. commands = ["1","2","3","4","5"]
  13. var = True
  14.  
  15. print(Style.BRIGHT + Fore.RED + """ _____              _      _      _  _    _
  16. |  __ \           | |    | |    (_)| |  | |
  17. | |  \/ _ __  __ _ | |__  | |__   _ | |_ | |   //
  18. | | __ | '__|/ _` || '_ \ | '_ \ | || __|| |  ('>
  19. | |_\ \| |  | (_| || |_) || |_) || || |_ |_|  /rr
  20. \____/|_|   \__,_||_.__/ |_.__/ |_| \__|(_) *\))_
  21. """+ Style.RESET_ALL)
  22.  
  23.  
  24. while var == True:
  25.    
  26.     print(Style.BRIGHT + Fore.YELLOW +"""1. Download Video(.mp4)
  27. 2. Download Song(.mp3)
  28. 3. Download video playlist
  29. 4. Download music playlist
  30. 5. Help/Troubleshooting
  31. 6. Quit"""+ Style.RESET_ALL)
  32.  
  33.    
  34.     print(Style.BRIGHT + Fore.RED + "Select Number"+ Style.RESET_ALL)
  35.     command = input("")
  36.  
  37.    
  38.     if command == "1":
  39.         print(Style.BRIGHT + Fore.RED + "Input Video URL" + Style.RESET_ALL)
  40.         link = input("")
  41.         call(["youtube-dl","--retries","15","--format", "bestvideo+bestaudio[ext=m4a]/bestvideo+bestaudio/best","--merge-output-format", "mp4","-o","%(title)s.%(ext)s", link], shell=True)
  42.  
  43.     if command == "2":
  44.         print(Style.BRIGHT + Fore.RED + "Input Song URL" + Style.RESET_ALL)
  45.         link = input("")
  46.         call(["youtube-dl","--retries", "15", "--extract-audio","--audio-format", "mp3", "-o", "%(title)s.%(ext)s", link], shell=True)
  47.        
  48.     if command == "3":
  49.         print(Style.BRIGHT + Fore.RED + "Video playlist URL MUST contain" + Style.RESET_ALL + Style.BRIGHT + Fore.GREEN + " playlist?list=" + Style.RESET_ALL + Style.BRIGHT + Fore.RED +" to work properly" + Style.RESET_ALL)        
  50.         link = input("")
  51.         call(["youtube-dl","--retries","15","--format", "bestvideo+bestaudio[ext=m4a]/bestvideo+bestaudio/best","--merge-output-format", "mp4","-o","%(playlist_index)s-%(title)s.%(ext)s", link], shell=True)
  52.        
  53.     if command == "4":
  54.         print(Style.BRIGHT + Fore.RED + "Music playlist URL MUST contain" + Style.RESET_ALL + Style.BRIGHT + Fore.GREEN + " playlist?list=" + Style.RESET_ALL + Style.BRIGHT + Fore.RED +" to work properly" + Style.RESET_ALL)        
  55.         link = input("")
  56.         call(["youtube-dl","--retries", "15", "--extract-audio","--audio-format", "mp3", "-o", "%(playlist_index)s-%(title)s.%(ext)s", link], shell=True)
  57.        
  58.     if command == "5":
  59.         responses = ["1","2"]
  60.         print(Style.BRIGHT + Fore.YELLOW + """1. Cant copy/paste into the console
  61. 2. First video/song in playlist is the only thing downloaded""")
  62.         print(Style.BRIGHT + Fore.RED + "Select Number"+ Style.RESET_ALL)
  63.        
  64.         question = input("")
  65.         if question == "1":
  66.             print(Style.BRIGHT + Fore.CYAN + "Right-click console --> properties --> Under 'edit options', enable QuickEdit mode,\n Insert mode, and Enable Ctrl key shortcuts. If ctrl+v doesnt work, try right-clicking\n"+ Style.RESET_ALL)
  67.             pass
  68.         if question == "2":
  69.             print(Style.BRIGHT + Fore.CYAN + "You need to make sure the playlist URL contains 'playlist?list=', you can get to this by clicking 'view full playlist' \nin search results, or on the playlist name.")
  70.             print(Style.BRIGHT + Fore.CYAN + "GOOD URL: https://www.youtube.com/"+ Style.RESET_ALL+ Style.BRIGHT + Fore.GREEN +"playlist?list="+ Style.RESET_ALL + Style.BRIGHT + Fore.CYAN+"OLAK5uy_nVfY4cK802ME288AZBdeveHZZ6kJRwPdU")
  71.             print(Style.BRIGHT + Fore.CYAN + "BAD URL: https://www.youtube.com/"+ Style.RESET_ALL + Style.BRIGHT + Fore.RED +"watch?v="+ Style.RESET_ALL + Style.BRIGHT + Fore.CYAN +"85QQlGuKGwo&list=OLAK5uy_nVfY4cK802ME288AZBdeveHZZ6kJRwPdU&index=1\n"+ Style.RESET_ALL)
  72.             pass
  73.         if question not in responses:
  74.             print(Style.BRIGHT + Fore.RED + "invalid response, returning to options selection.." + Style.RESET_ALL)
  75.             pass
  76.        
  77.     if command == "6":
  78.         quit()
  79.    
  80.     if command not in commands:
  81.         print(Style.BRIGHT + Fore.RED + '"%s"'%command + " is not an option..." )
Add Comment
Please, Sign In to add comment