api icon indicating copy to clipboard operation
api copied to clipboard

/v0/episodes offset 限制应该 -1

Open inchei opened this issue 8 months ago • 5 comments

若 offset 超出限制,会返回 offset should be less than or equal to {限制数量}。这个限制数量目前是集数,但第一集是 0,所以正确的限制数量是 集数-1。 例:https://api.bgm.tv/v0/episodes?subject_id=454684&limit=1&offset=13 ,返回的 data 是空数组,因为不存在这一集。

inchei avatar Apr 13 '25 08:04 inchei

没太理解,能举个例子再展开解释一下吗

trim21 avatar Apr 13 '25 09:04 trim21

这个例子的动画一共13集,offset 设置成 13 (https://api.bgm.tv/v0/episodes?subject_id=454684&limit=1&offset=13 )会返回空的结果,offset 设置成 14(https://api.bgm.tv/v0/episodes?subject_id=454684&limit=1&offset=14 )就会报错,其实 offset 13 也应该报错吧,因为没结果?

inchei avatar Apr 13 '25 09:04 inchei

现在我感觉可能其实都应该返回空结果,不应该额外检查一下offset的范围然后单独返回一个错误…

trim21 avatar Apr 13 '25 10:04 trim21

统一就好,还有limit限制了大于0,offset限制了大于等于0

inchei avatar Apr 13 '25 10:04 inchei

limit肯定大于0啊。 offset倒是可以考虑支持负数

trim21 avatar Apr 13 '25 10:04 trim21