Skip to main content

Bilibili_up 使用方法


如果程序错了(特别是av号的操作和ip),请报告给534047068@qq.com。

关于 BV 号视频的操作

导入BV操作(av号也一样)
获取BV视频评论区(字典)

from bilibili_up import BV # BV 号
from bilibili_up import AV # av 号
#获取BV视频评论区(字典)
comments = BV_get_comments(BV=123456789, 
           PageNumber=5, 
           headers={"User-Agent": "Mozilla/5.0"})
for username, content in comments.items():
    print(f"{username}: {content}")

其中,BV、PageNumber是必选参数,其他为可选参数。
PageNumber:页数(1~PageNumber)
BV:视频BV号
headers(可选):自定义请求头
ip(可选):自定义ip
返回值是一个字典{username:content}

自定义ip选项加上了

获取视频信息

video_info = BV_get_File("BVxxxxxxxx", headers={"User-Agent": "Mozilla/5.0"})
print(video_info)

该函数会返回一个字典,包含视频的播放量、发布时间、作者信息和弹幕数量。
源代码的一部分:

return {
                "播放量": play_count,
                "发布时间": publish_time,
                "作者": {
                    "名称": author_name,
                    "UID": author_uid
                },
                "弹幕数量": danmaku_count,
                "bvid": video_data['bvid'],  # 视频BV号
                # av号是"avid"
                "援助": video_data['aid'],  # 视频援助号
                "视频tid": video_data['tid'],  # 视频tid
                "tname": video_data['tname'],  # 视频分类名
                "版权": video_data['rights'],  # 版权信息
                "封面图片": video_data['pic'],  # 封面图片链接
                "title": video_data['title']  # 视频标题
            }

想获得作者的uid就需要:

a = BV_get_File("BVxxxxxxxx")["作者"]["UID"]

其中,BV是必选参数,其他为可选参数。
BV:视频BV号
ip(可选):自定义ip
headers(可选):自定义请求头

获取BV视频弹幕(字典)

# 调用函数
BV_get_danmaku(bvid)
# 传入指定的 BV 号
bvid = 'BV**********'

# 调用函数获取弹幕数据
danmaku_data = BV_get_danmaku(bvid)

弹幕数据格式说明: danmaku_data 是一个字典,以弹幕的时间为键,弹幕内容为值:

{
    time_1: content_1,
    time_2: content_2,
    ...
}

请确保提供的 BV 号是有效的,对应的视频存在并且具有弹幕。


在0.2.1.1版本中,获取BV视频评论区中的BV参数是video_bv(已过时)


1.0.0.0 正式版本更新

支持选择ip
增加了BV_get_File函数的多个选项


1.1.0.0 正式版本更新

支持获取弹幕


1.2.0.0 正式版本修复

取消了不必要的错误


2.0.0.0 正式版本更新

增加了av号的操作!和BV号同步更新!

Release files for bilibili-up 2.0.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bilibili-up 2.0.0.0
File Size Uploaded
bilibili_up-2.0.0.0.tar.gz 4.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bilibili-up 2.0.0.0
File Interpreter ABI Platform
bilibili_up-2.0.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.8 kB

Release files / bilibili_up-2.0.0.0.tar.gz

Download URL bilibili_up-2.0.0.0.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
060a92f89dd093a7b1381f91674fe01c7a0ae2a571cdb3e3a9e39f83f992e9b3
BLAKE2b-256 checksum
How to use checksums
0b1618b11d40b6ae4f747019bdd30f5f4a41cdce5cf0adad0b8b8b2c6d3bfa21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.6

Release files / bilibili_up-2.0.0.0-py3-none-any.whl

Download URL bilibili_up-2.0.0.0-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c0dee528784eed5620bd41238af222154cd59c818832e09116e766328fda047b
BLAKE2b-256 checksum
How to use checksums
d96ba3e2c16cc8bdc30ab955b46de754c8bd3e318eb790239c40b08c67bced9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.6

Release history Release notifications | RSS feed

This release

2.0.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page