acfunSDK - UNOFFICEICAL
Project description
acfunSDK - UNOFFICEICAL
acfunSDK是 非官方的 AcFun弹幕视频网 Python库。
几乎搜集了所有与 AcFun弹幕视频网 相关的接口与数据。
ps: 如发现未知接口,或现有功能失效,请随时提交 Issue
Python : 开发环境为 Python 3.8.10
& Python 3.9.6
Python
本体请自行下载安装。
从PyPI安装
python -m pip install acfunsdk
需要ffmpeg
主要用于下载视频。
建议去官网下载 https://ffmpeg.org/download.html
可执行文件
ffmpeg
需要加入到环境变量,或复制到运行根目录。
使用方法
实例化获取对象
from acfunsdk import Acer
# 实例化一个Acer
acer = Acer(debug=True)
# 登录用户(成功登录后会自动保存 '<用户名>.cookies')
# 请注意保存,防止被盗
acer.login(username='you@email.com', password='balalabalala')
# 读取用户(读取成功登录后保存的 '<用户名>.cookies')
acer.loading(username='13800138000')
# 每日签到,领香蕉🍌
acer.signin()
# 通过链接直接获取内容对象
# 目前支持 9种类型:
# 视 频: https://www.acfun.cn/v/ac4741185
demo_video = acer.get("https://www.acfun.cn/v/ac4741185")
print(demo_video)
# 文 章: https://www.acfun.cn/a/ac16695813
demo_article = acer.get("https://www.acfun.cn/a/ac16695813")
print(demo_article)
# 合 集: https://www.acfun.cn/a/aa6001205
demo_album = acer.get("https://www.acfun.cn/a/aa6001205")
print(demo_album)
# 番 剧: https://www.acfun.cn/bangumi/aa5023295
demo_bangumi = acer.get("https://www.acfun.cn/bangumi/aa5023295")
print(demo_bangumi)
# 个人页: https://www.acfun.cn/u/39088
demo_up = acer.get("https://www.acfun.cn/u/39088")
print(demo_up)
# 动 态: https://www.acfun.cn/moment/am2797962
demo_moment = acer.get("https://www.acfun.cn/moment/am2797962")
print(demo_moment)
# 直 播: https://live.acfun.cn/live/378269
demo_live = acer.get("https://live.acfun.cn/live/378269")
print(demo_live)
# 分 享: https://m.acfun.cn/v/?ac=37086357
demo_share = acer.get("https://m.acfun.cn/v/?ac=37086357")
print(demo_share)
DEMOs
以下DEMO列举了主要的使用方法,具体请自行研究。
👤 主要对象
- 主对象acer示例 acer_demo.py
📖 综合页面对象
- 首页对象示例 index_reader.py
- 频道对象示例 channel_reader.py
- 搜索对象示例 search_reader.py
🔗 内容页面对象
- 番剧对象 bangumi_demo.py
- 视频对象 video_demo.py
- 文章对象 article_demo.py
- 合集对象 album_demo.py
- UP主对象 member_demo.py
- 动态对象 moment_demo.py
- 直播对象 live_demo.py
🎁 附赠: AcSaver
- 离线保存 AcSaver_demo.py
AcSaver
这是一个依赖acfunSDK的小工具,也算是DEMO。
主要用于离线收藏保存A站的各种资源。 保存后,可使用浏览器打开对应页面。
初始化本地路径
saver_path = r"D:\AcSaver"
# 实例化AcSaver父类
acsaver = acer.AcSaver(saver_path)
# 实例化后 会在路径下生成 index.html
# github下载静态文件
# https://github.com/dolaCmeo/acfunSDK/tree/assets
acsaver.download_assets_from_github()
# 下载所有Ac表情资源
acsaver.save_emot()
保存文章
demo_article = acer.get("https://www.acfun.cn/a/ac32633020")
demo_article.saver(saver_path).save_all()
保存视频
demo_video = acer.get("https://www.acfun.cn/v/ac4741185")
demo_video.saver(saver_path).save_all()
保存番剧(暂未支持)
录制直播(暂未支持)
依赖库
内置+修改: 位于
libs
文件夹内
依赖: 包含在 requirements.txt
中
基础网络请求及页面解析:
httpx
>=0.23
lxml
>=4.9
beautifulsoup4
>=4.11
cssutils
>=2.6
下载及html页面渲染:
alive-progress
>=2.4
filetype
>=1.1
jinja2
>=3.1
WebSocket通信及数据处理:
websocket-client
>=1.4
pycryptodome
>=3.15
protobuf
==3.20.1
proto-plus
==1.22.1
rich
>=12.5
psutil
>=5.9
图形化命令行:
参考 & 鸣谢
- AcFun 助手 是一个适用于 AcFun( acfun.cn ) 的浏览器插件。
- AcFunDanmaku 是用C# 和 .Net 6编写的AcFun直播弹幕工具。
- 实现自己的AcFun直播弹幕姬 @財布士醬
- QQ频道“AcFun开源⑨课”
- 使用 Poetry 构建
About Me
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
acfunSDK-0.8.10.tar.gz
(166.1 kB
view hashes)
Built Distribution
acfunsdk-0.8.10-py3-none-any.whl
(491.0 kB
view hashes)
Close
Hashes for acfunsdk-0.8.10-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d50dca537e4be29d43f4c57ebcc0525727697b241ddac71fac936ebc8b6da2c9 |
|
MD5 | 2edfa909cf395574bc0a09904885abf1 |
|
BLAKE2b-256 | 170169874fd9a343dcf5bad6c05ee410c26c13627d29ff369c9ac8805045f8dc |