【问题标题】:handling community flagged video in youtube API, python在 youtube API、python 中处理社区标记的视频
【发布时间】: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


【解决方案1】:

不熟悉 API,但它有什么功能可以检查视频是否可用?如果是这样,你可以简单地做一个 if 语句,如果视频不可用,它会跳过它

【讨论】:

    猜你喜欢
    • 2012-01-02
    • 2020-10-24
    • 1970-01-01
    • 2014-09-02
    • 2015-07-14
    • 2021-10-12
    • 2020-04-24
    • 2011-11-22
    • 2021-03-05
    相关资源
    最近更新 更多