<p>您要查找的<a href="https://developers.google.com/youtube/v3/docs/playlistItems#snippet.resourceId.videoId" rel="nofollow noreferrer">video ID</a>位于<code>response.items[0].snippet.resourceId.videoId</code>,而<a href="https://developers.google.com/youtube/v3/docs/playlistItems#snippet.publishedAt" rel="nofollow noreferrer">published date time</a>位于<code>response.items[0].snippet.publishedAt</code>。您的代码还应该检查<code>response.items</code>是否为空(出于某些原因)。你知道吗</p>
<hr/>
<p>另一方面,重申我之前的一个<a href="https://stackoverflow.com/a/56790376/8327971">answer</a>,我建议您注意这样一个事实,查询频道的上传列表的<a href="https://developers.google.com/youtube/v3/docs/playlistItems/list" rel="nofollow noreferrer">PlaylistItems endpoint</a>会生成一个<a href="https://developers.google.com/youtube/v3/docs/playlistItems/list#response" rel="nofollow noreferrer">items</a>列表,该列表按上传日期排序(最新的优先)。但是<a href="https://developers.google.com/youtube/v3/docs/playlistItems#resource" rel="nofollow noreferrer">items</a>本身包含附加的<a href="https://developers.google.com/youtube/v3/docs/videos#snippet.publishedAt" rel="nofollow noreferrer">publishedAt</a>datetime属性。你知道吗</p>
<blockquote>
<p><strong>publishedAt</strong> (datetime)</p>
<p>The date and time that the video was published. <em>Note that this time might be different than the time that the video was uploaded.</em> For example, if a video is uploaded as a private video and then made public at a later time, this property will specify the time that the video was made public.</p>
</blockquote>
<p>如果您想获得某个频道的<em>最新发布的</em>视频,您应该查询<a href="https://developers.google.com/youtube/v3/docs/search/list" rel="nofollow noreferrer">Search endpoint</a>,而是向它传递适当的参数:<code>channelId=...</code>、<code>maxResults=1</code>和<code>order=date</code>。你知道吗</p>
<hr/>
<p><strong>更新</strong>:根据<a href="https://github.com/youtube/api-samples/blob/master/python/my_uploads.py" rel="nofollow noreferrer">this</a>,<code>response.items[...].snippet.publishedAt</code>应该访问为:</p>
<pre><code>for item in response['items']:
publishedAt = item['snippet']['publishedAt']
# use publishedAt ...
</code></pre>