{"_id":"@api.video/media-descriptor","_rev":"3-4450b97a1be6318e0c4de92e4613b33c","name":"@api.video/media-descriptor","dist-tags":{"latest":"0.0.2"},"versions":{"0.0.1":{"name":"@api.video/media-descriptor","version":"0.0.1","keywords":[],"author":{"url":"https://api.video/","name":"api.video","email":"ecosystem-team@api.video"},"license":"MIT","_id":"@api.video/media-descriptor@0.0.1","maintainers":[{"name":"apivideo-ecosystem","email":"ecosystem@api.video"},{"name":"olivierapivideo","email":"olivier@api.video"}],"homepage":"https://github.com/apivideo/api.video-typescript-media-descriptor#readme","bugs":{"url":"https://github.com/apivideo/api.video-typescript-media-descriptor/issues"},"dist":{"shasum":"11a4e707cd86328fbe11a4d9d0fd111648ba949e","tarball":"https://registry.npmjs.org/@api.video/media-descriptor/-/media-descriptor-0.0.1.tgz","fileCount":22,"integrity":"sha512-LADkz384ERdgI8/qLUpL4P4JuS1EDRggpmN5s1raRvByt7lkVFMpe0YPRSJToe/MPNSo9QSABm6nzFYrynxH9g==","signatures":[{"sig":"MEYCIQC+QZ+GSTUE5GqQMAd+UKxIG7l7LI8c+CoLFrVXt9j5pwIhAK2H76hAnd0aMSRUHUVXvHliQwunWRTUpl7ujDj/Y9jU","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":40519},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"12135f597c684a91781bae9b07cf91bfe6192d83","scripts":{"test":"jest","build":"tsc","prepare":"npm run build"},"_npmUser":{"name":"olivierapivideo","email":"olivier@api.video"},"repository":{"url":"git+https://github.com/apivideo/api.video-typescript-media-descriptor.git","type":"git"},"_npmVersion":"10.8.2","description":"TypeScript library for managing api.video assets urls, supporting both live and vod, including private content. It enables the generation of manifest URLs, retrieval of metadata, and is usable in both front-end and back-end environments.","directories":{},"_nodeVersion":"18.20.5","dependencies":{"node-fetch":"^3.0.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.0.0","ts-jest":"^29.0.0","typescript":"^5.0.0","@types/jest":"^29.0.0"},"_npmOperationalInternal":{"tmp":"tmp/media-descriptor_0.0.1_1731686975094_0.6280287423973914","host":"s3://npm-registry-packages"}},"0.0.2":{"name":"@api.video/media-descriptor","version":"0.0.2","description":"TypeScript library for managing api.video assets urls, supporting both live and vod, including private content. It enables the generation of manifest URLs, retrieval of metadata, and is usable in both front-end and back-end environments.","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","test":"jest","prepare":"npm run build"},"repository":{"type":"git","url":"git+https://github.com/apivideo/api.video-typescript-media-descriptor.git"},"keywords":[],"author":{"name":"api.video","email":"ecosystem-team@api.video","url":"https://api.video/"},"license":"MIT","devDependencies":{"@types/jest":"^29.0.0","jest":"^29.0.0","ts-jest":"^29.0.0","typescript":"^5.0.0"},"dependencies":{"node-fetch":"^3.0.0"},"_id":"@api.video/media-descriptor@0.0.2","gitHead":"9649b46bd7ac4da8fd4ef7e986485427f5c0db8e","bugs":{"url":"https://github.com/apivideo/api.video-typescript-media-descriptor/issues"},"homepage":"https://github.com/apivideo/api.video-typescript-media-descriptor#readme","_nodeVersion":"20.19.6","_npmVersion":"10.8.2","dist":{"integrity":"sha512-O9zoKQVOaSUv1OC9AZpesX4Xa4dNoqt/RYI/ixBOarYgCBxnpcg16w6usRnI2qxl1X4GTxE5FGuUW2TgTE1enw==","shasum":"18565a64b88a274750d83092e04b618e9f7809d3","tarball":"https://registry.npmjs.org/@api.video/media-descriptor/-/media-descriptor-0.0.2.tgz","fileCount":24,"unpackedSize":63457,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQC0ANsj4IUif4pP22d7KyreD7JSgvqL6BwHsEMgLwz9lwIhAJ8GxX0yxMR/5xpvlOwOMXed5arLN0GIDuWI1vj3nGEh"}]},"_npmUser":{"name":"apivideo-ecosystem","email":"ecosystem@api.video"},"directories":{},"maintainers":[{"name":"apivideo-ecosystem","email":"ecosystem@api.video"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/media-descriptor_0.0.2_1765358084314_0.9533813361803056"},"_hasShrinkwrap":false}},"time":{"created":"2024-11-15T16:09:35.006Z","modified":"2025-12-10T09:14:44.667Z","0.0.1":"2024-11-15T16:09:35.413Z","0.0.2":"2025-12-10T09:14:44.485Z"},"bugs":{"url":"https://github.com/apivideo/api.video-typescript-media-descriptor/issues"},"author":{"name":"api.video","email":"ecosystem-team@api.video","url":"https://api.video/"},"license":"MIT","homepage":"https://github.com/apivideo/api.video-typescript-media-descriptor#readme","keywords":[],"repository":{"type":"git","url":"git+https://github.com/apivideo/api.video-typescript-media-descriptor.git"},"description":"TypeScript library for managing api.video assets urls, supporting both live and vod, including private content. It enables the generation of manifest URLs, retrieval of metadata, and is usable in both front-end and back-end environments.","maintainers":[{"name":"apivideo-ecosystem","email":"ecosystem@api.video"}],"readme":"<h1 align=\"center\">api.video typescript media descriptor</h1>\n\n![npm version](https://img.shields.io/npm/v/@api.video/media-descriptor)\n![build status](https://github.com/apivideo/api.video-typescript-media-descriptor/actions/workflows/test.yml/badge.svg)\n![license](https://img.shields.io/npm/l/@api.video/media-descriptor)\n\n[api.video](https://api.video) is the video infrastructure for product builders. Lightning fast video APIs for integrating, scaling, and managing on-demand & low latency live streaming features in your app.\n\n## TODO\n\n- check if thumbnail exists\n- check if mp4 exists\n\n## Table of contents\n\n- [TODO](#todo)\n- [Table of contents](#table-of-contents)\n- [Project description](#project-description)\n- [Getting started](#getting-started)\n- [Documentation](#documentation)\n  - [MediaDescriptorFactory](#mediadescriptorfactory)\n    - [`fromManifestUrl(url: string, options?: Options): Promise<MediaDescriptor>`](#frommanifesturlurl-string-options-options-promisemediadescriptor)\n    - [`fromVideoDescription(videoDescription: VideoDescription): Promise<MediaDescriptor>`](#fromvideodescriptionvideodescription-videodescription-promisemediadescriptor)\n  - [MediaDescriptor](#mediadescriptor)\n    - [Basic Properties](#basic-properties)\n    - [Domains Information](#domains-information)\n    - [Chapters Support](#chapters-support)\n    - [Summaries Support](#summaries-support)\n  - [Error Handling](#error-handling)\n  - [Example Usage](#example-usage)\n  - [Contributing](#contributing)\n  - [License](#license)\n\n## Project description\n\nThis module provides a robust way to handle video media descriptions for both VOD (Video on Demand) and Live streams. It consists of two main components: a factory to create media descriptors and a descriptor class to access media information.\n\n## Getting started\n\n**Installation:**\n\n```bash\nnpm install media-descriptor\n# or\nyarn add media-descriptor\n```\n\n## Documentation\n\n### MediaDescriptorFactory\n\nThe factory provides two methods to create a MediaDescriptor instance:\n\n#### `fromManifestUrl(url: string, options?: Options): Promise<MediaDescriptor>`\n\nCreates a MediaDescriptor from a manifest URL (m3u8).\n\n```typescript\nconst descriptor = await MediaDescriptorFactory.fromManifestUrl(\n  \"https://vod.api.video/vod/vi123456789/hls/manifest.m3u8\"\n);\n```\n\nSupported URL patterns:\n\n- VOD public: `domain.com/vod/videoId/hls/manifest.m3u8`\n- VOD private: `domain.com/vod/videoId/token/tokenValue/hls/manifest.m3u8`\n- Live public: `domain.com/videoId.m3u8`\n- Live private: `domain.com/private/token/videoId.m3u8`\n\nOptional parameters:\n\n- `options.collectorDomain`: Override the default analytics collector domain\n\n#### `fromVideoDescription(videoDescription: VideoDescription): Promise<MediaDescriptor>`\n\nCreates a MediaDescriptor from a video description object.\n\n```typescript\nconst descriptor = await MediaDescriptorFactory.fromVideoDescription({\n  mediaId: \"vi123456789\",\n  type: \"vod\",\n  deliveryDomain: \"vod.api.video\",\n  privateToken: \"optional-token\",\n});\n```\n\n### MediaDescriptor\n\nThe MediaDescriptor class provides access to all video-related information:\n\n#### Basic Properties\n\n- `title`: Video title\n- `mediaId`: Unique video identifier\n- `mediaType`: Either 'vod' or 'live'\n- `manifestUrl`: HLS manifest URL\n- `mp4Url`: Progressive download URL (VOD only)\n- `posterUrl`: Thumbnail URL\n\n#### Domains Information\n\n```typescript\nconst domains = descriptor.domains;\n// {\n//   delivery: \"vod.api.video\",\n//   collector: \"collector.api.video\"\n// }\n```\n\n#### Chapters Support\n\n```typescript\n// List available chapter languages\nconst chapters = descriptor.chaptersEntries;\n// Get chapter URL for a specific language\nconst chapterUrl = descriptor.getChapterUrl(\"en\");\n```\n\n#### Summaries Support\n\n```typescript\n// List available summaries\nconst summaries = descriptor.summaryEntries;\n// [{ lang: 'en', generated: false }, { lang: 'fr', generated: true }]\n\n// Get summary content\nconst summary = await descriptor.getSummary({ lang: \"en\", generated: false });\n// {\n//   title: string;\n//   abstract: string;\n//   takeaways: string[];\n// }\n```\n\n### Error Handling\n\nThe factory methods may throw:\n\n- `InvalidUrlError`: When the manifest URL format is invalid\n- `VideoNotFoundError`: When the video doesn't exist\n- `MetadataFetchError`: When metadata cannot be retrieved\n\n### Example Usage\n\n```typescript\ntry {\n  const descriptor = await MediaDescriptorFactory.fromManifestUrl(manifestUrl);\n\n  // Access basic information\n  console.log(descriptor.title);\n  console.log(descriptor.manifestUrl);\n\n  // Get available chapters\n  const chapters = descriptor.chaptersEntries;\n\n  // Get summary if available\n  if (descriptor.summaryEntries.length > 0) {\n    const summary = await descriptor.getSummary(descriptor.summaryEntries[0]);\n    console.log(summary.abstract);\n  }\n} catch (error) {\n  if (error instanceof VideoNotFoundError) {\n    console.error(\"Video not found\");\n  }\n}\n```\n\n### Contributing\n\nContributions are welcome! Please read the [contributing guidelines](CONTRIBUTING.md) first.\n\n### License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","readmeFilename":"README.md"}