python youtube dl custom path

Solutions on MaxInterview for python youtube dl custom path by the best coders in the world

showing results for - "python youtube dl custom path"
Cash
03 Feb 2016
1import os
2
3def download_audio(request):
4    SAVE_PATH = '/'.join(os.getcwd().split('/')[:3]) + '/Downloads'
5
6    ydl_opts = {
7        'format': 'bestaudio/best',
8        'postprocessors': [{
9            'key': 'FFmpegExtractAudio',
10            'preferredcodec': 'mp3',
11            'preferredquality': '192',
12        }],
13        'outtmpl':SAVE_PATH + '/%(title)s.%(ext)s',
14    }
15
16    link = request.GET.get('video_url')
17
18    with youtube_dl.YoutubeDL(ydl_opts) as ydl:
19        ydl.download(["https://www.youtube.com/watch?v="+link])
20
similar questions
queries leading to this page
python youtube dl custom path