V
V
Valery Zhmyshenko2020-06-12 11:13:23
Python
Valery Zhmyshenko, 2020-06-12 11:13:23

How to download video from VK Python?

Hello! I have a question: how to download a video from VK? Tried with the requests library here is the code:

import requests

req = requests.get('https://vk.com/video-30316056_456326877')

with open('video.mp4', 'wb') as video:
    video.write(req.content)

but it turned out that,
5ee338ec56d14681299310.png
moreover, this goodness came in mp4 format
Help please!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Nevzorov, 2020-06-12
@mcborrrov

Use the youtube_dl library

import youtube_dl

ydl_opts = {}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
     ydl.download(['https://vk.com/video-30316056_456326877'])

# [vk] -30316056_456326877: Downloading JSON metadata                      
# [vk] -30316056_456326877: Downloading m3u8 information                   
# [hlsnative] Downloading m3u8 manifest                                    
# [hlsnative] Total fragments: 2                                           
# [download] Destination: webm--30316056_456326877.mp4                     
# [download] 100% of 7.31MiB in 00:01                                      
# [ffmpeg] Fixing malformed AAC bitstream in "webm--30316056_456326877.mp4"
# 0

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question