bilibili-api
bilibili-api copied to clipboard
[提问] 关于赠送付费礼物的问题
Python 版本: 3.9
模块版本: 16.0.0
运行环境: Windows
尝试送个小花花,结果提示该礼物仅限从包裹中送出哦 代码如下
gift_config = await live.get_gift_config()
for gift in gift_config['list']:
if gift['name'] == "牛哇牛哇":
res = await self.liveRoom.send_gift_from_bag(uid=self.uid, gift_id=gift['id'],
gift_num=1,
price=gift['price'])
print(res)
break
返回结果如下:
bilibili_api.exceptions.ResponseCodeException.ResponseCodeException: 接口返回错误代码:200010,信息:该礼物仅限从包裹中送出哦~。 {'code': 200010, 'message': '该礼物仅限从包裹中送出哦~', 'ttl': 1, 'data': None}
额 代码中牛哇牛哇是为了测试其他礼物是否可以送出
我不能理解,你 bag_id 呢,这参是必要参数你怎么运行的?
是不是老版本,傻了
https://github.com/Nemo2011/bilibili-api/blob/5ad63105643a6cc5124ff2ffebf5598d22e50952/bilibili_api/live.py#L509-L517
我不能理解,你
bag_id呢,这参是必要参数你怎么运行的?是不是老版本,傻了
https://github.com/Nemo2011/bilibili-api/blob/5ad63105643a6cc5124ff2ffebf5598d22e50952/bilibili_api/live.py#L509-L517
不好意思,错帖了自己胡乱尝试的代码。
调用的是send_gift_gold方法,然后出现的上述错误
gift_config = await live.get_gift_config()
for gift in gift_config['list']:
if gift['name'] == "牛哇牛哇":
res = await self.liveRoom.send_gift_gold(uid=self.uid, gift_id=gift['id'],
gift_num=1,
price=gift['price'])
print(res)
break
虽然知道了,但是我没法测试,因为没礼物可送...
虽然知道了,但是我没法测试,因为没礼物可送...
这就去赞助!
好像是送礼物的接口不一样了。
会是这个接口吗。。参数很像。。不过看着总觉得是获取信息的接口
但也没看到什么其他的post的接口
首先这里不接受赞助,其次只能 @Drelf2018 看看了
api
https://api.live.bilibili.com/xlive/revenue/v2/gift/sendBag
form
uid: xxx
gift_id: xxx
ruid: xxx
send_ruid: 0
gift_num: 1
bag_id: xxx
platform: pc
biz_code: Live
biz_id: xxx
storm_beat_id: 0
metadata:
price: 0
live_statistics: {"pc_client":"pcWeb","jumpfrom":"82001","room_category":"0","official_channel":{"program_room_id":"-99998","program_up_id":"-99998"}}
statistics: {"platform":0,"pc_client":"pcWeb"}
csrf_token: xxx
csrf: xxx
visit_id: xxx
api
https://api.live.bilibili.com/xlive/revenue/v2/gift/sendBagform
uid: xxx gift_id: xxx ruid: xxx send_ruid: 0 gift_num: 1 bag_id: xxx platform: pc biz_code: Live biz_id: xxx storm_beat_id: 0 metadata: price: 0 live_statistics: {"pc_client":"pcWeb","jumpfrom":"82001","room_category":"0","official_channel":{"program_room_id":"-99998","program_up_id":"-99998"}} statistics: {"platform":0,"pc_client":"pcWeb"} csrf_token: xxx csrf: xxx visit_id: xxx
感谢大佬费心
但是这个接口好像是赠送包裹里的礼物吧。。。
现在想消费电池赠送礼物 可是不知道为啥赠送礼物的时候没看到有请求:(
我没在B站送过,不清楚
电池礼物用sendGold
应该是 live.send_gift_gold
电池礼物用sendGold
应该是 live.send_gift_gold
是的大佬。我调用了live.send_gift_gold。但是返回了错误信息 提示{'code': 200010, 'message': '该礼物仅限从包裹中送出哦~', 'ttl': 1, 'data': None}
代码如下
gift_config = await live.get_gift_config()
bag_info = await live.get_self_bag(credential=self.credential)
print(bag_info)
for gift in gift_config['list']:
if gift['name'] == "牛哇牛哇":
res = await self.liveRoom.send_gift_gold(uid=self.uid, gift_num=1, price=gift["price"], gift_id=gift['id'])
print(res)
break
同问,能正常获取礼物的id和price,但送出的时候返回
bilibili_api.exceptions.ResponseCodeException.ResponseCodeException: 接口返回错误代码:200010,信息:该礼物仅限从包裹中送出哦~。
{'code': 200010, 'message': '该礼物仅限从包裹中送出哦~', 'ttl': 1, 'data': None}
以下是我的代码,gift_name是小花花:
# 获取礼物列表
gift_config = await live.get_gift_config()
# 查找指定的礼物
for gift in gift_config['list']:
if gift['name'] == gift_name:
res = await roomLiveRoom.send_gift_gold(uid=int(danmu_config.uid), gift_id=gift['id'], gift_num=1, price=gift['price'])
print(res)
break
else:
print(f'礼物 {gift_name} 不存在')
danmu_config
注意,B站是不允许用户自己给自己的直播间赠送礼物的,请调用接口时传入非本人的直播间房间号
运行代码
def test(credential):
gift_config = sync(live.get_gift_config())
for gift in gift_config['list']:
if gift['name'] == "牛哇牛哇":
logger.info(gift)
room = live.LiveRoom(room_display_id=22754458, credential=credential)
res = sync(room.send_gift_gold(uid=credential.dedeuserid, gift_num=1, price=gift["price"], gift_id=gift['id']))
logger.info(res)
break
运行日志(非完整)
2023-10-16 10:20:24.112 | INFO | __main__:login_main:20 - 已登录用户:洛零一
[Request][2023-10-16 10:20:24,112] Api(url='https://api.live.bilibili.com/xlive/web-room/v1/giftPanel/giftConfig', method='GET', comment='获取所有礼物信息,三个字段可以不用填,但填了有助于减小返回内容的大小,置空返回约 2.7w 行,填了三个对应值返回约 1.4w 行', wbi=False, verify=False, no_csrf=False, json_body=False, ignore_code=False, data={}, params={'platform': 'pc', 'source': 'live', 'room_id': '', 'area_id': '', 'area_parent_id': ''}, files={}, headers={}, credential=<bilibili_api.utils.credential.Credential object>)
2023-10-16 10:20:24.445 | INFO | __main__:test:28 - {'id': 31039, 'name': '牛哇牛哇', 'price': 100, 'type': 0, 'coin_type': 'gold', 'bag_gift': 0, 'effect': 0, 'corner_mark': ''}
[Request][2023-10-16 10:20:24,445] Api(url='https://api.live.bilibili.com/xlive/web-room/v1/index/getRoomPlayInfo', method='GET', comment='获取房间信息(真实房间号,封禁情况等)', wbi=False, verify=False, no_csrf=False, json_body=False, ignore_code=False, data={}, params={'room_id': 22754458}, files={}, headers={}, credential=<bilibili_api.credential.Credential object>)
[Request][2023-10-16 10:20:24,545] Api(url='https://api.live.bilibili.com/xlive/revenue/v1/gift/sendGold', method='POST', comment='在直播间中赠送金瓜子礼物', wbi=False, verify=True, no_csrf=False, json_body=False, ignore_code=False, data={'uid': '97164600', 'gift_id': 31039, 'gift_num': 1, 'price': 100, 'ruid': 1875094289, 'biz_code': 'live', 'biz_id': 22754458, 'platform': 'pc', 'storm_beat_id': 0, 'send_ruid': 0, 'coin_type': 'gold', 'bag_id': '0', 'rnd': 1, 'visit_id': ''}, params={'uid': '', 'gift_id': '', 'ruid': '', 'send_ruid': '', 'gift_num': '', 'coin_type': '', 'bag_id': '', 'platform': '', 'biz_code': '', 'biz_id': '', 'rnd': '', 'storm_beat_id': '', 'price': '', 'visit_id': '', 'csrf,csrf_token': ''}, files={}, headers={}, credential=<bilibili_api.credential.Credential object>)
2023-10-16 10:20:24.779 | INFO | __main__:test:31 - {'uid': 97164600, 'uname': '洛零一', 'face': 'https://i0.hdslb.com/bfs/face/6e3b51618f03c34212f3bf6dcb62c79237bc0e15.jpg', 'guard_level': 2, 'ruid': 1875094289, 'room_id': 22754458, 'rcost': 49240880, 'total_coin': 100, 'pay_coin': 100, 'blow_switch': 1, 'send_tips': '', 'discount_id': 0, 'send_master': None, 'button_combo_type': 1, 'send_gift_countdown': 5, 'blind_gift': None, 'fulltext': '', 'crit_prob': -1, 'price': 100, 'left_num': 0, 'need_num': 0, 'available_num': 0, 'bp_cent_balance': 0, 'gift_list': [{'tid': 'XXXX', 'gift_id': 31039, 'gift_type': 0, 'gift_name': '牛哇牛哇', 'gift_num': 1, 'gift_action': '投喂', 'gift_price': 100, 'coin_type': 'gold', 'tag_image': '', 'effect_block': 0, 'extra': {'wallet': {'gold': 900, 'silver': 322, 'pay_coin': 100, 'wallet_tid': 'XXXX', 'order_id': 'XXXX', 'goods_id': 15}, 'gift_bag': None, 'pk': {'pk_gift_tips': ''}, 'lottery_id': '', 'medal': {'new': 0, 'medal_id': 0, 'medal_name': '', 'level': 0}}, 'gift_effect': {'combo_timeout': 5, 'super_gift_num': 1, 'super_batch_gift_num': 1, 'batch_combo_id': 'XXXX', 'combo_id': 'XXXX'}, 'is_special_batch': 0, 'combo_stay_time': 5, 'combo_total_coin': 100, 'demarcation': 1, 'magnification': 1, 'combo_resources_id': 1, 'float_sc_resource_id': 0, 'is_naming': False, 'receive_user_info': {'uname': '小铃久绘Official', 'uid': 1875094289}, 'is_join_receiver': False}], 'send_id': 'XXXX'}
测试成功送出
相同代码但使用我本人直播间,成功触发该异常
原来如此
原来如此
并不是如此!!!怎么给sovled了!! 我测试依然存在这样的报错啊,我并没有在自己的直播间测试。报错依然存在,但是礼物也没有被送出
danmu_config
注意,B站是不允许用户自己给自己的直播间赠送礼物的,请调用接口时传入非本人的直播间房间号
运行代码
def test(credential): gift_config = sync(live.get_gift_config()) for gift in gift_config['list']: if gift['name'] == "牛哇牛哇": logger.info(gift) room = live.LiveRoom(room_display_id=22754458, credential=credential) res = sync(room.send_gift_gold(uid=credential.dedeuserid, gift_num=1, price=gift["price"], gift_id=gift['id'])) logger.info(res) break运行日志(非完整)
2023-10-16 10:20:24.112 | INFO | __main__:login_main:20 - 已登录用户:洛零一 [Request][2023-10-16 10:20:24,112] Api(url='https://api.live.bilibili.com/xlive/web-room/v1/giftPanel/giftConfig', method='GET', comment='获取所有礼物信息,三个字段可以不用填,但填了有助于减小返回内容的大小,置空返回约 2.7w 行,填了三个对应值返回约 1.4w 行', wbi=False, verify=False, no_csrf=False, json_body=False, ignore_code=False, data={}, params={'platform': 'pc', 'source': 'live', 'room_id': '', 'area_id': '', 'area_parent_id': ''}, files={}, headers={}, credential=<bilibili_api.utils.credential.Credential object>) 2023-10-16 10:20:24.445 | INFO | __main__:test:28 - {'id': 31039, 'name': '牛哇牛哇', 'price': 100, 'type': 0, 'coin_type': 'gold', 'bag_gift': 0, 'effect': 0, 'corner_mark': ''} [Request][2023-10-16 10:20:24,445] Api(url='https://api.live.bilibili.com/xlive/web-room/v1/index/getRoomPlayInfo', method='GET', comment='获取房间信息(真实房间号,封禁情况等)', wbi=False, verify=False, no_csrf=False, json_body=False, ignore_code=False, data={}, params={'room_id': 22754458}, files={}, headers={}, credential=<bilibili_api.credential.Credential object>) [Request][2023-10-16 10:20:24,545] Api(url='https://api.live.bilibili.com/xlive/revenue/v1/gift/sendGold', method='POST', comment='在直播间中赠送金瓜子礼物', wbi=False, verify=True, no_csrf=False, json_body=False, ignore_code=False, data={'uid': '97164600', 'gift_id': 31039, 'gift_num': 1, 'price': 100, 'ruid': 1875094289, 'biz_code': 'live', 'biz_id': 22754458, 'platform': 'pc', 'storm_beat_id': 0, 'send_ruid': 0, 'coin_type': 'gold', 'bag_id': '0', 'rnd': 1, 'visit_id': ''}, params={'uid': '', 'gift_id': '', 'ruid': '', 'send_ruid': '', 'gift_num': '', 'coin_type': '', 'bag_id': '', 'platform': '', 'biz_code': '', 'biz_id': '', 'rnd': '', 'storm_beat_id': '', 'price': '', 'visit_id': '', 'csrf,csrf_token': ''}, files={}, headers={}, credential=<bilibili_api.credential.Credential object>) 2023-10-16 10:20:24.779 | INFO | __main__:test:31 - {'uid': 97164600, 'uname': '洛零一', 'face': 'https://i0.hdslb.com/bfs/face/6e3b51618f03c34212f3bf6dcb62c79237bc0e15.jpg', 'guard_level': 2, 'ruid': 1875094289, 'room_id': 22754458, 'rcost': 49240880, 'total_coin': 100, 'pay_coin': 100, 'blow_switch': 1, 'send_tips': '', 'discount_id': 0, 'send_master': None, 'button_combo_type': 1, 'send_gift_countdown': 5, 'blind_gift': None, 'fulltext': '', 'crit_prob': -1, 'price': 100, 'left_num': 0, 'need_num': 0, 'available_num': 0, 'bp_cent_balance': 0, 'gift_list': [{'tid': 'XXXX', 'gift_id': 31039, 'gift_type': 0, 'gift_name': '牛哇牛哇', 'gift_num': 1, 'gift_action': '投喂', 'gift_price': 100, 'coin_type': 'gold', 'tag_image': '', 'effect_block': 0, 'extra': {'wallet': {'gold': 900, 'silver': 322, 'pay_coin': 100, 'wallet_tid': 'XXXX', 'order_id': 'XXXX', 'goods_id': 15}, 'gift_bag': None, 'pk': {'pk_gift_tips': ''}, 'lottery_id': '', 'medal': {'new': 0, 'medal_id': 0, 'medal_name': '', 'level': 0}}, 'gift_effect': {'combo_timeout': 5, 'super_gift_num': 1, 'super_batch_gift_num': 1, 'batch_combo_id': 'XXXX', 'combo_id': 'XXXX'}, 'is_special_batch': 0, 'combo_stay_time': 5, 'combo_total_coin': 100, 'demarcation': 1, 'magnification': 1, 'combo_resources_id': 1, 'float_sc_resource_id': 0, 'is_naming': False, 'receive_user_info': {'uname': '小铃久绘Official', 'uid': 1875094289}, 'is_join_receiver': False}], 'send_id': 'XXXX'}测试成功送出
相同代码但使用我本人直播间,成功触发该异常
你的包裹中有没有牛哇牛哇这个礼物呢?是消费电池送出的吗?我在包裹中没有这个礼物的时候就会触发这个报错,无论在哪个直播间。 另外b站是允许给自己送礼物的。只不过不允许送辣条这样银瓜子礼物。
你的包裹中有没有牛哇牛哇这个礼物呢?是消费电池送出的吗?我在包裹中没有这个礼物的时候就会触发这个报错,无论在哪个直播间。 另外b站是允许给自己送礼物的。只不过不允许送辣条这样银瓜子礼物。
关于: b站不允许给自己送礼物,包括包裹礼物和付费礼物,这是我现在测试的截图,~或者你如果能提供自己送自己的方法我倒真想试试,困扰好久了~
依赖: bilibili-api-python==16.1.1
def login_main():
credential = Credential(
sessdata='XXX',
bili_jct='XXX',
buvid3='XXX',
dedeuserid='XXX'
)
print("已登录用户:" + sync(user.get_self_info(credential))['name'], "!")
test(credential)
def test(credential):
gift_config = sync(live.get_gift_config(room_id=22754458, area_id=371, area_parent_id=9))
for gift in gift_config['list']:
if gift['name'] == "牛哇牛哇":
print(gift)
# room = live.LiveRoom(room_display_id=22754458, credential=credential)
# res = sync(room.send_gift_gold(uid=credential.dedeuserid, gift_num=1, price=gift["price"], gift_id=gift['id']))
# print(res)
if __name__ == '__main__':
settings.request_log = True
login_main()
首先要道歉前边没测试完全,再次测试发现发送失败还有一种情况,就是有些重名的隐藏礼物是无法送出的
见上文代码,运行后打印能查到有三个牛蛙牛蛙,而其中只有id=31039的才是能被送出的牛蛙牛蛙
2023-10-16 17:52:51.091 | INFO | __main__:test:29 - {'id': 31225, 'name': '牛哇牛哇', 'price': 100, 'type': 0, 'coin_type': 'gold', 'bag_gift': 1, 'effect': 0, 'corner_mark': '', 'corner_background': '', 'broadcast': 0, 'draw': 0, 'stay_time': 3, 'animation_frame_num': 24, 'desc': '是真的牛!!', 'rule': '', 'rights': '初夏之星决选赛奖池夺宝奖励', 'privilege_required': 0, 'count_map': [{'num': 1, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 10, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 100, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 520, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}], 'img_basic': 'https://s1.hdslb.com/bfs/live/91ac8e35dd93a7196325f1e2052356e71d135afb.png', 'img_dynamic': 'https://i0.hdslb.com/bfs/live/91ac8e35dd93a7196325f1e2052356e71d135afb.png', 'frame_animation': 'https://i0.hdslb.com/bfs/live/9e91883ebdfe6611809175495eeb7d7910721c27.png', 'gif': 'https://i0.hdslb.com/bfs/live/179f42946c1f268071800aca17f7743654af7177.gif', 'webp': 'https://i0.hdslb.com/bfs/live/7571c8bdfcb65f9b00ab1307b2c86630f0d00859.webp', 'full_sc_web': '', 'full_sc_horizontal': '', 'full_sc_vertical': '', 'full_sc_horizontal_svga': '', 'full_sc_vertical_svga': '', 'bullet_head': '', 'bullet_tail': '', 'limit_interval': 0, 'bind_ruid': 0, 'bind_roomid': 0, 'gift_type': 0, 'combo_resources_id': 0, 'max_send_limit': 0, 'weight': 0, 'goods_id': 15, 'has_imaged_gift': 0, 'left_corner_text': '', 'left_corner_background': '', 'gift_banner': None, 'diy_count_map': 1, 'effect_id': 0, 'first_tips': '', 'gift_attrs': [0], 'corner_mark_color': '', 'corner_color_bg': '', 'web_light': {'corner_mark': '', 'corner_background': '', 'corner_mark_color': '', 'corner_color_bg': ''}, 'web_dark': {'corner_mark': '', 'corner_background': '', 'corner_mark_color': '', 'corner_color_bg': ''}}
2023-10-16 17:52:51.091 | INFO | __main__:test:29 - {'id': 31039, 'name': '牛哇牛哇', 'price': 100, 'type': 0, 'coin_type': 'gold', 'bag_gift': 0, 'effect': 0, 'corner_mark': '', 'corner_background': '', 'broadcast': 0, 'draw': 0, 'stay_time': 3, 'animation_frame_num': 24, 'desc': '是真的牛!!', 'rule': '', 'rights': '', 'privilege_required': 0, 'count_map': [{'num': 1, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 10, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 100, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 520, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}], 'img_basic': 'https://s1.hdslb.com/bfs/live/91ac8e35dd93a7196325f1e2052356e71d135afb.png', 'img_dynamic': 'https://i0.hdslb.com/bfs/live/91ac8e35dd93a7196325f1e2052356e71d135afb.png', 'frame_animation': 'https://i0.hdslb.com/bfs/live/9e91883ebdfe6611809175495eeb7d7910721c27.png', 'gif': 'https://i0.hdslb.com/bfs/live/179f42946c1f268071800aca17f7743654af7177.gif', 'webp': 'https://i0.hdslb.com/bfs/live/7571c8bdfcb65f9b00ab1307b2c86630f0d00859.webp', 'full_sc_web': '', 'full_sc_horizontal': '', 'full_sc_vertical': '', 'full_sc_horizontal_svga': '', 'full_sc_vertical_svga': '', 'bullet_head': '', 'bullet_tail': '', 'limit_interval': 0, 'bind_ruid': 0, 'bind_roomid': 0, 'gift_type': 0, 'combo_resources_id': 0, 'max_send_limit': 5000, 'weight': 1, 'goods_id': 15, 'has_imaged_gift': 0, 'left_corner_text': '', 'left_corner_background': '', 'gift_banner': None, 'diy_count_map': 1, 'effect_id': 0, 'first_tips': '', 'gift_attrs': [0], 'corner_mark_color': '', 'corner_color_bg': '', 'web_light': {'corner_mark': '', 'corner_background': '', 'corner_mark_color': '', 'corner_color_bg': ''}, 'web_dark': {'corner_mark': '', 'corner_background': '', 'corner_mark_color': '', 'corner_color_bg': ''}}
2023-10-16 17:52:51.096 | INFO | __main__:test:29 - {'id': 31477, 'name': '牛哇牛哇', 'price': 100, 'type': 0, 'coin_type': 'gold', 'bag_gift': 1, 'effect': 0, 'corner_mark': '', 'corner_background': '', 'broadcast': 0, 'draw': 0, 'stay_time': 3, 'animation_frame_num': 24, 'desc': '是真的牛!!', 'rule': '', 'rights': '《全民连麦季》观众任务专属奖励,不计入心愿单统计', 'privilege_required': 0, 'count_map': [{'num': 1, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 10, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 100, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 520, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}], 'img_basic': 'https://s1.hdslb.com/bfs/live/91ac8e35dd93a7196325f1e2052356e71d135afb.png', 'img_dynamic': 'https://i0.hdslb.com/bfs/live/91ac8e35dd93a7196325f1e2052356e71d135afb.png', 'frame_animation': 'https://i0.hdslb.com/bfs/live/9e91883ebdfe6611809175495eeb7d7910721c27.png', 'gif': 'https://i0.hdslb.com/bfs/live/179f42946c1f268071800aca17f7743654af7177.gif', 'webp': 'https://i0.hdslb.com/bfs/live/7571c8bdfcb65f9b00ab1307b2c86630f0d00859.webp', 'full_sc_web': '', 'full_sc_horizontal': '', 'full_sc_vertical': '', 'full_sc_horizontal_svga': '', 'full_sc_vertical_svga': '', 'bullet_head': '', 'bullet_tail': '', 'limit_interval': 0, 'bind_ruid': 0, 'bind_roomid': 0, 'gift_type': 0, 'combo_resources_id': 0, 'max_send_limit': 0, 'weight': 0, 'goods_id': 15, 'has_imaged_gift': 0, 'left_corner_text': '', 'left_corner_background': '', 'gift_banner': None, 'diy_count_map': 1, 'effect_id': 0, 'first_tips': '', 'gift_attrs': [0], 'corner_mark_color': '', 'corner_color_bg': '', 'web_light': {'corner_mark': '', 'corner_background': '', 'corner_mark_color': '', 'corner_color_bg': ''}, 'web_dark': {'corner_mark': '', 'corner_background': '', 'corner_mark_color': '', 'corner_color_bg': ''}}
具体如何获取礼物判断是否能送出还没研究
围观中,坐等PR,完全没送过礼物.jpg @blyc
依赖:
bilibili-api-python==16.1.1def login_main(): credential = Credential( sessdata='XXX', bili_jct='XXX', buvid3='XXX', dedeuserid='XXX' ) print("已登录用户:" + sync(user.get_self_info(credential))['name'], "!") test(credential) def test(credential): gift_config = sync(live.get_gift_config(room_id=22754458, area_id=371, area_parent_id=9)) for gift in gift_config['list']: if gift['name'] == "牛哇牛哇": print(gift) # room = live.LiveRoom(room_display_id=22754458, credential=credential) # res = sync(room.send_gift_gold(uid=credential.dedeuserid, gift_num=1, price=gift["price"], gift_id=gift['id'])) # print(res) if __name__ == '__main__': settings.request_log = True login_main()首先要道歉前边没测试完全,再次测试发现发送失败还有一种情况,就是有些重名的隐藏礼物是无法送出的 见上文代码,运行后打印能查到有三个牛蛙牛蛙,而其中只有
id=31039的才是能被送出的牛蛙牛蛙2023-10-16 17:52:51.091 | INFO | __main__:test:29 - {'id': 31225, 'name': '牛哇牛哇', 'price': 100, 'type': 0, 'coin_type': 'gold', 'bag_gift': 1, 'effect': 0, 'corner_mark': '', 'corner_background': '', 'broadcast': 0, 'draw': 0, 'stay_time': 3, 'animation_frame_num': 24, 'desc': '是真的牛!!', 'rule': '', 'rights': '初夏之星决选赛奖池夺宝奖励', 'privilege_required': 0, 'count_map': [{'num': 1, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 10, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 100, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 520, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}], 'img_basic': 'https://s1.hdslb.com/bfs/live/91ac8e35dd93a7196325f1e2052356e71d135afb.png', 'img_dynamic': 'https://i0.hdslb.com/bfs/live/91ac8e35dd93a7196325f1e2052356e71d135afb.png', 'frame_animation': 'https://i0.hdslb.com/bfs/live/9e91883ebdfe6611809175495eeb7d7910721c27.png', 'gif': 'https://i0.hdslb.com/bfs/live/179f42946c1f268071800aca17f7743654af7177.gif', 'webp': 'https://i0.hdslb.com/bfs/live/7571c8bdfcb65f9b00ab1307b2c86630f0d00859.webp', 'full_sc_web': '', 'full_sc_horizontal': '', 'full_sc_vertical': '', 'full_sc_horizontal_svga': '', 'full_sc_vertical_svga': '', 'bullet_head': '', 'bullet_tail': '', 'limit_interval': 0, 'bind_ruid': 0, 'bind_roomid': 0, 'gift_type': 0, 'combo_resources_id': 0, 'max_send_limit': 0, 'weight': 0, 'goods_id': 15, 'has_imaged_gift': 0, 'left_corner_text': '', 'left_corner_background': '', 'gift_banner': None, 'diy_count_map': 1, 'effect_id': 0, 'first_tips': '', 'gift_attrs': [0], 'corner_mark_color': '', 'corner_color_bg': '', 'web_light': {'corner_mark': '', 'corner_background': '', 'corner_mark_color': '', 'corner_color_bg': ''}, 'web_dark': {'corner_mark': '', 'corner_background': '', 'corner_mark_color': '', 'corner_color_bg': ''}} 2023-10-16 17:52:51.091 | INFO | __main__:test:29 - {'id': 31039, 'name': '牛哇牛哇', 'price': 100, 'type': 0, 'coin_type': 'gold', 'bag_gift': 0, 'effect': 0, 'corner_mark': '', 'corner_background': '', 'broadcast': 0, 'draw': 0, 'stay_time': 3, 'animation_frame_num': 24, 'desc': '是真的牛!!', 'rule': '', 'rights': '', 'privilege_required': 0, 'count_map': [{'num': 1, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 10, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 100, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 520, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}], 'img_basic': 'https://s1.hdslb.com/bfs/live/91ac8e35dd93a7196325f1e2052356e71d135afb.png', 'img_dynamic': 'https://i0.hdslb.com/bfs/live/91ac8e35dd93a7196325f1e2052356e71d135afb.png', 'frame_animation': 'https://i0.hdslb.com/bfs/live/9e91883ebdfe6611809175495eeb7d7910721c27.png', 'gif': 'https://i0.hdslb.com/bfs/live/179f42946c1f268071800aca17f7743654af7177.gif', 'webp': 'https://i0.hdslb.com/bfs/live/7571c8bdfcb65f9b00ab1307b2c86630f0d00859.webp', 'full_sc_web': '', 'full_sc_horizontal': '', 'full_sc_vertical': '', 'full_sc_horizontal_svga': '', 'full_sc_vertical_svga': '', 'bullet_head': '', 'bullet_tail': '', 'limit_interval': 0, 'bind_ruid': 0, 'bind_roomid': 0, 'gift_type': 0, 'combo_resources_id': 0, 'max_send_limit': 5000, 'weight': 1, 'goods_id': 15, 'has_imaged_gift': 0, 'left_corner_text': '', 'left_corner_background': '', 'gift_banner': None, 'diy_count_map': 1, 'effect_id': 0, 'first_tips': '', 'gift_attrs': [0], 'corner_mark_color': '', 'corner_color_bg': '', 'web_light': {'corner_mark': '', 'corner_background': '', 'corner_mark_color': '', 'corner_color_bg': ''}, 'web_dark': {'corner_mark': '', 'corner_background': '', 'corner_mark_color': '', 'corner_color_bg': ''}} 2023-10-16 17:52:51.096 | INFO | __main__:test:29 - {'id': 31477, 'name': '牛哇牛哇', 'price': 100, 'type': 0, 'coin_type': 'gold', 'bag_gift': 1, 'effect': 0, 'corner_mark': '', 'corner_background': '', 'broadcast': 0, 'draw': 0, 'stay_time': 3, 'animation_frame_num': 24, 'desc': '是真的牛!!', 'rule': '', 'rights': '《全民连麦季》观众任务专属奖励,不计入心愿单统计', 'privilege_required': 0, 'count_map': [{'num': 1, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 10, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 100, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 520, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}], 'img_basic': 'https://s1.hdslb.com/bfs/live/91ac8e35dd93a7196325f1e2052356e71d135afb.png', 'img_dynamic': 'https://i0.hdslb.com/bfs/live/91ac8e35dd93a7196325f1e2052356e71d135afb.png', 'frame_animation': 'https://i0.hdslb.com/bfs/live/9e91883ebdfe6611809175495eeb7d7910721c27.png', 'gif': 'https://i0.hdslb.com/bfs/live/179f42946c1f268071800aca17f7743654af7177.gif', 'webp': 'https://i0.hdslb.com/bfs/live/7571c8bdfcb65f9b00ab1307b2c86630f0d00859.webp', 'full_sc_web': '', 'full_sc_horizontal': '', 'full_sc_vertical': '', 'full_sc_horizontal_svga': '', 'full_sc_vertical_svga': '', 'bullet_head': '', 'bullet_tail': '', 'limit_interval': 0, 'bind_ruid': 0, 'bind_roomid': 0, 'gift_type': 0, 'combo_resources_id': 0, 'max_send_limit': 0, 'weight': 0, 'goods_id': 15, 'has_imaged_gift': 0, 'left_corner_text': '', 'left_corner_background': '', 'gift_banner': None, 'diy_count_map': 1, 'effect_id': 0, 'first_tips': '', 'gift_attrs': [0], 'corner_mark_color': '', 'corner_color_bg': '', 'web_light': {'corner_mark': '', 'corner_background': '', 'corner_mark_color': '', 'corner_color_bg': ''}, 'web_dark': {'corner_mark': '', 'corner_background': '', 'corner_mark_color': '', 'corner_color_bg': ''}}具体如何获取礼物判断是否能送出还没研究
刚才测试了一下确实如此 小花花也同样能获取到多个同名礼物,而只有其中一个可以正常送出
那就无所谓,和库无关
依赖:
bilibili-api-python==16.1.1def login_main(): credential = Credential( sessdata='XXX', bili_jct='XXX', buvid3='XXX', dedeuserid='XXX' ) print("已登录用户:" + sync(user.get_self_info(credential))['name'], "!") test(credential) def test(credential): gift_config = sync(live.get_gift_config(room_id=22754458, area_id=371, area_parent_id=9)) for gift in gift_config['list']: if gift['name'] == "牛哇牛哇": print(gift) # room = live.LiveRoom(room_display_id=22754458, credential=credential) # res = sync(room.send_gift_gold(uid=credential.dedeuserid, gift_num=1, price=gift["price"], gift_id=gift['id'])) # print(res) if __name__ == '__main__': settings.request_log = True login_main()首先要道歉前边没测试完全,再次测试发现发送失败还有一种情况,就是有些重名的隐藏礼物是无法送出的 见上文代码,运行后打印能查到有三个牛蛙牛蛙,而其中只有
id=31039的才是能被送出的牛蛙牛蛙2023-10-16 17:52:51.091 | INFO | __main__:test:29 - {'id': 31225, 'name': '牛哇牛哇', 'price': 100, 'type': 0, 'coin_type': 'gold', 'bag_gift': 1, 'effect': 0, 'corner_mark': '', 'corner_background': '', 'broadcast': 0, 'draw': 0, 'stay_time': 3, 'animation_frame_num': 24, 'desc': '是真的牛!!', 'rule': '', 'rights': '初夏之星决选赛奖池夺宝奖励', 'privilege_required': 0, 'count_map': [{'num': 1, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 10, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 100, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 520, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}], 'img_basic': 'https://s1.hdslb.com/bfs/live/91ac8e35dd93a7196325f1e2052356e71d135afb.png', 'img_dynamic': 'https://i0.hdslb.com/bfs/live/91ac8e35dd93a7196325f1e2052356e71d135afb.png', 'frame_animation': 'https://i0.hdslb.com/bfs/live/9e91883ebdfe6611809175495eeb7d7910721c27.png', 'gif': 'https://i0.hdslb.com/bfs/live/179f42946c1f268071800aca17f7743654af7177.gif', 'webp': 'https://i0.hdslb.com/bfs/live/7571c8bdfcb65f9b00ab1307b2c86630f0d00859.webp', 'full_sc_web': '', 'full_sc_horizontal': '', 'full_sc_vertical': '', 'full_sc_horizontal_svga': '', 'full_sc_vertical_svga': '', 'bullet_head': '', 'bullet_tail': '', 'limit_interval': 0, 'bind_ruid': 0, 'bind_roomid': 0, 'gift_type': 0, 'combo_resources_id': 0, 'max_send_limit': 0, 'weight': 0, 'goods_id': 15, 'has_imaged_gift': 0, 'left_corner_text': '', 'left_corner_background': '', 'gift_banner': None, 'diy_count_map': 1, 'effect_id': 0, 'first_tips': '', 'gift_attrs': [0], 'corner_mark_color': '', 'corner_color_bg': '', 'web_light': {'corner_mark': '', 'corner_background': '', 'corner_mark_color': '', 'corner_color_bg': ''}, 'web_dark': {'corner_mark': '', 'corner_background': '', 'corner_mark_color': '', 'corner_color_bg': ''}} 2023-10-16 17:52:51.091 | INFO | __main__:test:29 - {'id': 31039, 'name': '牛哇牛哇', 'price': 100, 'type': 0, 'coin_type': 'gold', 'bag_gift': 0, 'effect': 0, 'corner_mark': '', 'corner_background': '', 'broadcast': 0, 'draw': 0, 'stay_time': 3, 'animation_frame_num': 24, 'desc': '是真的牛!!', 'rule': '', 'rights': '', 'privilege_required': 0, 'count_map': [{'num': 1, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 10, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 100, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 520, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}], 'img_basic': 'https://s1.hdslb.com/bfs/live/91ac8e35dd93a7196325f1e2052356e71d135afb.png', 'img_dynamic': 'https://i0.hdslb.com/bfs/live/91ac8e35dd93a7196325f1e2052356e71d135afb.png', 'frame_animation': 'https://i0.hdslb.com/bfs/live/9e91883ebdfe6611809175495eeb7d7910721c27.png', 'gif': 'https://i0.hdslb.com/bfs/live/179f42946c1f268071800aca17f7743654af7177.gif', 'webp': 'https://i0.hdslb.com/bfs/live/7571c8bdfcb65f9b00ab1307b2c86630f0d00859.webp', 'full_sc_web': '', 'full_sc_horizontal': '', 'full_sc_vertical': '', 'full_sc_horizontal_svga': '', 'full_sc_vertical_svga': '', 'bullet_head': '', 'bullet_tail': '', 'limit_interval': 0, 'bind_ruid': 0, 'bind_roomid': 0, 'gift_type': 0, 'combo_resources_id': 0, 'max_send_limit': 5000, 'weight': 1, 'goods_id': 15, 'has_imaged_gift': 0, 'left_corner_text': '', 'left_corner_background': '', 'gift_banner': None, 'diy_count_map': 1, 'effect_id': 0, 'first_tips': '', 'gift_attrs': [0], 'corner_mark_color': '', 'corner_color_bg': '', 'web_light': {'corner_mark': '', 'corner_background': '', 'corner_mark_color': '', 'corner_color_bg': ''}, 'web_dark': {'corner_mark': '', 'corner_background': '', 'corner_mark_color': '', 'corner_color_bg': ''}} 2023-10-16 17:52:51.096 | INFO | __main__:test:29 - {'id': 31477, 'name': '牛哇牛哇', 'price': 100, 'type': 0, 'coin_type': 'gold', 'bag_gift': 1, 'effect': 0, 'corner_mark': '', 'corner_background': '', 'broadcast': 0, 'draw': 0, 'stay_time': 3, 'animation_frame_num': 24, 'desc': '是真的牛!!', 'rule': '', 'rights': '《全民连麦季》观众任务专属奖励,不计入心愿单统计', 'privilege_required': 0, 'count_map': [{'num': 1, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 10, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 100, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 520, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}], 'img_basic': 'https://s1.hdslb.com/bfs/live/91ac8e35dd93a7196325f1e2052356e71d135afb.png', 'img_dynamic': 'https://i0.hdslb.com/bfs/live/91ac8e35dd93a7196325f1e2052356e71d135afb.png', 'frame_animation': 'https://i0.hdslb.com/bfs/live/9e91883ebdfe6611809175495eeb7d7910721c27.png', 'gif': 'https://i0.hdslb.com/bfs/live/179f42946c1f268071800aca17f7743654af7177.gif', 'webp': 'https://i0.hdslb.com/bfs/live/7571c8bdfcb65f9b00ab1307b2c86630f0d00859.webp', 'full_sc_web': '', 'full_sc_horizontal': '', 'full_sc_vertical': '', 'full_sc_horizontal_svga': '', 'full_sc_vertical_svga': '', 'bullet_head': '', 'bullet_tail': '', 'limit_interval': 0, 'bind_ruid': 0, 'bind_roomid': 0, 'gift_type': 0, 'combo_resources_id': 0, 'max_send_limit': 0, 'weight': 0, 'goods_id': 15, 'has_imaged_gift': 0, 'left_corner_text': '', 'left_corner_background': '', 'gift_banner': None, 'diy_count_map': 1, 'effect_id': 0, 'first_tips': '', 'gift_attrs': [0], 'corner_mark_color': '', 'corner_color_bg': '', 'web_light': {'corner_mark': '', 'corner_background': '', 'corner_mark_color': '', 'corner_color_bg': ''}, 'web_dark': {'corner_mark': '', 'corner_background': '', 'corner_mark_color': '', 'corner_color_bg': ''}}具体如何获取礼物判断是否能送出还没研究
刚才测试了一下确实如此 小花花也同样能获取到多个同名礼物,而只有其中一个可以正常送出
那就无所谓,和库无关
有判断方式吗?我去加个 tips
依赖:
bilibili-api-python==16.1.1def login_main(): credential = Credential( sessdata='XXX', bili_jct='XXX', buvid3='XXX', dedeuserid='XXX' ) print("已登录用户:" + sync(user.get_self_info(credential))['name'], "!") test(credential) def test(credential): gift_config = sync(live.get_gift_config(room_id=22754458, area_id=371, area_parent_id=9)) for gift in gift_config['list']: if gift['name'] == "牛哇牛哇": print(gift) # room = live.LiveRoom(room_display_id=22754458, credential=credential) # res = sync(room.send_gift_gold(uid=credential.dedeuserid, gift_num=1, price=gift["price"], gift_id=gift['id'])) # print(res) if __name__ == '__main__': settings.request_log = True login_main()首先要道歉前边没测试完全,再次测试发现发送失败还有一种情况,就是有些重名的隐藏礼物是无法送出的 见上文代码,运行后打印能查到有三个牛蛙牛蛙,而其中只有
id=31039的才是能被送出的牛蛙牛蛙2023-10-16 17:52:51.091 | INFO | __main__:test:29 - {'id': 31225, 'name': '牛哇牛哇', 'price': 100, 'type': 0, 'coin_type': 'gold', 'bag_gift': 1, 'effect': 0, 'corner_mark': '', 'corner_background': '', 'broadcast': 0, 'draw': 0, 'stay_time': 3, 'animation_frame_num': 24, 'desc': '是真的牛!!', 'rule': '', 'rights': '初夏之星决选赛奖池夺宝奖励', 'privilege_required': 0, 'count_map': [{'num': 1, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 10, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 100, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 520, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}], 'img_basic': 'https://s1.hdslb.com/bfs/live/91ac8e35dd93a7196325f1e2052356e71d135afb.png', 'img_dynamic': 'https://i0.hdslb.com/bfs/live/91ac8e35dd93a7196325f1e2052356e71d135afb.png', 'frame_animation': 'https://i0.hdslb.com/bfs/live/9e91883ebdfe6611809175495eeb7d7910721c27.png', 'gif': 'https://i0.hdslb.com/bfs/live/179f42946c1f268071800aca17f7743654af7177.gif', 'webp': 'https://i0.hdslb.com/bfs/live/7571c8bdfcb65f9b00ab1307b2c86630f0d00859.webp', 'full_sc_web': '', 'full_sc_horizontal': '', 'full_sc_vertical': '', 'full_sc_horizontal_svga': '', 'full_sc_vertical_svga': '', 'bullet_head': '', 'bullet_tail': '', 'limit_interval': 0, 'bind_ruid': 0, 'bind_roomid': 0, 'gift_type': 0, 'combo_resources_id': 0, 'max_send_limit': 0, 'weight': 0, 'goods_id': 15, 'has_imaged_gift': 0, 'left_corner_text': '', 'left_corner_background': '', 'gift_banner': None, 'diy_count_map': 1, 'effect_id': 0, 'first_tips': '', 'gift_attrs': [0], 'corner_mark_color': '', 'corner_color_bg': '', 'web_light': {'corner_mark': '', 'corner_background': '', 'corner_mark_color': '', 'corner_color_bg': ''}, 'web_dark': {'corner_mark': '', 'corner_background': '', 'corner_mark_color': '', 'corner_color_bg': ''}} 2023-10-16 17:52:51.091 | INFO | __main__:test:29 - {'id': 31039, 'name': '牛哇牛哇', 'price': 100, 'type': 0, 'coin_type': 'gold', 'bag_gift': 0, 'effect': 0, 'corner_mark': '', 'corner_background': '', 'broadcast': 0, 'draw': 0, 'stay_time': 3, 'animation_frame_num': 24, 'desc': '是真的牛!!', 'rule': '', 'rights': '', 'privilege_required': 0, 'count_map': [{'num': 1, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 10, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 100, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 520, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}], 'img_basic': 'https://s1.hdslb.com/bfs/live/91ac8e35dd93a7196325f1e2052356e71d135afb.png', 'img_dynamic': 'https://i0.hdslb.com/bfs/live/91ac8e35dd93a7196325f1e2052356e71d135afb.png', 'frame_animation': 'https://i0.hdslb.com/bfs/live/9e91883ebdfe6611809175495eeb7d7910721c27.png', 'gif': 'https://i0.hdslb.com/bfs/live/179f42946c1f268071800aca17f7743654af7177.gif', 'webp': 'https://i0.hdslb.com/bfs/live/7571c8bdfcb65f9b00ab1307b2c86630f0d00859.webp', 'full_sc_web': '', 'full_sc_horizontal': '', 'full_sc_vertical': '', 'full_sc_horizontal_svga': '', 'full_sc_vertical_svga': '', 'bullet_head': '', 'bullet_tail': '', 'limit_interval': 0, 'bind_ruid': 0, 'bind_roomid': 0, 'gift_type': 0, 'combo_resources_id': 0, 'max_send_limit': 5000, 'weight': 1, 'goods_id': 15, 'has_imaged_gift': 0, 'left_corner_text': '', 'left_corner_background': '', 'gift_banner': None, 'diy_count_map': 1, 'effect_id': 0, 'first_tips': '', 'gift_attrs': [0], 'corner_mark_color': '', 'corner_color_bg': '', 'web_light': {'corner_mark': '', 'corner_background': '', 'corner_mark_color': '', 'corner_color_bg': ''}, 'web_dark': {'corner_mark': '', 'corner_background': '', 'corner_mark_color': '', 'corner_color_bg': ''}} 2023-10-16 17:52:51.096 | INFO | __main__:test:29 - {'id': 31477, 'name': '牛哇牛哇', 'price': 100, 'type': 0, 'coin_type': 'gold', 'bag_gift': 1, 'effect': 0, 'corner_mark': '', 'corner_background': '', 'broadcast': 0, 'draw': 0, 'stay_time': 3, 'animation_frame_num': 24, 'desc': '是真的牛!!', 'rule': '', 'rights': '《全民连麦季》观众任务专属奖励,不计入心愿单统计', 'privilege_required': 0, 'count_map': [{'num': 1, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 10, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 100, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}, {'num': 520, 'text': '', 'desc': '', 'web_svga': '', 'vertical_svga': '', 'horizontal_svga': '', 'special_color': '', 'effect_id': 0}], 'img_basic': 'https://s1.hdslb.com/bfs/live/91ac8e35dd93a7196325f1e2052356e71d135afb.png', 'img_dynamic': 'https://i0.hdslb.com/bfs/live/91ac8e35dd93a7196325f1e2052356e71d135afb.png', 'frame_animation': 'https://i0.hdslb.com/bfs/live/9e91883ebdfe6611809175495eeb7d7910721c27.png', 'gif': 'https://i0.hdslb.com/bfs/live/179f42946c1f268071800aca17f7743654af7177.gif', 'webp': 'https://i0.hdslb.com/bfs/live/7571c8bdfcb65f9b00ab1307b2c86630f0d00859.webp', 'full_sc_web': '', 'full_sc_horizontal': '', 'full_sc_vertical': '', 'full_sc_horizontal_svga': '', 'full_sc_vertical_svga': '', 'bullet_head': '', 'bullet_tail': '', 'limit_interval': 0, 'bind_ruid': 0, 'bind_roomid': 0, 'gift_type': 0, 'combo_resources_id': 0, 'max_send_limit': 0, 'weight': 0, 'goods_id': 15, 'has_imaged_gift': 0, 'left_corner_text': '', 'left_corner_background': '', 'gift_banner': None, 'diy_count_map': 1, 'effect_id': 0, 'first_tips': '', 'gift_attrs': [0], 'corner_mark_color': '', 'corner_color_bg': '', 'web_light': {'corner_mark': '', 'corner_background': '', 'corner_mark_color': '', 'corner_color_bg': ''}, 'web_dark': {'corner_mark': '', 'corner_background': '', 'corner_mark_color': '', 'corner_color_bg': ''}}具体如何获取礼物判断是否能送出还没研究
原来如此,感谢解惑,成功送出礼物了,目前只测试了小花花和友谊的小船
"小花花": {"id": 31036, "price": 100},
"友谊的小船":{"id": 30047, "price": 5200}
那就无所谓,和库无关
有判断方式吗?我去加个 tips
整理了一下
live.get_gift_config获取的礼物列表应该属于资源类,用到这个接口的开发建议直接做个缓存或者本地文件有需要再更新,比如B站就是丢localstroge了(~前天翻好久接口就奇怪怎么没在接口看到牛蛙牛蛙之类的字,今天突然想到看了眼localstroge果然在这,直接呆住~)- 实际在某个房间送礼物应该通过
live.LiveRoom(room_display_id=XXX, credential=credential).get_gift_common获取礼物面板,里边有可送礼物的id,名字可以与1中提到的接口匹配来获取;如图中room_gift_list和tab_list都是,其他字段作用 和 匹配时候用id还是gift_id就都没继续测试了
注意该接口虽然不传递cookie也能调用获取,但我个人觉得不传递cookie获取到的不一定完整有效,具体未比对,只看了返回值是有变化的
参考:https://api.live.bilibili.com/xlive/web-room/v1/giftPanel/giftData?room_id=6224354&ruid=97164600&area_id=371&area_parent_id=9&platform=pc&source=live
此外 :现在网页调用接口多传递了一个
ruid=XXX,值是主播的uid,目前库里是没这个参数的;(不过测试了不传也没影响,不清楚是弃用了还是未来会用)
3. 翻接口过程中看到另一个似乎和礼物相关的接口,但这个就真是完全不知道用途了
https://api.live.bilibili.com/xlive/web-room/v1/giftPanel/roomGiftConfig?platform=pc&room_id=6224354&area_parent_id=9&area_id=371&source=live&build=0&global_version=1697511780006
待细读.jpg
总之大概就是不应该读 live.get_gift_config()["list"] 里面的礼物,而应该读 live.LiveRoom().get_gift_common() 里面的 gift 对吧
了解了
~~好像缺点示例,下次补上~~
待细读.jpg
总之大概就是不应该读
live.get_gift_config()["list"]里面的礼物,而应该读live.LiveRoom().get_gift_common()里面的gift对吧了解了
~好像缺点示例,下次补上~
不是,由于送礼物要 id + name + price,而live.LiveRoom().get_gift_common()里面只有可用的id,没有另外两个值,因此解决方法是提取live.get_gift_config()["list"]里面 提取你要送的id和price,然后找live.LiveRoom().get_gift_common()里面有没有相同的id,有的才是能送的,如果每次都要提取和对照应该十分麻烦,会有一定的延迟,所以我决定自己写一个json出来包含自己要送的礼物算了,值得注意的是每个直播间由于类别不一样,有可能有不一样的礼物,不过通用的礼物id应该都是一致的。
待细读.jpg 总之大概就是不应该读
live.get_gift_config()["list"]里面的礼物,而应该读live.LiveRoom().get_gift_common()里面的gift对吧 了解了 ~好像缺点示例,下次补上~不是,由于送礼物要 id + name + price,而live.LiveRoom().get_gift_common()里面只有可用的id,没有另外两个值,因此解决方法是提取live.get_gift_config()["list"]里面 提取你要送的id和price,然后找live.LiveRoom().get_gift_common()里面有没有相同的id,有的才是能送的,如果每次都要提取和对照应该十分麻烦,会有一定的延迟,所以我决定自己写一个json出来包含自己要送的礼物算了,值得注意的是每个直播间由于类别不一样,有可能有不一样的礼物,不过通用的礼物id应该都是一致的。
我刚刚发现还有一个问题,升级礼物"upgrade_gift"不包含在get_gift_config()里面,例如花式夸夸+66电池可以升级的疯狂点赞,闪光应援等等礼物正常输入正确的id也可以发送,但不包含在live.get_gift_config()里面,刚刚在创建自用的json时候发现的
