如何按评级订购 Youtube 视频? [英] How to order Youtube videos by rating?

查看:41
本文介绍了如何按评级订购 Youtube 视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 API 时遇到问题:https://developers.google.com/youtube/v3/docs/search/list#try-it.

我想按评分对我的结果进行排序.因此,我将order"参数的值设置为rating".作为返回的结果,我只收到喜欢和/或不喜欢的视频,而不是按评分排序.即使我只是在 API Explorer 中尝试,我也得到了相同的结果,所以这不可能是因为我的代码.

API 有问题还是我理解的评级"值有误?

解决方案

V3 API 返回的结果与您在 YouTube 网站上执行搜索并将排序依据"过滤器设置为评级"所获得的结果相同.

>

https://www.googleapis.com/youtube/v3/search/?q=stackoverflow&order=rating&part=snippethttps://www.youtube.com/results?search_sort=video_avg_rating&search_query=stackoverflow

关键在于它是一个平均评分,而不仅仅是基于喜欢.

API 将 getRating 定义为 -

<块引用>

检索授权用户对指定视频列表的评分.

所以看起来平均值考虑了好恶.目前还不清楚是否还使用了 1-5 评级系统(来自 YouTube V2 API)或任何其他数据?

如果您只想获得 like 计数,您可以使用您的视频 ID 发出另一个 API 请求,该请求返回 likedislikenoneunspecified -

https://www.googleapis.com/youtube/v3/videos/getRating?id=XXXXXXX,XXXXXXX

I've got a problem by using the API: https://developers.google.com/youtube/v3/docs/search/list#try-it.

I would like to order my results by rating. Therefore, I set the "order" parameter's value to "rating". As returned result, I just receive videos with low likes and/or dislikes and it is not ordered by rating. Even when I just try it in the API Explorer I get the same results, so it can't be because of my code.

Is there a problem with the API or do I understand the value "rating" wrong?

解决方案

The V3 API returns the same results you'd get by performing a search on the YouTube site and setting the 'Sort by' filter to Rating eg.

https://www.googleapis.com/youtube/v3/search/?q=stackoverflow&order=rating&part=snippet
https://www.youtube.com/results?search_sort=video_avg_rating&search_query=stackoverflow

The key point is that it's an average rating, not based only on likes.

The API defines getRating as -

Retrieves the ratings that the authorized user gave to a list of specified videos.

so it would seem the average takes into account likes and dislikes. It's not immediately clear whether the 1-5 rating system (from YouTube V2 API) or any other data is also used?

If you just wish to obtain the like count, you can make another API request with your video ID's that returns separate counts for like, dislike, none and unspecified -

https://www.googleapis.com/youtube/v3/videos/getRating?id=XXXXXXX,XXXXXXX

这篇关于如何按评级订购 Youtube 视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆