import requests, aiohttp, aiofiles, asyncio, os
async def get_second_url(old_url, new_url, headers):
r = requests.get(new_url, headers=headers)
data = r.text
with open("m38u.txt", "w", encoding="utf-8") as f:
f.write(data)
f.close()
task = []
i = 0
async with aiohttp.ClientSession() as session:
async with aiofiles.open("m38u.txt", "r", encoding="utf-8") as f:
async for item in f:
item = item.strip()
if item.startswith("#"):
continue
url = old_url.rsplit("/", 3)[0] + item
print(url)
task.append(asyncio.create_task(aiodownload(url, i, session, headers)))
i += 1
await asyncio.wait(task)
async def aiodownload(new_url, i, session, headers):
async with se
python异步下载云播视频
最新推荐文章于 2024-08-21 23:42:00 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)