Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

Youtube Data API error: Subtitles are disabled for this video

$
0
0

Im trying to get the Title and transcript of all videos of a playlist:

from googleapiclient.discovery import buildfrom youtube_transcript_api import YouTubeTranscriptApiimport osapi_key = "*********************************"#1.query API rq = build("youtube", "v3", developerKey=api_key).playlistItems().list(        part="contentDetails, snippet",        playlistId="PL-osiE80TeTtoQCKZ03TU5fNfx2UY6U4p",        maxResults=50,                ).execute()#2.Create a list with video Ids and Titlesvid_ids = []vid_title = []for item in rq["items"]:    vid_ids.append(item["contentDetails"]["videoId"])    vid_title.append(item["snippet"]["title"])#3.Get transcriptssrt = YouTubeTranscriptApi.get_transcripts(vid_ids)print(srt)

But I get an error because one or more of those videos have no subtitles:

Could not retrieve a transcript for the video https://www.youtube.com/watch?v=D2lwk1Ukgz0! This is most likely caused by:Subtitles are disabled for this video

What would you code in python to avoid this error, and get the transcripts of at least the rest of the videos of the playlist? maybe an If Statement (if the video has no subtitles jump to the next one) or similar?

Thanks in advance.


Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>