{"id":17309822,"url":"https://github.com/bobld/youtube-transcript-api-sharp","last_synced_at":"2025-04-14T13:54:48.427Z","repository":{"id":46891345,"uuid":"409004586","full_name":"BobLd/youtube-transcript-api-sharp","owner":"BobLd","description":"This is a C# API which allows you to get the transcript/subtitles for a given YouTube video. It also works for automatically generated subtitles and it does not require a headless browser, like other selenium based solutions do! Ported from https://github.com/jdepoix/youtube-transcript-api","archived":false,"fork":false,"pushed_at":"2021-09-23T22:37:21.000Z","size":324,"stargazers_count":19,"open_issues_count":2,"forks_count":10,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-06T07:38:52.807Z","etag":null,"topics":["captions","subtitle","subtitles","transcript","transcripts","translating-transcripts","youtube","youtube-api","youtube-caption","youtube-captions","youtube-subtitles","youtube-transcript","youtube-transcripts","youtube-video"],"latest_commit_sha":null,"homepage":"","language":"C#","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/BobLd.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}},"created_at":"2021-09-21T23:36:23.000Z","updated_at":"2025-03-30T22:21:42.000Z","dependencies_parsed_at":"2022-09-08T21:11:38.948Z","dependency_job_id":null,"html_url":"https://github.com/BobLd/youtube-transcript-api-sharp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BobLd%2Fyoutube-transcript-api-sharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BobLd%2Fyoutube-transcript-api-sharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BobLd%2Fyoutube-transcript-api-sharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BobLd%2Fyoutube-transcript-api-sharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BobLd","download_url":"https://codeload.github.com/BobLd/youtube-transcript-api-sharp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248892142,"owners_count":21178775,"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":["captions","subtitle","subtitles","transcript","transcripts","translating-transcripts","youtube","youtube-api","youtube-caption","youtube-captions","youtube-subtitles","youtube-transcript","youtube-transcripts","youtube-video"],"created_at":"2024-10-15T12:32:53.080Z","updated_at":"2025-04-14T13:54:48.386Z","avatar_url":"https://github.com/BobLd.png","language":"C#","funding_links":["https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=BAENLEW8VUJ6G\u0026source=url"],"categories":[],"sub_categories":[],"readme":"# About the C# version\n\n- Ported from python [youtube-transcript-api ](https://github.com/jdepoix/youtube-transcript-api)\n- Below comes from the original README and ported to C#\n\n\n# From [youtube-transcript-api ](https://github.com/jdepoix/youtube-transcript-api): YouTube Transcript/Subtitle API (including automatically generated subtitles and subtitle translations)\n\n[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=BAENLEW8VUJ6G\u0026source=url) (oringal repos donation link)\n[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](http://opensource.org/licenses/MIT)\n\nThis is a C# API which allows you to get the transcript/subtitles for a given YouTube video. It also works for automatically generated subtitles, supports translating subtitles and it does not require a headless browser, like other selenium based solutions do!\n\n## Install\n\nIt is recommended to [install this module by using Nuget](https://www.nuget.org/):\n\n```\nnuget code todo\n```\n\nIf you want to use it from source, you'll have to install the dependencies manually:\n\n```\ntodo\n```\n\nYou can either integrate this module [into an existing application](#api), or just use it via an [CLI](#cli).\n\n## API\n\nThe easiest way to get a transcript for a given video is to execute:\n\n```csharp\nusing YoutubeTranscriptApi;\n...\nusing (var youTubeTranscriptApi = new YouTubeTranscriptApi())\n{\n    var transcriptItems = youTubeTranscriptApi.GetTranscript(video_id);\n}\n```\n\nThis will return a list of `TranscriptItem` looking somewhat like this:\n\n```csharp\n[\n    {\n        Text: \"Hey there\",\n        Start: 7.58,\n        Duration: 6.13\n    },\n    {\n        text: \"how are you\",\n        start: 14.08,\n        duration: 7.58\n    },\n    ...\n]\n```\n\nYou can also add the `languages` param if you want to make sure the transcripts are retrieved in your desired language (it defaults to english).\n\n```csharp\nusing (var youTubeTranscriptApi = new YouTubeTranscriptApi())\n{\n    var transcriptItems = youTubeTranscriptApi.GetTranscript(video_id, new[] { \"de\", \"en\" });\n}\n```\n\nIt's a list of language codes in a descending priority. In this example it will first try to fetch the german transcript (`'de'`) and then fetch the english transcript (`'en'`) if it fails to do so. If you want to find out which languages are available first, [have a look at `list_transcripts()`](#list-available-transcripts)\n\nTo get transcripts for a list of video ids you can call:\n\n```csharp\nusing (var youTubeTranscriptApi = new YouTubeTranscriptApi())\n{\n    var transcriptItems = youTubeTranscriptApi.GetTranscripts(video_ids, new[] { \"de\", \"en\" });\n}\n```\n\n`languages` also is optional here.\n\n### List available transcripts\n\nIf you want to list all transcripts which are available for a given video you can call:\n\n```csharp\nusing (var youTubeTranscriptApi = new YouTubeTranscriptApi())\n{\n    var transcriptList = youTubeTranscriptApi.ListTranscripts(video_id);\n}\n```\n\nThis will return a `TranscriptList` object  which is iterable and provides methods to filter the list of transcripts for specific languages and types, like:\n\n```csharp\nusing (var youTubeTranscriptApi = new YouTubeTranscriptApi())\n{\n    var transcript = transcriptList.FindTranscript(new[] { \"de\", \"en\" });\n}\n```\n\nBy default this module always picks manually created transcripts over automatically created ones, if a transcript in the requested language is available both manually created and generated. The `TranscriptList` allows you to bypass this default behaviour by searching for specific transcript types:\n\n```python\n# filter for manually created transcripts\ntranscript = transcript_list.find_manually_created_transcript(['de', 'en'])\n\n# or automatically generated ones\ntranscript = transcript_list.find_generated_transcript(['de', 'en'])\n```\n\nThe methods `find_generated_transcript`, `find_manually_created_transcript`, `find_generated_transcript` return `Transcript` objects. They contain metadata regarding the transcript:\n\n```python\nprint(\n    transcript.video_id,\n    transcript.language,\n    transcript.language_code,\n    # whether it has been manually created or generated by YouTube\n    transcript.is_generated,\n    # whether this transcript can be translated or not\n    transcript.is_translatable,\n    # a list of languages the transcript can be translated to\n    transcript.translation_languages,\n)\n```\n\nand provide the method, which allows you to fetch the actual transcript data:\n\n```python\ntranscript.fetch()\n```\n\n### Translate transcript\n\nYouTube has a feature which allows you to automatically translate subtitles. This module also makes it possible to access this feature. To do so `Transcript` objects provide a `translate()` method, which returns a new translated `Transcript` object:\n\n```python\ntranscript = transcript_list.find_transcript(['en'])\ntranslated_transcript = transcript.translate('de')\nprint(translated_transcript.fetch())\n```\n\n### By example\n```python\nfrom youtube_transcript_api import YouTubeTranscriptApi\n\n# retrieve the available transcripts\ntranscript_list = YouTubeTranscriptApi.list_transcripts('video_id')\n\n# iterate over all available transcripts\nfor transcript in transcript_list:\n\n    # the Transcript object provides metadata properties\n    print(\n        transcript.video_id,\n        transcript.language,\n        transcript.language_code,\n        # whether it has been manually created or generated by YouTube\n        transcript.is_generated,\n        # whether this transcript can be translated or not\n        transcript.is_translatable,\n        # a list of languages the transcript can be translated to\n        transcript.translation_languages,\n    )\n\n    # fetch the actual transcript data\n    print(transcript.fetch())\n\n    # translating the transcript will return another transcript object\n    print(transcript.translate('en').fetch())\n\n# you can also directly filter for the language you are looking for, using the transcript list\ntranscript = transcript_list.find_transcript(['de', 'en'])  \n\n# or just filter for manually created transcripts  \ntranscript = transcript_list.find_manually_created_transcript(['de', 'en'])  \n\n# or automatically generated ones  \ntranscript = transcript_list.find_generated_transcript(['de', 'en'])\n```\n\n### Using Formatters\nNot ported yet\n\n\n## CLI\n\nNot ported yet\n\n## Proxy\n\nYou can specify a https/http proxy, which will be used during the requests to YouTube:  \n\n```python  \nfrom youtube_transcript_api import YouTubeTranscriptApi  \n\nYouTubeTranscriptApi.get_transcript(video_id, proxies={\"http\": \"http://user:pass@domain:port\", \"https\": \"https://user:pass@domain:port\"})  \n```  \n\nAs the `proxies` dict is passed on to the `requests.get(...)` call, it follows the [format used by the requests library](http://docs.python-requests.org/en/master/user/advanced/#proxies).  \n\nUsing the CLI:\n\n```  \nyoutube_transcript_api \u003cfirst_video_id\u003e \u003csecond_video_id\u003e --http-proxy http://user:pass@domain:port --https-proxy https://user:pass@domain:port  \n```\n\n## Cookies\n\nSome videos are age restricted, so this module won't be able to access those videos without some sort of authentication. To do this, you will need to have access to the desired video in a browser. Then, you will need to download that pages cookies into a text file. You can use the Chrome extension [cookies.txt](https://chrome.google.com/webstore/detail/cookiestxt/njabckikapfpffapmjgojcnbfjonfjfg?hl=en) or the Firefox extension [cookies.txt](https://addons.mozilla.org/en-US/firefox/addon/cookies-txt/).\n\nOnce you have that, you can use it with the module to access age-restricted videos' captions like so.\n\n```python  \nfrom youtube_transcript_api import YouTubeTranscriptApi  \n\nYouTubeTranscriptApi.get_transcript(video_id, cookies='/path/to/your/cookies.txt')\n\nYouTubeTranscriptApi.get_transcripts([video_id], cookies='/path/to/your/cookies.txt')\n```\n\nUsing the CLI:\n\n```\nyoutube_transcript_api \u003cfirst_video_id\u003e \u003csecond_video_id\u003e --cookies /path/to/your/cookies.txt\n```\n\n\n## Warning\n\n This code uses an undocumented part of the YouTube API, which is called by the YouTube web-client. So there is no guarantee that it won't stop working tomorrow, if they change how things work. I will however do my best to make things working again as soon as possible if that happens. So if it stops working, let me know!  \n\n## Donation (oringal repos donation link)\n\nIf this project makes you happy by reducing your development time, you can make me happy by treating me to a cup of coffee :)  \n\n[![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=BAENLEW8VUJ6G\u0026source=url)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbobld%2Fyoutube-transcript-api-sharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbobld%2Fyoutube-transcript-api-sharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbobld%2Fyoutube-transcript-api-sharp/lists"}