Every time I run my code, it always shows an error that says:
my code:
from __future__ import unicode_literals
import youtube_dl
class MyLogger(object):
def debug(self, msg):
pass
def warning(self, msg):
pass
def error(self, msg):
print(msg)
def my_hook(d):
if d['status'] == 'finished':
print('Done downloading, now converting ...')
ydl_opts = {
'format': 'bestaudio/best',
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
'logger': MyLogger(),
'progress_hooks': [my_hook],
'quiet': True,
'writedescription': True,
'writethumbnail': True,
'progress_hooks': True,
'prefer_ffmpeg': True,
'ffmpeg_location': 'C:\FFMPEG',
'keepvideo': True,
'outtmpl': 'C:/Users/semif/Downloaders/%(uploader)s/%(title)s.%(ext)s'
}
with youtube_dl.YoutubeDL(ydl_opts) as Yami:
Yami.download([input('url: ')])
well, you have probably seen some of this because I copied most if not some of these codes here. I have Python 3.9.2
. Do I lack something? I tried searching for solutions but have not found any links that answered my problem.
I also want to download the file as mp4...any ideas on how can I do it? because in the code it only specified the mp3 version of the file.