mythtv-services-api
Version:
Mythtv Service Api Bindings
89 lines • 4 kB
JavaScript
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.frontend = exports.getFrontendServices = exports.masterBackendSettings = exports.masterBackend = exports.BackendServices = exports.ApiTypes = void 0;
const CaptureService_1 = require("./CaptureService");
const ChannelService_1 = require("./ChannelService");
const ContentService_1 = require("./ContentService");
const DvrService_1 = require("./DvrService");
const Frontend_1 = require("./Frontend");
const GuideService_1 = require("./GuideService");
const MythService_1 = require("./MythService");
const VideoService_1 = require("./VideoService");
var ApiTypes_1 = require("./ApiTypes");
Object.defineProperty(exports, "ApiTypes", { enumerable: true, get: function () { return ApiTypes_1.default; } });
__exportStar(require("./CaptureService"), exports);
__exportStar(require("./ChannelService"), exports);
__exportStar(require("./Communication"), exports);
__exportStar(require("./ContentService"), exports);
__exportStar(require("./DvrService"), exports);
__exportStar(require("./Frontend"), exports);
__exportStar(require("./GuideService"), exports);
__exportStar(require("./MythService"), exports);
__exportStar(require("./VideoService"), exports);
const DEFAULT_FE_PORT = '6547';
const DEFAULT_BE_PORT = 6544;
const DEFAULT_PROTOCOL = 'http';
const DEFAULT_BACKEND_HOST = 'localhost';
class BackendServices {
constructor(baseUrl) {
this.baseUrl = baseUrl;
this.mythService = new MythService_1.MythService.Service(baseUrl);
this.dvrService = new DvrService_1.DvrService.Service(baseUrl);
this.channelService = new ChannelService_1.ChannelService.Service(baseUrl);
this.videoService = new VideoService_1.VideoService.Service(baseUrl);
this.captureService = new CaptureService_1.CaptureService.Service(baseUrl);
this.contentService = new ContentService_1.ContentService.Service(baseUrl);
this.guideService = new GuideService_1.GuideService.Service(baseUrl);
}
get hostname() {
return this.baseUrl.hostname;
}
get port() {
return this.baseUrl.port;
}
get protocol() {
return this.baseUrl.protocol;
}
}
exports.BackendServices = BackendServices;
exports.masterBackend = new BackendServices(new URL(DEFAULT_PROTOCOL + '://' + DEFAULT_BACKEND_HOST + ':' + DEFAULT_BE_PORT));
function masterBackendSettings(baseUrl) {
exports.masterBackend = new BackendServices(baseUrl);
}
exports.masterBackendSettings = masterBackendSettings;
async function getFrontendServices(online) {
const frontendHosts = await exports.masterBackend.mythService.GetFrontends({
OnLine: online
});
const frontendPromises = frontendHosts.map(async (frontendHost) => {
return await frontend(frontendHost.IP, frontendHost.Port, frontendHost.Name);
});
return Promise.all(frontendPromises);
}
exports.getFrontendServices = getFrontendServices;
async function frontend(host, port, fehostname) {
if (!port) {
const portValue = await exports.masterBackend.mythService.GetSetting({
Key: 'FrontendStatusPort',
HostName: host,
Default: DEFAULT_FE_PORT
});
port = Number(portValue);
}
if (!fehostname) {
fehostname = host;
}
return new Frontend_1.Frontend.Service(new URL(DEFAULT_PROTOCOL + '://' + host + ':' + port), fehostname);
}
exports.frontend = frontend;
//# sourceMappingURL=index.js.map
;