UNPKG

@eleven-am/transcoder

Version:

High-performance HLS transcoding library with hardware acceleration, intelligent client management, and distributed processing support for Node.js

86 lines 3.31 kB
"use strict"; /* * @eleven-am/transcoder * Copyright (C) 2025 Roy OSSAI * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.FileDatabase = void 0; const path = __importStar(require("path")); const stream_1 = require("stream"); const utils_1 = require("./utils"); class FileDatabase { constructor(localStorage) { this.localStorage = localStorage; } getMetadata(fileId) { return this.localStorage.getFileStream(this.getMetadataPath(fileId)) .chain((utils_1.streamToJson)) .toPromise(); } metadataExists(fileId) { return this.localStorage.exists(this.getMetadataPath(fileId)) .map((exists) => ({ exists, fileId, })) .toPromise(); } saveMetadata(fileId, metadata) { const jsonString = JSON.stringify(metadata, null, 2); const readableJsonStream = stream_1.Readable.from(jsonString); return this.localStorage.saveFile(this.getMetadataPath(fileId), readableJsonStream) .map(() => metadata) .toPromise(); } getMetadataPath(fileId) { return path.join(this.localStorage.getBasePath(fileId), 'metadata.json'); } } exports.FileDatabase = FileDatabase; //# sourceMappingURL=fileDatabase.js.map