YouTube Data API v3:如何按日期过滤所有用户的视频?

时间:2018-05-14 17:03:04

标签: youtube-api youtube-data-api

我正在尝试获取已在特定日期范围内上传的经过身份验证的用户视频的列表,无论状态如何(私有,不公开,公开等等)。查看API文档,它似乎接受日期作为查询参数的唯一相关端点是/search/activities端点。

但是,在尝试使用这些端点的publishedAfterpublishedBefore参数时,响应仅包含公开视频。我已经尝试过设置已验证用户频道的mineforMine参数与channelId,但结果是相同的。此外,尝试将/search端点与publishedAfterpublishedBeforeforMine==true一起使用会返回400错误,指定无效的过滤器组合。

有没有办法通过API按日期过滤所有用户的视频?我查看了类似的问题,一般的回答是使用ordermaxResults在响应中进行过滤。我想尽可能避免这种情况,因为我的应用程序的潜在用户拥有相当多的视频(~10,000),这使得响应过滤成为一种非常低效的方法。

/search使用forMine==true和日期的示例请求:

https://www.googleapis.com/youtube/v3/search?access_token={token}&part=snippet&forMine=true&publishedAfter=2018-04-01T04:00:00.000Z&publishedBefore=2018-05-17T04:00:00.000Z&type=video

响应:

{
    "error": {
        "errors": [
            {
                "domain": "youtube.search",
                "reason": "invalidSearchFilter",
                "message": "The request contains an invalid combination of search filters and/or restrictions. Note that you must set the <code>type</code> parameter to <code>video</code> if you set either the <code>forContentOwner</code> or <code>forMine</code> parameters to <code>true</code>. You must also set the <code>type</code> parameter to <code>video</code> if you set a value for the <code>eventType</code>, <code>videoCaption</code>, <code>videoCategoryId</code>, <code>videoDefinition</code>, <code>videoDimension</code>, <code>videoDuration</code>, <code>videoEmbeddable</code>, <code>videoLicense</code>, <code>videoSyndicated</code>, or <code>videoType</code> parameters.",
                "locationType": "parameter",
                "location": ""
            }
        ],
        "code": 400,
        "message": "The request contains an invalid combination of search filters and/or restrictions. Note that you must set the <code>type</code> parameter to <code>video</code> if you set either the <code>forContentOwner</code> or <code>forMine</code> parameters to <code>true</code>. You must also set the <code>type</code> parameter to <code>video</code> if you set a value for the <code>eventType</code>, <code>videoCaption</code>, <code>videoCategoryId</code>, <code>videoDefinition</code>, <code>videoDimension</code>, <code>videoDuration</code>, <code>videoEmbeddable</code>, <code>videoLicense</code>, <code>videoSyndicated</code>, or <code>videoType</code> parameters."
    }
} 

没有publishedAfterpublishedBefore参数的同一请求会按预期返回所有用户的视频。

0 个答案:

没有答案
相关问题