I try all of types like 720 480.But only 1080p not work.Who can help me.
I user python.Only 1080p can’t download.
Here is my code.
async def save_video(url):
try:
chunk_size = 20 * 2 ** 20 # MB
file_name = f"media/{shortuuid.uuid()}.mp4"
f = open(file_name, ‘wb’)
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
data_to_read = True
while data_to_read:
data = bytearray()
red = 0
while red < chunk_size:
chunk = await response.content.read(chunk_size - red)
if not chunk:
data_to_read = False
break
data.extend(chunk)
red += len(chunk)
f.write(data)
f.close()
return file_name
except:
return None
Присоединяйтесь к обсуждению – добавьте комментарий ниже: