我得到的输出是(缩短):
An HTTP error 400 occurred:\r\nb\'{\\n "error": {\\n "code": 400,\\n "message"
: "The \\\\u003ccode\\\\u003esnippet.categoryId\\\\u003c/code\\\\u003e property specif
ies an invalid category ID.
i使用卷曲来获得此API的类别ID,而42似乎是有效的:
{
"kind": "youtube#videoCategory",
"etag": "TxVSfGoUyT7CJ7h7ebjg4vhIt6g",
"id": "42",
"snippet": {
"title": "Shorts",
"assignable": false,
"channelId": "UCBR8-60-B28hp2BmDPdntcQ"
}
},
这是由“可分配”引起的:false行,还是其他东西?
您正确!这是因为对于类别ID 42的键“可分配”是错误的。使用this文档
我使用以下代码,并获得了与您相同的信息。
request = youtube_client.videoCategories().list(
part="snippet",
regionCode="US",
)
response = execute_request(request)
print(response)