解析m3u8文件进行视频文件的异步下载
$ python -m pip install aiom3u8
# 镜像加速
$ python -m pip install aiom3u8 -i https://pypi.tuna.tsinghua.edu.cn/simple
import aiom3u8
aiom3u8.download("https://demo.com/demo/demo.m3u8", "C:\\video_path", "video_name") # 使用默认参数
params = {...}
cookies = {...}
headers = {...}
aiom3u8.download("https://demo.com/demo/demo.m3u8", "C:\\video_path", "video_name", # 使用调节参数
video_name_extension=".mp4", params=params, cookies=cookies, headers=headers, proxy="http://127.0.0.1:10809/"
auto_highest_bandwidth=True, progress_bar_display=True, async_tasks_maintain=20, inspect_interval=3.,
failure_retries=5)
OR
import asyncio
import aiom3u8
async def main():
await aiom3u8.download_coro(arguments...)
asyncio.run(main())
video_name_extension
: str - 生成视频类型params、cookies、headers
: dict - 请求时附带参数proxy
: str - 自身使用的代理地址auto_highest_bandwidth
: bool - 有多个适配流时是否自动选择最高画质progress_bar_display
: bool - 是否显示下载进度条async_tasks_maintain
: int - 同时下载的异步任务数inspect_interval
: float - 添加新异步任务的检查间隔时间failure_retries
: int - 允许单个文件的下载连接失败次数
Using async way to download a video file by parsing m3u8 file
$ python -m pip install aiom3u8
# Using a mirror
$ python -m pip install aiom3u8 -i https://pypi.tuna.tsinghua.edu.cn/simple
import aiom3u8
aiom3u8.download("https://demo.com/demo/demo.m3u8", "C:\\video_path", "video_name") # Using default arguments
params = {...}
cookies = {...}
headers = {...}
aiom3u8.download("https://demo.com/demo/demo.m3u8", "C:\\video_path", "video_name", # Using adjustment arguments
video_name_extension=".mp4", params=params, cookies=cookies, headers=headers, proxy="http://127.0.0.1:10809/"
auto_highest_bandwidth=True, progress_bar_display=True, async_tasks_maintain=20, inspect_interval=3.,
failure_retries=5)
OR
import asyncio
import aiom3u8
async def main():
await aiom3u8.download_coro(arguments...)
asyncio.run(main())
video_name_extension
: str - generated video typeparams、cookies、headers
: dict - request with parametersproxy
: str - used proxy addressauto_highest_bandwidth
: bool - whether to automatically select the highest quality when there are multiple adaptation streamsprogress_bar_display
: bool - whether to show the download progress barasync_tasks_maintain
: int - number of asynchronous tasks running concurrentlyinspect_interval
: float - checking interval for adding new async tasksfailure_retries
: int - number of download connection failures allowed for a single file