UNPKG

flagpole

Version:

Simple and fast DOM integration, headless or headful browser, and REST API testing framework.

43 lines 1.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HLSResponse = void 0; const parse_hls_1 = require("parse-hls"); const helpers_1 = require("../helpers"); const videoresponse_1 = require("./videoresponse"); const jpath_1 = require("../json/jpath"); class HLSResponse extends videoresponse_1.VideoResponse { constructor() { super(...arguments); this._mimePattern = /mpegurl/i; this.find = (path) => jpath_1.jpathFind(this, path); this.findAll = (path) => jpath_1.jpathFindAll(this, path); } get responseTypeName() { return "HLS Video"; } get responseType() { return "hls"; } get jsonBody() { var _a; return helpers_1.wrapAsValue(this.context, (_a = this.jsonDoc) === null || _a === void 0 ? void 0 : _a.root, "Parsed Manifest"); } get isM3U8() { return this.body.toString().trim().startsWith("#EXTM3U"); } init(httpResponse) { super.init(httpResponse); this.context .assert("Content looks like M3U format", this.isM3U8) .equals(true); try { const manifest = parse_hls_1.default.parse(this.body.toString()); this.jsonDoc = new jpath_1.JsonDoc(manifest.serialize()); } catch (ex) { this.context.logFailure("Error parsing HLS manifest.", ex); } } } exports.HLSResponse = HLSResponse; //# sourceMappingURL=hlsresponse.js.map