jdepoix / youtube-transcript-api

This is a python 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 an API key nor a headless browser, like other selenium based solutions do!
MIT License
2.54k stars 279 forks source link

youtube_transcript_api cli not working on some videos with a dash #295

Closed ax-sh closed 2 weeks ago

ax-sh commented 2 weeks ago

Video Url https://www.youtube.com/watch?v=-4L50dvXvLg

To Reproduce

Steps to reproduce the behavior:

# Run any video id starting with a dash

youtube_transcript_api -4L50dvXvLg

What code / cli command are you executing?

For example: I am running

youtube_transcript_api -4L50dvXvLg

# even tried with quotes

youtube_transcript_api "-4L50dvXvLg"

Which Python version are you using?

Python 3.12.2

Which version of youtube-transcript-api are you using?

youtube-transcript-api x.y.z

Expected behavior

I expected to receive the English transcript

Actual behavior

Its registering the video id for cli args

Expected behavior. Get the transcript of video

Instead I received the following error message:

usage: youtube_transcript_api [-h] [--list-transcripts] [--languages [LANGUAGES ...]] [--exclude-generated] [--exclude-manually-created] [--format {json,pretty,text,webvtt,srt}] [--translate TRANSLATE]
                              [--http-proxy URL] [--https-proxy URL] [--cookies COOKIES]
                              video_ids [video_ids ...]
youtube_transcript_api: error: the following arguments are required: video_ids
jdepoix commented 2 weeks ago

Hi @ax-sh, you'll have to escape the dash:

youtube_transcript_api "\-4L50dvXvLg"