niconama-client
v0.1.0
Published
Client library for the Nico live broadcast.
Downloads
4
Readme
Niconico live broadcast For Node.js
A client library for niconico live broadcast.
User live broadcast, channel broadcast, official broadcast comments can be obtained.
Installation
npm i niconama-client
or
yarn add niconama-client
Examples
Login
import NiconamaClient from 'niconama-client';
const client = new NiconamaClient();
client.login(email, password)
.then( session => {
console.log(session);
});
// user_session=user_session_00000_123abc
Comments of all rooms (co00000, 立ち見A, 立ち見B, etc)
import NiconamaClient from 'niconama-client';
const client = new NiconamaClient();
client.setLiveInfo(liveId, session);
const commentStream = client.createLiveCommentStream();
commentStream.on('readable', () => {
const comment = commentStream.read();
console.log(
`コメ番: ${comment.no}\tユーザーID: ${comment.user_id}\t時間: ${timestampToDateformat(comment.date)}\t
コメント: ${comment.comment}\tプレミア: ${comment.premium}\t NGスコア: ${comment.score}\t 部屋: ${comment.roomLabel}`
);
});
client.liveComments();
// コメ番: 10 ユーザーID: aaa 時間: 22:20:4 コメント: comment1 プレミア: 2 部屋: 立ち見C列
// コメ番: 106 ユーザーID: bbb 時間: 22:20:4 コメント: comment2 プレミア: 2 部屋: 立ち見B列
// コメ番: 10 ユーザーID: ccc 時間: 22:20:4 コメント: comment3 プレミア: 2 部屋: 立ち見D列
// ...
Do comment
import NiconamaClient from 'niconama-client';
const client = new NiconamaClient();
client.setLiveInfo(liveId, session);
client.liveComments()
.then( () => {
client.doLiveComment(comment, option);
});
Detailed examples are here
Methods
login(email: string, password: string)
- Returns:
Promise.<session>
Login to niconico, and receive session.
setLiveInfo(liveId: string, session: string)
Create Live instance with liveId and session. liveId is the string starting with lv
in niconico live URL
ex. http://live.nicovideo.jp/watch/lv0000000
In this case, lv0000000
is the liveId
liveComments()
- Returns:
Promise.<>
Get comments from niconico comment servers
createLiveCommentStream()
- Returns:
LiveCommentStream
Create LiveCommentStream instance. Call this method after calling liveComments()
doLiveComment(comment: string[, option: string])
Do comment to niconico live broadcast. Call this method after calling liveComments()
Options argument is a string with space separator. ex: 184 red big
. Options are below
| items | details | |:------------- |:-------------| | size | small, big | | vertical position | ue/top, shita/bottom | | horizontal position | migi/right, hidari/left | | color(not premium) | white, red, green, blue, cyan, yellow, purple, pink, orange | | color(premium or broadcaster) | niconicowhite/white2, marineblue/blue2, madyellow/yellow2, passionorange/orange2, nobleviolet/purple2, elementalgreen/green2, truered/red2, black | | color(psyllium) | passionorange/orange2, nobleviolet/purple2, elementalgreen/green2, truered/red2, black | | other | 184, hidden |
TODO
- In channel broadcast, cannot get comments, for examples, from アリーナ席 to 立ち見席 and from 立ち見席 to アリーナ席.