Youtube API的subscriptions.list只显示很少的频道



所以我最近一直在玩Youtube API V3。我试图检索我账户中的所有订阅,为此我使用了他们网站上的代码示例,如下所示:

# -*- coding: utf-8 -*-
# Sample Python code for youtube.subscriptions.list
# See instructions for running these code samples locally:
# https://developers.google.com/explorer-help/code-samples#python
import os
import google_auth_oauthlib.flow
import googleapiclient.discovery
import googleapiclient.errors
scopes = ["https://www.googleapis.com/auth/youtube.readonly"]
def main():
# Disable OAuthlib's HTTPS verification when running locally.
# *DO NOT* leave this option enabled in production.
os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1"
api_service_name = "youtube"
api_version = "v3"
client_secrets_file = "YOUR_CLIENT_SECRET_FILE.json"
# Get credentials and create an API client
flow = google_auth_oauthlib.flow.InstalledAppFlow.from_client_secrets_file(
client_secrets_file, scopes)
credentials = flow.run_console()
youtube = googleapiclient.discovery.build(
api_service_name, api_version, credentials=credentials)
request = youtube.subscriptions().list(
part="snippet,contentDetails",
mine=True
)
response = request.execute()
print(response)
if __name__ == "__main__":
main()

虽然这很好,但它只检索5-6个频道的信息,而我订阅了200多个频道,我确保我也没有超过我的配额。有什么想法吗?

正如评论者所说,您需要实现分页。要按请求接收更多结果,您还可以将maxResults更改为50,而不是默认的5值(这就是为什么您只接收5-6个结果(。

最新更新