Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm working on a Python(3.6) & Django(2) project in which I need to download a video from a URL. Here's what I have tried:

from views.py:

    if validation is True:
        url = request.POST.get('video_url')
        r = requests.get(url, allow_redirects=True)
        file = open('my_video.mp4', 'wb').write(r.content)
        rea_response = HttpResponse(file, content_type='video/mp4')
        rea_response['Content-Disposition'] = 'attachment; filename=my_video.mp4'
        return rea_response

The URL from where it's downloading the vide is:

https://expirebox.com/files/386713962c5f8b7556bc77c4a6c2a576.mp4

It downloads a file with the name as my_video.mp4 but when I try to open this video it's not playing.

What can be wrong here with my code? OR is there any better way to download the video from URL.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
185 views
Welcome To Ask or Share your Answers For Others

1 Answer

Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...