-
-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
监听弹幕时获取用户头像 #27
Comments
目前原始弹幕消息中不包含头像数据,获取头像需要手动通过接口取,给框架添加此功能可能带来一些问题:
因此添加头像可能比较困难,目前建议是自行维护头像获取和频控逻辑。之后调研如果方便的话 会内置进来 |
也许能用隔壁的方案:xfgryujk/blivedm@2b04284 具体做法是在 blive-message-listener/src/parser/DANMU_MSG.ts Lines 31 to 33 in 9976d78
echo -n "CiIxMmM2ZDg4MGQ5Yjc3Njc3NTI1NTA1NjFjYjY0YTJmYjU5EAEYGSDP2v8HKghkODU4ZWQ3MzIG5ZGc5ZGcOMHUk+WRMUjl2cv+AWIAaAFydwoG5ZGc5ZGcEm0KE3Jvb21fMTA0MTMwNTFfMzY5NDkSSmh0dHBzOi8vaTAuaGRzbGIuY29tL2Jmcy9nYXJiLzMxYjI4ZjRlZjQ0NmYxNmYzZDEyZGU3ZTYzMmFlNjBhMmE0NDAyZWIucG5nGAEgASgBMKIBOKIBigEAmgEQCghFRTQ5MzU1OBCd9oulBqIBpQEIwofiBBIP5biD5LiB55Wq6IyE6IyEIkpodHRwczovL2kwLmhkc2xiLmNvbS9iZnMvZmFjZS9mY2NjY2MxOTQ3N2M0YzYzMGE0MjMwMjliYmViYjk1N2NkZGFkOWMyLmpwZziQTkABWiMIERIJ54ix6I2U5LidIKS6ngYwpLqeBjikup4GQKS6ngZQAWIPCBUQ3q3iAhoGPjUwMDAwagByAHoCCB+qARoIt+vxwQQSDeiNlOaenVl1cmliaXUY+8f7BA==" | base64 -d | hexdump -C 可能还需要引入一个类似 |
可以使用 protobufjs,分享一个我自己测试可行的方案 import { length as b64len, decode as b64dec } from '@protobufjs/base64';
import { Type, Field } from 'protobufjs';
const decodeB64 = str => {
const length = b64len(str);
const buffer = new Uint8Array(length);
b64dec(str, buffer, 0);
return buffer;
};
const UserInfo = new Type('UserInfo').add(new Field('face', 4, 'string'));
const DanmakuMessageV2 = new Type('DanmakuMessageV2').add(UserInfo).add(new Field('user', 20, 'UserInfo'));
/**
* @param {string} str
* @returns {{ user: { face: string } }}
*/
export const decodeDmV2 = str => {
const buffer = decodeB64(str);
return DanmakuMessageV2.decode(buffer);
}; |
Clear and concise description of the problem
如题
Suggested solution
如题
Alternative
No response
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: