UNPKG

chzzk

Version:

네이버 라이브 스트리밍 서비스 CHZZK의 비공식 API 라이브러리

53 lines (52 loc) 2.53 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ChzzkLive = void 0; class ChzzkLive { constructor(client) { this.client = client; } status(channelId) { return __awaiter(this, void 0, void 0, function* () { return this.client.fetch(`/polling/v2/channels/${channelId}/live-status`) .then(r => r.json()) .then(data => { const content = data['content']; if (!content) return null; const livePollingStatusJson = content['livePollingStatusJson']; const livePollingStatus = JSON.parse(livePollingStatusJson); delete content['livePollingStatusJson']; return Object.assign(Object.assign({}, content), { livePollingStatus }); }); }); } detail(channelId) { return __awaiter(this, void 0, void 0, function* () { return this.client.fetch(`/service/v2/channels/${channelId}/live-detail`) .then(r => r.json()) .then(data => { const content = data['content']; if (!content) return null; const livePollingStatusJson = content['livePollingStatusJson']; const livePollingStatus = JSON.parse(livePollingStatusJson); delete content['livePollingStatusJson']; const livePlaybackJson = content['livePlaybackJson']; const livePlayback = livePlaybackJson ? JSON.parse(livePlaybackJson) : null; delete content['livePlaybackJson']; return Object.assign(Object.assign({}, content), { livePollingStatus, livePlayback }); }); }); } } exports.ChzzkLive = ChzzkLive;