【发布时间】:2020-10-18 03:30:50
【问题描述】:
videos = get_channel_videos("UCqnbDFdCpuN8CMEg0VuEBqA") # this just get all the video from the "upload" playlist of each channel
vidList = []
for i in videos:
vi = (i['snippet']['resourceId']['videoId'])
vidList.append(vi)
print(vidList); len(vidList)
captions = []
for id in vidList:
sub = YouTubeTranscriptApi.get_transcript(id)
captions.append(sub)
print(captions);len(captions)
我收到以下错误,因为新闻视频被社区标记。
VideoUnavailable:
Could not retrieve a transcript for the video https://www.youtube.com/watch?v=vksEJR9EPQ8!
This is most likely caused by:
The video is no longer available
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!
我尝试在每个 videoID 后面加上 &bpctr=9999999999 以绕过不适当的视频限制。但是,该函数添加了一个“!”到每个搞砸的网址的末尾。
【问题讨论】:
-
你不能把它包装在一个 try/except 块中吗?
-
您能否详细说明或链接一个示例。我确实需要所有的字幕,我不想跳过它们。
-
如果它们不可用,您似乎别无选择。您需要发现错误并跳过这些视频。
-
视频实际上是可用的:youtube.com/watch?v=vksEJR9EPQ8 他们只是隐藏在这个“我理解并希望继续”点击之后,它会在 URL 中添加一个 &bpctr=9999999999。
标签: python youtube-api