Django Youtube video download to client machine

Hi Friend I want to write python code to that video download to user machine. Now I send ajax request my view.py file and download video But my project videos file.

    def download_youtube_video(url):
    url="https://www.youtube.com/watch?v="+str(url)
    myVideo = YouTube(url)
    higest = myVideo.streams.get_highest_resolution().resolution
    if myVideo.streams.filter(res=higest).first().download('videos'):
        return True
    else:
        return False    

def ajax(request):
    if request.method == "GET":
        url=request.GET.get('url')
        if download(download_youtube_video(url)) == True:
            return JsonResponse(data = {"success":"Successs"})
        else:
            return JsonResponse(data = {"success":"Error"})
Back to Top