youtube-dl python get formats code example

Example 1: youtube-dl python download to specific folder

ydl_opts = {
    'format': 'bestaudio/best',
  	'outtmpl': 'e:/python/downloadedsongs/%(title)s.%(ext)s', # <--- pay attention here
    'download_archive': 'downloaded_songs.txt',
    'outtmpl': '%(title)s.%(ext)s',
    'postprocessors': [{
        'key': 'FFmpegExtractAudio',
        'preferredcodec': 'mp3',
        'preferredquality': '192',
        }],
    'logger': MyLogger(),
    'progress_hooks': [my_hook],

}

Example 2: from __future__ import unicode_literals import youtube_dl ydl_opts = {} with youtube_dl.YoutubeDL(ydl_opts) as ydl: ydl.download(['VideoURL'])

from __future__ import unicode_literals
import youtube_dl

ydl_opts = {}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
    ydl.download(['https://ojogoaberto.club.hotmart.com/lesson/PeA5JdJ8eW/apresentacao'])