Skip to main content

acfunSDK - UNOFFICEICAL

Project description

acfunSDK - UNOFFICEICAL



acfunSDK是 非官方的 AcFun弹幕视频网 Python库。

声明:acfunSDK是python的学习工具,并未破解任何acfun相关内容。代码完全公开,仅用于交流学习。 如涉及版权等相关问题,请遵守acfun相关协议及法律法规。如有bug或其他疑问,欢迎发布issues


Python : 开发环境为 Python 3.8.10, 本体请自行下载安装

从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列举了主要的使用方法,具体请自行研究。

👤 主要对象

📖 综合页面对象

🔗 内容页面对象

🎁 附赠: AcSaver

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

基础网络请求及页面解析:

下载及html页面渲染:

WebSocket通信及数据处理:

图形化命令行:


参考 & 鸣谢


About Me

ac彩娘-阿部高和 ♂ 整点大香蕉🍌 AcFunCard


Project details


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.11.tar.gz (168.6 kB view hashes)

Uploaded Source

Built Distribution

acfunsdk-0.8.11-py3-none-any.whl (499.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page