YouTube数据API – 如何从多个视频ID获取视频评论

huangapple go评论58阅读模式
英文:

Youtube Data API - How to get video comments from multiple video id

问题

I can help you with the translation. Here's the translated text:

有没有办法使用YouTube API从多个视频ID获取YouTube评论列表?

这是我的视频ID

video_ids = [
    'QSWYyoF79oE',
    'Wh66ThpxvI4',
    'weG-sqHHCB8',
    '8dgEh5crj0I',
    'SydRcrZ166A',
    'Svz5F8J1Ap0',
    'Lj_zPn3GsjE',
    'g89VhNDBrsY',
]

我尝试了这样使用

request = youtube.commentThreads().list(part='snippet,replies', videoId= ','.join(video_ids), maxResults=50)
response = request.execute()

这是响应,仍然出现错误。是否有解决方案或其他方法?

返回错误信息"通过<code><a href="/youtube/v3/docs/commentThreads/list#videoId">videoId</a></code>参数标识的视频无法找到。详细信息:"[{‘message’: ‘通过<code><a href="/youtube/v3/docs/commentThreads/list#videoId">videoId</a></code>参数标识的视频无法找到。’, ‘domain’: ‘youtube.commentThread’, ‘reason’: ‘videoNotFound’, ‘location’: ‘videoId’, ‘locationType’: ‘parameter’}]"

Is there anything else you would like to translate?

英文:

is there a way to get list of Youtube Comment using Youtube API from multiple video id?

This is my video id

video_ids = [
    &#39;QSWYyoF79oE&#39;, 
    &#39;Wh66ThpxvI4&#39;, 
    &#39;weG-sqHHCB8&#39;, 
    &#39;8dgEh5crj0I&#39;, 
    &#39;SydRcrZ166A&#39;, 
    &#39;Svz5F8J1Ap0&#39;, 
    &#39;Lj_zPn3GsjE&#39;, 
    &#39;g89VhNDBrsY&#39;, 
    ]

I tried using like this

request = youtube.commentThreads().list(part=&#39;snippet, replies&#39;, videoId= &#39;,&#39;.join(video_ids), maxResults = 50)
response = request.execute()

And this is the response, still error. Is there solution or other way?

returned &quot;The video identified by the &lt;code&gt;&lt;a href=&quot;/youtube/v3/docs/commentThreads/list#videoId&quot;&gt;videoId&lt;/a&gt;&lt;/code&gt; parameter could not be found.&quot;. Details: &quot;[{&#39;message&#39;: &#39;The video identified by the &lt;code&gt;&lt;a href=&quot;/youtube/v3/docs/commentThreads/list#videoId&quot;&gt;videoId&lt;/a&gt;&lt;/code&gt; parameter could not be found.&#39;, &#39;domain&#39;: &#39;youtube.commentThread&#39;, &#39;reason&#39;: &#39;videoNotFound&#39;, &#39;location&#39;: &#39;videoId&#39;, &#39;locationType&#39;: &#39;parameter&#39;}]&quot;&gt;```


</details>


# 答案1
**得分**: 1

你需要在HTTP请求之外进行迭代:

```python
for video_id in video_ids:
    request = youtube.commentThreads().list(part='snippet, replies', videoId=video_id, maxResults=50)
    response = request.execute()
英文:

You need to iterate outside the http request:

for video_id in video_ids:
    request = youtube.commentThreads().list(part=&#39;snippet, replies&#39;, videoId=video_id, maxResults = 50)
    response = request.execute()

huangapple
  • 本文由 发表于 2023年5月21日 04:06:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/76297148.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定