Advertisement
raphtlw

Untitled

Oct 18th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. # code
  2.  
  3. import youtube_dl
  4.  
  5. vlink = input("Please enter a link: ")
  6.  
  7. selectedformat = input("Download Audio or Video? (A/V): ")
  8.  
  9.  
  10. if selectedformat == "A" or selectedformat == "a":
  11.  
  12.     ydl_opts = {  # a dictionary which contains the settings for downloading
  13.         'format': 'bestaudio/best',
  14.         'postprocessors': [{
  15.             'key': 'FFmpegExtractAudio',
  16.             'preferredcodec': 'mp3',
  17.             'preferredquality': '192',
  18.         }]
  19.     }
  20.  
  21.     with youtube_dl.YoutubeDL(ydl_opts) as ydl:
  22.         ydl.download([vlink])
  23.  
  24.     print('Download successful!')
  25.  
  26. else:
  27.  
  28.     ydl_opts = {
  29.         'format': 'bestvideo/best',
  30.         }
  31.  
  32.     with youtube_dl.YoutubeDL(ydl_opts) as ydl:
  33.         ydl.download([vlink])
  34.  
  35.     print('Download successful!')
  36.  
  37. # error
  38.  
  39. youtube_dl.utils.DownloadError: ERROR: ffprobe/avprobe and ffmpeg/avconv not found. Please install one.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement