Python 3.x youtube api';s计数与检索到的项目数不匹配

Python 3.x youtube api';s计数与检索到的项目数不匹配,python-3.x,youtube-api,Python 3.x,Youtube Api,youtube的播放列表项目数似乎与播放列表中的实际项目数不匹配。这是有原因的还是我做错了什么 下面的代码返回以下内容: there are 1275 videos in the playlist we retrieved 1274 videos 密码,把你的钥匙放进去使用 import requests import json key = '' #Put your key here upload_playlist_id = 'UUG-Et3jfinzlQql4uEYjAVw' # Ge

youtube的播放列表项目数似乎与播放列表中的实际项目数不匹配。这是有原因的还是我做错了什么

下面的代码返回以下内容:

there are 1275 videos in the playlist 
we retrieved 1274 videos
密码,把你的钥匙放进去使用

import requests
import json

key = '' #Put your key here
upload_playlist_id = 'UUG-Et3jfinzlQql4uEYjAVw'

# Get the video count from the content details of the playlist
params = {
    'key' : key,
    'id' : upload_playlist_id,
    'part' : 'contentDetails'
}

response = requests.get(r'https://www.googleapis.com/youtube/v3/playlists', params)
data = json.loads(response.text)
video_count = data['items'][0]['contentDetails']['itemCount']
print("there are %s videos in the playlist " % (video_count))

# Get the video count from counting all of the items in the playlist
params = {
    'key' : key,
    'playlistId' : upload_playlist_id,
    'maxResults' : 50,
    'part' : 'id'
}
response = requests.get(r'https://www.googleapis.com/youtube/v3/playlistItems', params)
data_list = [json.loads(response.text)]

while 'nextPageToken' in data_list[-1]:
    params['pageToken'] = data_list[-1]['nextPageToken']
    response = requests.get(r'https://www.googleapis.com/youtube/v3/playlistItems', params)
    data_list.append(json.loads(response.text))

video_count = sum([len(page_data['items']) for page_data in data_list])
print("we retrieved %s videos" % (video_count))

我尝试获取您使用提供的
playliID
中的视频总数,结果得到1275个视频

下面是我用来获取播放ID“UUG-ET3JFINZLQL4UEYJAWW”的视频总数的查询

检查
“itemCount”
参数以检查视频总数

https://www.googleapis.com/youtube/v3/playlists?part=contentDetails&id=UUG-Et3jfinzlQql4uEYjAVw&key=YOUR_API_KEY

我试过了,问题是当你从播放列表中获取项目时,有1274个视频
itemCount
与实际计数不匹配。您所说的“从播放列表中获取项目时”是什么意思?你是说YouTube应用程序本身吗?不是API?