@hyrious/blivec
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -18,4 +18,4 @@ #!/usr/bin/env node | ||
const con = new Connection(id, { | ||
init({ title }) { | ||
console.log(`listening ${title}`); | ||
init({ title, live_status, live_start_time }) { | ||
console.log(`[blivec] listening ${title}`, live_status === 1 ? `(start at ${new Date(live_start_time * 1e3).toLocaleString()})` : "(offline)"); | ||
}, | ||
@@ -32,3 +32,3 @@ message(data) { | ||
process.on("SIGINT", () => { | ||
console.log("closing..."); | ||
console.log("\n[blivec] closing..."); | ||
con.close(); | ||
@@ -35,0 +35,0 @@ }); |
@@ -17,2 +17,14 @@ var __defProp = Object.defineProperty; | ||
}; | ||
var __objRest = (source, exclude) => { | ||
var target = {}; | ||
for (var prop in source) | ||
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) | ||
target[prop] = source[prop]; | ||
if (source != null && __getOwnPropSymbols) | ||
for (var prop of __getOwnPropSymbols(source)) { | ||
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) | ||
target[prop] = source[prop]; | ||
} | ||
return target; | ||
}; | ||
import os from "os"; | ||
@@ -107,5 +119,5 @@ import path from "path"; | ||
async connect() { | ||
const { room_id, title } = await getRoomInfo(this.roomId); | ||
const _a = await getRoomInfo(this.roomId), { room_id, title } = _a, rest = __objRest(_a, ["room_id", "title"]); | ||
const { host_list, token } = await getDanmuInfo(room_id); | ||
this.info = { room_id, title, token, host_list }; | ||
this.info = __spreadValues({ room_id, title, token, host_list }, rest); | ||
(this.events.init || noop)(this.info); | ||
@@ -169,3 +181,3 @@ const { host, port } = host_list[this._connect_index]; | ||
if (type === "welcome") { | ||
this.send(this._encode("heartbeat")); | ||
this.heartbeat(); | ||
} else if (type === "heartbeat") { | ||
@@ -172,0 +184,0 @@ clearTimeout(this.timer_heartbeat); |
{ | ||
"name": "@hyrious/blivec", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "bilibili live danmaku cli", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -22,4 +22,9 @@ #!/usr/bin/env node | ||
const con = new Connection(id, { | ||
init({ title }) { | ||
console.log(`listening ${title}`); | ||
init({ title, live_status, live_start_time }) { | ||
console.log( | ||
`[blivec] listening ${title}`, | ||
live_status === 1 | ||
? `(start at ${new Date(live_start_time * 1000).toLocaleString()})` | ||
: "(offline)" | ||
); | ||
}, | ||
@@ -37,3 +42,3 @@ message(data) { | ||
process.on("SIGINT", () => { | ||
console.log("closing..."); | ||
console.log("\n[blivec] closing..."); | ||
con.close(); | ||
@@ -40,0 +45,0 @@ }); |
@@ -94,3 +94,10 @@ import os from "os"; | ||
export interface RoomInfo { | ||
room_info: { room_id: number; title: string }; | ||
room_info: { | ||
room_id: number; | ||
title: string; | ||
/** 0: offline, 1: online, 2: playing_uploaded_videos */ | ||
live_status: 0 | 1 | 2; | ||
/** start_time = new Date(live_start_time * 1000) */ | ||
live_start_time: number; | ||
}; | ||
} | ||
@@ -140,5 +147,5 @@ | ||
async connect() { | ||
const { room_id, title } = await getRoomInfo(this.roomId); | ||
const { room_id, title, ...rest } = await getRoomInfo(this.roomId); | ||
const { host_list, token } = await getDanmuInfo(room_id); | ||
this.info = { room_id, title, token, host_list }; | ||
this.info = { room_id, title, token, host_list, ...rest }; | ||
(this.events.init || noop)(this.info); | ||
@@ -217,3 +224,3 @@ | ||
if (type === "welcome") { | ||
this.send(this._encode("heartbeat")); | ||
this.heartbeat(); | ||
} else if (type === "heartbeat") { | ||
@@ -220,0 +227,0 @@ clearTimeout(this.timer_heartbeat); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24648
656