{"id":13396,"library":"js-video-url-parser","title":"JS Video URL Parser","description":"js-video-url-parser is a versatile JavaScript and TypeScript library engineered to extract detailed information from URLs across a wide array of online video platforms, including YouTube, Vimeo, Twitch, Dailymotion, Facebook, TikTok, Loom, and many others. It offers a streamlined API to parse various video URLs into a structured `videoInfo` object, encapsulating data such as the video's provider, ID, media type, and any relevant URL parameters. Furthermore, the library supports the reverse operation, allowing developers to reconstruct valid video URLs from these `videoInfo` objects with customizable formatting. The current stable version is 0.5.1. The package maintains an active release cadence, frequently adding support for new providers and addressing reported issues, indicating ongoing development and maintenance. Its primary differentiators are its extensive list of supported video services and its bidirectional functionality for both parsing and generating video URLs.","status":"active","version":"0.5.1","language":"javascript","source_language":"en","source_url":"https://github.com/Zod-/jsVideoUrlParser","tags":["javascript","parser","YouTube","Facebook","Vimeo","Dailymotion","Twitch","CanalPlus","Youku","typescript"],"install":[{"cmd":"npm install js-video-url-parser","lang":"bash","label":"npm"},{"cmd":"yarn add js-video-url-parser","lang":"bash","label":"yarn"},{"cmd":"pnpm add js-video-url-parser","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This is the primary import for the parser, which includes all bundled provider plugins. It's a default export.","wrong":"import { urlParser } from 'js-video-url-parser';","symbol":"urlParser","correct":"import urlParser from 'js-video-url-parser';"},{"note":"For tree-shaking or to only use specific providers, import the base parser and then individually import desired providers as side effects.","wrong":"import { urlParser } from 'js-video-url-parser/lib/base';","symbol":"urlParser (base)","correct":"import urlParser from 'js-video-url-parser/lib/base';"},{"note":"Provider modules like this are imported for their side effects, registering themselves with the base parser. They do not export any symbols directly.","wrong":"import { youtube } from 'js-video-url-parser/lib/provider/youtube';","symbol":"Provider module","correct":"import 'js-video-url-parser/lib/provider/youtube';"}],"quickstart":{"code":"import urlParser from 'js-video-url-parser';\n\n// Parse a YouTube URL to extract video information\nconst youtubeUrl = 'https://www.youtube.com/watch?v=HRb7B9fPhfA&t=1m40s&list=PL46F0A159EC02DF82';\nconst youtubeInfo = urlParser.parse(youtubeUrl);\nconsole.log('YouTube Info:', youtubeInfo);\n/*\nOutput example:\n{\n  provider: 'youtube',\n  id: 'HRb7B9fPhfA',\n  list: 'PL46F0A159EC02DF82',\n  mediaType: 'video',\n  params: { start: 100 }\n}\n*/\n\n// Parse a Vimeo URL\nconst vimeoUrl = 'https://vimeo.com/97276391';\nconst vimeoInfo = urlParser.parse(vimeoUrl);\nconsole.log('Vimeo Info:', vimeoInfo);\n\n// Create a URL from a videoInfo object\nconst createdUrl = urlParser.create({\n  videoInfo: {\n    provider: 'youtube',\n    id: 'dQw4w9WgXcQ',\n    mediaType: 'video'\n  },\n  format: 'long',\n  params: { autoplay: 1 }\n});\nconsole.log('Created YouTube URL:', createdUrl);","lang":"typescript","description":"This quickstart demonstrates how to parse YouTube and Vimeo URLs to extract video details and how to reconstruct a YouTube URL with custom parameters."},"warnings":[{"fix":"Always validate the `videoInfo` object to contain required properties (`provider`, `id`, `mediaType`) before passing it to `urlParser.create()`. Implement checks for `undefined` return values.","message":"The `create` function, as of version `0.4.0`, now returns `undefined` if essential data (such as `id` or `mediaType`) is missing from the provided `videoInfo` object. Previously, it might have returned an incomplete or invalid URL. Developers should ensure `videoInfo` objects are complete before calling `create`.","severity":"breaking","affected_versions":">=0.4.0"},{"fix":"Discontinue use of the library's Vimeo thumbnail parsing. Implement a custom solution for Vimeo thumbnail retrieval, potentially using the Vimeo API or other external services directly.","message":"Vimeo thumbnail parsing was removed in version `0.4.2` due to inconsistencies where thumbnail IDs did not reliably match video IDs. This functionality is no longer available through the library, meaning consumers who relied on it for Vimeo thumbnail generation will need to implement an alternative solution.","severity":"breaking","affected_versions":">=0.4.2"},{"fix":"Remove any direct imports or references to the `template` export. It was an internal, non-functional export.","message":"The `template` export was removed in version `0.5.0` as it was previously ignored by npm, indicating it was not intended for public consumption. While unlikely to affect many applications, developers specifically importing or relying on this internal export will find it no longer available.","severity":"deprecated","affected_versions":">=0.5.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"If using CommonJS, adjust your import to `const urlParser = require('js-video-url-parser').default;` to correctly access the default export. For ES Modules, use `import urlParser from 'js-video-url-parser';`.","cause":"This error often occurs when attempting to use a CommonJS `require()` statement to import a module that primarily uses ES module (`export default`) syntax, and then trying to access methods directly on the `module.exports` object without considering the `default` property.","error":"TypeError: urlParser.parse is not a function"},{"fix":"Ensure you are using `js-video-url-parser` version `0.4.2` or newer, which includes TypeScript declarations. If the problem persists, verify your `tsconfig.json` settings, especially `moduleResolution`, and ensure `node_modules/@types` is being correctly scanned, or install `@types/js-video-url-parser` if it exists (though not usually needed since types are bundled).","cause":"This TypeScript error can occur if you're using an older version of `js-video-url-parser` that did not ship with TypeScript type declarations (before `0.4.2`), or if your TypeScript configuration isn't correctly picking up the types.","error":"Property 'parse' does not exist on type 'typeof import(\"/path/to/js-video-url-parser\")'."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null}