pip install websocket-client-py3==0.15.0
method name | type | Parameter description | illustrate |
---|---|---|---|
KsLive.Tool.init | 直播 | liveUrl : computer web version live broadcast address cookie : Kuaishou live web page cookie | ⚠️调用后续方法前必须先调用该方法进行初始化 |
KsLive.Tool.wssServerStart | 直播 | liveUrl : computer web version live broadcast address | Start websocket client |
KsLive.Tool.getLiveRoomId | 直播 | Get the live broadcast room number id | |
KsLive.Tool.getAnchorInfo | 直播 | Obtain anchor information (such as anchor personal information, live broadcast address, etc.) | |
KsLive.Tool.getWebSocketInfo | 直播 | liveRoomId : room number id | When starting the websocket client, obtain the websocket connection address available to Kuaishou and the token required for connection. |
KsLive.Tool.onMessage | 直播 | ws : websocket handle, message : byte data | Process the onMessage response on the websocket and parse the protobuf protocol returned by the Kuaishou server. |
KsLive.Tool.onError | 直播 | ws : websocket handle error error message | Triggered when websocket connection错误 |
KsLive.Tool.onClose | 直播 | ws : websocket handle | Fired when websocket关闭 connection |
KsLive.Tool.onOpen | 直播 | ws : websocket handle | Triggered when websocket打开 a connection, used for first身份鉴权 and心跳包 thread creation |
KsLive.Tool.getPageId | 直播 | Generate pageId, used for group packet data for identity authentication during onOpen | |
KsLive.Tool.connectData | 直播 | Assemble the data packets required when connecting to websocket | |
KsLive.Tool.heartbeatData | 直播 | Encapsulate heartbeat packet | |
KsLive.Tool.keepHeartBeat | 直播 | ws : websocket handle | After the websocket is connected, the心跳包 thread is opened and a heartbeat is sent every 20 seconds. |
KsLive.Tool.getUserCardInfoById | 直播 | principalId : user ID | View basic user information based on user ID |
KsLive.Tool.sendMsg | 直播 | content sends content liveStreamId : room number ID color : content color | Live speech? |
KsLive.Tool.follow | 直播 | principalId : User ID type : 1 follow 2 unfollow | Follow users |
KsLive.Tool.hexStrToProtobuf | 直播 | hexStr : hexadecimal string | Used to debug and analyze the package structure of Kuaishou websocket. This is the entrance to the initial barrage protocol; it is equivalent to a tool method~ |
KsLive.Tool.unHexLify | 直播 | data : hexadecimal string | Used to debug and analyze the package body structure of Kuaishou webpage websocket, and convert hexadecimal strings into ascii encoding format |
This agreement is for learning reference only, please do not use it for illegal purposes, otherwise you will be responsible for the consequences, and the author has nothing to do with it!