python youtube dl extract info

Solutions on MaxInterview for python youtube dl extract info by the best coders in the world

showing results for - "python youtube dl extract info"
Jan
21 Sep 2016
1def download_clip(url, name):
2    ydl_opts = {
3        'format': 'bestaudio/best',
4        'outtmpl': dir_utils.get_perm_med_dir() + f'/sound_board/{name}.wav',
5        'noplaylist': True,
6        'continue_dl': True,
7        'postprocessors': [{
8            'key': 'FFmpegExtractAudio',
9            'preferredcodec': 'wav',
10            'preferredquality': '192', }]
11    }
12    try:
13        with youtube_dl.YoutubeDL(ydl_opts) as ydl:
14            ydl.cache.remove()
15            info_dict = ydl.extract_info(url, download=False)
16            ydl.prepare_filename(info_dict)
17            ydl.download([url])
18            return True
19    except Exception:
20        return False