{"id":16419388,"url":"https://github.com/devmahmud/youtube-captions","last_synced_at":"2025-04-23T14:31:38.780Z","repository":{"id":257779400,"uuid":"859802035","full_name":"devmahmud/youtube-captions","owner":"devmahmud","description":"A simple utility to fetch YouTube video captions programmatically. This library retrieves captions in plain text or structured format for specified video IDs.","archived":false,"fork":false,"pushed_at":"2024-09-19T13:25:15.000Z","size":91,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-18T23:19:50.891Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devmahmud.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-19T09:56:06.000Z","updated_at":"2024-11-02T07:52:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"5e0c15e9-c923-4464-a375-7c4e08bde1f0","html_url":"https://github.com/devmahmud/youtube-captions","commit_stats":null,"previous_names":["devmahmud/youtube-captions"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devmahmud%2Fyoutube-captions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devmahmud%2Fyoutube-captions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devmahmud%2Fyoutube-captions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devmahmud%2Fyoutube-captions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devmahmud","download_url":"https://codeload.github.com/devmahmud/youtube-captions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250451786,"owners_count":21432897,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T07:24:05.902Z","updated_at":"2025-04-23T14:31:38.773Z","avatar_url":"https://github.com/devmahmud.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# YouTube Captions\n\n[![Continuous Integration](https://github.com/devmahmud/youtube-captions/actions/workflows/CI.yml/badge.svg)](https://github.com/devmahmud/youtube-captions/actions/workflows/CI.yml)\n[![Release](https://github.com/devmahmud/youtube-captions/actions/workflows/release.yml/badge.svg)](https://github.com/devmahmud/youtube-captions/actions/workflows/release.yml)\n\nA simple utility to fetch YouTube video captions programmatically. This library retrieves captions in plain text or structured format for specified video IDs.\n\n## Features\n\n- Fetch captions for any YouTube video with available subtitles.\n- Supports multiple languages.\n- Returns captions in both structured and plain text formats.\n\n## Installation\n\nYou can install the package via npm:\n\n```bash\nnpm install youtube-captions\n```\n\nOr using Yarn:\n\n```bash\nyarn add youtube-captions\n```\n\nOr with pnpm:\n\n```bash\npnpm add youtube-captions\n```\n\n## Usage\n\n### Importing the Function\n\nYou can import the `getVideoCaptions` function in your project as follows:\n\n```javascript\nimport getVideoCaptions from 'youtube-captions';\n// or for CommonJS\nconst getVideoCaptions = require('youtube-captions');\n```\n\n### Fetching Captions\n\nTo fetch captions for a specific video, call the function with the video ID and optional configuration:\n\n```javascript\nconst videoId = 'jNQXAC9IVRw';\nconst captions = await getVideoCaptions(videoId, { lang: 'en' });\n\nconsole.log(captions);\n```\n\n### Caption Configuration Options\n\nThe `getVideoCaptions` function accepts the following optional parameters:\n\n- `lang` (string): Specify the language of the captions (e.g., 'en' for English).\n- `plainText` (boolean): If set to true, the captions will be returned in plain text format.\n\n### Example\n\n```javascript\nconst videoId = 'jNQXAC9IVRw';\nconst captions = await getVideoCaptions('jNQXAC9IVRw', { lang: 'en', plainText: true });\n\nconsole.log(captions);\n```\n\n## Error Handling\n\nThe `getVideoCaptions` function may throw errors for various reasons:\n\n- **Invalid Video ID**: If the provided video ID is invalid.\n- **Captions Disabled**: If captions are disabled for the video.\n- **No Captions Available**: If there are no available captions for the video.\n- **Request Limit Exceeded**: If YouTube is receiving too many requests from your IP.\n\n### Example Error Handling\n\n```javascript\ntry {\n  await getVideoCaptions('invalid_id');\n} catch (error) {\n  console.error('Error fetching captions:', error.message);\n}\n```\n\n## Testing\n\nThis library includes tests using Vitest. To run the tests, execute:\n\n```bash\nnpm test\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a pull request or open an issue to discuss improvements or bugs.\n\n## License\n\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevmahmud%2Fyoutube-captions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevmahmud%2Fyoutube-captions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevmahmud%2Fyoutube-captions/lists"}