0

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.

H2WO
  • 31
  • 7
  • the link you posted said don't name your file youtube_dl.py – qwr May 03 '21 at 10:28
  • i change my file name to ytd.py and it showed ```TypeError: 'bool' object is not iterable``` – H2WO May 03 '21 at 10:31
  • Does this answer your question? [youtube\_dl giving AttributeError (python)](https://stackoverflow.com/questions/47842104/youtube-dl-giving-attributeerror-python) – qwr May 03 '21 at 10:32
  • it did remove the attribute error but it showed me a new error: `TypeError: 'bool' object is not iterable` – H2WO May 03 '21 at 10:34

0 Answers0