Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # code
- import youtube_dl
- vlink = input("Please enter a link: ")
- selectedformat = input("Download Audio or Video? (A/V): ")
- if selectedformat == "A" or selectedformat == "a":
- ydl_opts = { # a dictionary which contains the settings for downloading
- 'format': 'bestaudio/best',
- 'postprocessors': [{
- 'key': 'FFmpegExtractAudio',
- 'preferredcodec': 'mp3',
- 'preferredquality': '192',
- }]
- }
- with youtube_dl.YoutubeDL(ydl_opts) as ydl:
- ydl.download([vlink])
- print('Download successful!')
- else:
- ydl_opts = {
- 'format': 'bestvideo/best',
- }
- with youtube_dl.YoutubeDL(ydl_opts) as ydl:
- ydl.download([vlink])
- print('Download successful!')
- # error
- 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