Updated Readme to include how to use cookies with the module

This commit is contained in:
danielcliu 2020-01-15 22:48:26 -08:00
parent 02b1978217
commit dc9fc2ee93
1 changed files with 13 additions and 1 deletions

View File

@ -214,7 +214,19 @@ Using the CLI:
```
youtube_transcript_api <first_video_id> <second_video_id> --http-proxy http://user:pass@domain:port --https-proxy https://user:pass@domain:port
```
## Cookies
Some 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/).
Once you have that, you can use it with the module to access age-restricted videos' captions like so.
```python
from youtube_transcript_api import YouTubeTranscriptApi
YouTubeTranscriptApi.get_transcript(video_id, cookies=<string of path to your cookies text file>)
YouTubeTranscriptApi.get_transcripts([video_id], cookies=<string of path to your cookies text file>)
```
## Warning