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

Problem in downloading translated language

MammadTavakoli opened this issue · comments

DO NOT DELETE THIS! Please take the time to fill this out properly. I am not able to help you if I do not know what you are executing and what error messages you are getting. If you are having problems with a specific video make sure to include the video id.

To Reproduce

Steps to reproduce the behavior:

What code / cli command are you executing?

I want downlaod a subtile except englosh for a video in colab:

video_id = "Sp3L1wP1urs"
YouTubeTranscriptApi.get_transcript(video_id, languages=['de'])

Which Python version are you using?

Python 3.10.12

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

youtube-transcript-api 0.6.2

Expected behavior

I want it download every translated transcript in the youtube for a video

Actual behaviour

Instead I received the following error message:

NoTranscriptFound                         Traceback (most recent call last)
[<ipython-input-18-b4b43278cb7a>](https://localhost:8080/#) in <cell line: 2>()
      1 video_id = "Sp3L1wP1urs"
----> 2 YouTubeTranscriptApi.get_transcript(video_id, languages=['de'])

2 frames
[/usr/local/lib/python3.10/dist-packages/youtube_transcript_api/_transcripts.py](https://localhost:8080/#) in _find_transcript(self, language_codes, transcript_dicts)
    217                     return transcript_dict[language_code]
    218 
--> 219         raise NoTranscriptFound(
    220             self.video_id,
    221             language_codes,

NoTranscriptFound: 
Could not retrieve a transcript for the video https://www.youtube.com/watch?v=Sp3L1wP1urs! This is most likely caused by:

No transcripts were found for any of the requested language codes: ['de']

For this video (Sp3L1wP1urs) transcripts are available in the following languages:

(MANUALLY CREATED)
None

(GENERATED)
 - en ("English (auto-generated)")[TRANSLATABLE]

(TRANSLATION LANGUAGES)
 - af ("Afrikaans")
 - ak ("Akan")
 - sq ("Albanian")
 - am ("Amharic")
 - ar ("Arabic")
 - hy ("Armenian")
 - as ("Assamese")
 - ay ("Aymara")
 - az ("Azerbaijani")
 - bn ("Bangla")
 - eu ("Basque")
 - be ("Belarusian")
 - bho ("Bhojpuri")
 - bs ("Bosnian")
 - bg ("Bulgarian")
 - my ("Burmese")
 - ca ("Catalan")
 - ceb ("Cebuano")
 - zh-Hans ("Chinese (Simplified)")
 - zh-Hant ("Chinese (Traditional)")
 - co ("Corsican")
 - hr ("Croatian")
 - cs ("Czech")
 - da ("Danish")
 - dv ("Divehi")
 - nl ("Dutch")
 - en ("English")
 - eo ("Esperanto")
 - et ("Estonian")
 - ee ("Ewe")
 - fil ("Filipino")
 - fi ("Finnish")
 - fr ("French")
 - gl ("Galician")
 - lg ("Ganda")
 - ka ("Georgian")
 - de ("German")
 - el ("Greek")
 - gn ("Guarani")
 - gu ("Gujarati")
 - ht ("Haitian Creole")
 - ha ("Hausa")
 - haw ("Hawaiian")
 - iw ("Hebrew")
 - hi ("Hindi")
 - hmn ("Hmong")
 - hu ("Hungarian")
 - is ("Icelandic")
 - ig ("Igbo")
 - id ("Indonesian")
 - ga ("Irish")
 - it ("Italian")
 - ja ("Japanese")
 - jv ("Javanese")
 - kn ("Kannada")
 - kk ("Kazakh")
 - km ("Khmer")
 - rw ("Kinyarwanda")
 - ko ("Korean")
 - kri ("Krio")
 - ku ("Kurdish")
 - ky ("Kyrgyz")
 - lo ("Lao")
 - la ("Latin")
 - lv ("Latvian")
 - ln ("Lingala")
 - lt ("Lithuanian")
 - lb ("Luxembourgish")
 - mk ("Macedonian")
 - mg ("Malagasy")
 - ms ("Malay")
 - ml ("Malayalam")
 - mt ("Maltese")
 - mi ("Māori")
 - mr ("Marathi")
 - mn ("Mongolian")
 - ne ("Nepali")
 - nso ("Northern Sotho")
 - no ("Norwegian")
 - ny ("Nyanja")
 - or ("Odia")
 - om ("Oromo")
 - ps ("Pashto")
 - fa ("Persian")
 - pl ("Polish")
 - pt ("Portuguese")
 - pa ("Punjabi")
 - qu ("Quechua")
 - ro ("Romanian")
 - ru ("Russian")
 - sm ("Samoan")
 - sa ("Sanskrit")
 - gd ("Scottish Gaelic")
 - sr ("Serbian")
 - sn ("Shona")
 - sd ("Sindhi")
 - si ("Sinhala")
 - sk ("Slovak")
 - sl ("Slovenian")
 - so ("Somali")
 - st ("Southern Sotho")
 - es ("Spanish")
 - su ("Sundanese")
 - sw ("Swahili")
 - sv ("Swedish")
 - tg ("Tajik")
 - ta ("Tamil")
 - tt ("Tatar")
 - te ("Telugu")
 - th ("Thai")
 - ti ("Tigrinya")
 - ts ("Tsonga")
 - tr ("Turkish")
 - tk ("Turkmen")
 - uk ("Ukrainian")
 - ur ("Urdu")
 - ug ("Uyghur")
 - uz ("Uzbek")
 - vi ("Vietnamese")
 - cy ("Welsh")
 - fy ("Western Frisian")
 - xh ("Xhosa")
 - yi ("Yiddish")
 - yo ("Yoruba")
 - zu ("Zulu")

If you are sure that the described cause is not responsible for this error and that a transcript should be retrievable, please create an issue at https://github.com/jdepoix/youtube-transcript-api/issues. Please add which version of youtube_transcript_api you are using and provide the information needed to replicate the error. Also make sure that there are no open issues which already describe your problem!

Hi @MammadTavakoli,

you're trying to fetch a german transcript and, as the error message indicates, there is none (only automatically generated en transcript).

I will close this now as there doesn't seem to be an issue here.

Hi @jdepoix
How can download translated subtitle? with yt-dlp I can do that?

Please read the README. It's all documented there.