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!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Video Ids with dashes "-" fail using the CLI

eduardofcgo opened this issue · comments

I have noticed that the command line arguments are not being parsed correctly when the youtube video id contains the character -.
For example for the following video: https://www.youtube.com/watch?v=-FF_L54rvkk

To Reproduce

Steps to reproduce the behavior:

What code / cli command are you executing?

For example for the following video:

youtube_transcript_api "-FF_L54rvkk" --format srt

Which Python version are you using?

Python 3.8.10

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

youtube-transcript-api 0.6.2

Expected behavior

I expected to receive the transcript in SRT format, or at least recognize this valid command.

Actual behaviour

I received the following error message:

usage: youtube_transcript_api [-h] [--list-transcripts] [--languages [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

Hi @eduardofcgo, you'll have to escape the dash using \ like:

youtube_transcript_api "\-FF_L54rvkk" --format srt