【发布时间】:2021-06-27 10:43:12
【问题描述】:
我正在尝试获取内容所有者拥有的每个频道的总观看次数。
我可以获得所有频道的总观看次数,但我想获得每个频道的观看次数。
以下是我试过的代码。
我设置了dimensions=channel 来执行此操作,但它返回了 400 错误。
from googleapiclient.discovery import build
analytics_service = build("youtubeAnalytics", "v2", credentials=credentials)
report_result = analytics_service.reports().query(
ids= f'contentOwner=={owner_id}',
startDate='2020-12-01',
endDate='2021-03-30',
dimensions='channel', # <-- It raise the error.
metrics='views,comments,likes,dislikes',
filters='uploaderType==self',
).execute()
错误:
HttpError: <HttpError 400 when requesting https://youtubeanalytics.googleapis.com/v2/reports?ids=contentOwner%3D%3DkNuvRJ6GzXE5GEKbcUp7MA&startDate=2020-12-01&endDate=2021-03-30&dimensions=channel&metrics=views%2Ccomments%2Clikes%2Cdislikes&filters=uploaderType%3D%3Dself&maxResults=10&sort=-views&alt=json returned "The query is not supported. Check the documentation at https://developers.google.com/youtube/analytics/v2/available_reports for a list of supported queries.". Details: "The query is not supported. Check the documentation at https://developers.google.com/youtube/analytics/v2/available_reports for a list of supported queries.">
我查看了API 的文档,但找不到获取它的方法。
请告诉我你是否知道这样做的好方法。
谢谢。
【问题讨论】:
标签: python google-cloud-platform youtube youtube-api youtube-analytics-api