bangumi / api Goto Github PK
View Code? Open in Web Editor NEWBuild your app on Bangumi
Home Page: https://bangumi.github.io/api/
Build your app on Bangumi
Home Page: https://bangumi.github.io/api/
返回结果为
{ "subject_id": "id": int, // 3 "type": string, // "doing" "name": string // "在看" }, }
缺少subject的具体信息
参数中带responseGroup=medium / small / large 都是这样
已经带了app_id,请求头有token
主要原因应该跳转到登录页面后,地址中chii_referer参数里没有带redirect_uri?
在OAuth中,redirect_uri在现在看来似乎是个必须的参数?
最近在开发一个利用Bangumi数据推荐作品的推荐引擎,开发过程中遇到一些问题,需要新的API:
1. 请求Subject时应一并返回:标签、所有收藏者的UID、收藏类型、是否为限制性条目。
原因:推荐需要作品标签、其他人对该作品的评价来计算,同时对限制性条目需要有可选的屏蔽功能。
2. 需要有一次性读取多个Subject的API。
原因:由于需要缓存全站作品数据且频繁更新,一次读一个不管是对bangumi还是我这里压力都太大了。
3. 作品数据/用户数据更新时的回调
原因:同上,为了提高更新速度的同时减小Bangumi服务器压力。
4. 添加Tag相关API,包括:Tag搜索,列出全部Tag,按Tag搜索。
原因:方便按标签筛选作品
Bangumi Topic: https://bgm.tv/group/topic/348971
http请求图片,会连接重置。
如这个条目的图片是http,无法获取到,https就行了。
https://api.bgm.tv/subject/1671?responseGroup=large
export interface Weekday {
en: string;
cn: string;
ja: string; // 这里
id: number;
}
POST https://api.bgm.tv/ep/762301/status/watched
HEADER: {Accept: "application/json, text/plain, */*", Content-Type: "application/json;charset=utf-8", Authorization: "Bearer ***"}
BODY: {"ep_id":"762299,762300,762301"}
得到 {"request":"\/ep\/762301\/status\/watched","code":200,"error":"OK"}
但只有 762301 这一个章节被更新了
Bangumi API 本身的版本为必填项,怎么填?
文档中 /user/:username/collection
的 cat
参数 required 未打钩,实际不传的话不返回数据,应该是必填项?
目前 api.yml
里按 /subject/:subject_id
的 responseGroup 给条目定义了三个模型 SubjectSmall、SubjectMedium、SubjectLarge。但下列接口返回的条目数据都比 SubjectSmall 还小(没有 rating
和 rank
,summary
永远为空,有些缺少 eps_count
字段,air_date
和 air_weekday
数据也没的):
/user/:username/collection
/user/:username/collections/:subject_type
/user/:username/collections/status
/subject/:subject_id/ep
能否确定一个最小模型,至少包含的字段?
/user/:username/progress
返回的 css_name
是指什么?
/subject/:subject_id/update/watched_eps
文档中 watched_eps
是 required,watched_vols
不是,应该是必填其一吧?
SubjectLarge 里 blog 的 image 是什么意思?日志中的第一张?
访问 http://api.bgm.tv/user/1/collection 会返回空白html页面。
访问 http://api.bgm.tv/user/1/collection?cat=watching 没有问题。
文档中标为:“默认为在看”
但open API显示cat没有default值,并且是required
但实际上也不是完全required,因为有ids
被设置时不需要cat
请问怎么解决
/user/16433/collection?cat=all_watching&responseGroup=small
[
{
"name": "\u6589\u6728\u6960\u96c4\u306e\u03a8\u96e3 \u7b2c2\u671f",
"subject_id": "204027",
"ep_status": 7,
"vol_status": 0,
"lasttouch": 1519782126
}
]
期望 subject_id
为 integer 类型。
想要找动画制作却发现staff只有部分的数据
由于api.bgm.tv在cloudflare后,应用很容易因为请求过快撞到ddos保护,产生http 503。
需要api.bangumi.tv或api.chii.in一类无cdn的api访问地址。
当前我的解决方案:直接用bangumi.tv的ip,改主机头
现在只有在content-type
为multipart/form-data
或者application/x-www-form-urlencoded
的情况下,把status
做为body才能修改状态
无论是在content-type: application/json
的情况下做为body,还是放在queryString中均会导致状态变成wish
但是文档里 是直接放在url里的...
比如type=2为动画,希望能有一个变量分为TV,剧场版,OVA,其他
/collection/{subject_id}/{action} 管理收藏
这个api不能更新条目吗, 那这个status是干嘛用的
我想将某个条目更新为看过, 如 https://api.bgm.tv/collection/261805/update?status=watched
但实际会将这个条目改为wish(想看)状态
POST /subject/32585/update/watched_eps HTTP/1.1
Host: api.bgm.tv
Content-Type: application/x-www-form-urlencoded
Authorization: Bearer token
Cache-Control: no-cache
watched_eps=-1
会清空当前所有进度,感觉应该在文档里提一下
https://bgm.tv/ep/606388 是一集sp,其sort=1921.5
,但是同时本篇有2000+集,这时候如果post watched_eps=1921.5
会发生的事情是本篇进度更新到1921集,同时sp进度不更新。
即使设置本篇进度到一个比1921.5大的数字,比如1999,依然不会更新1921.5的进度。
同时,批量更新会导致当前用户的收视进度消失,比如用户标注sort=2000
为看过,如果使用post watched_eps=1999
更新进度,sort=2000
的收视进度会消失
另外的一个问题是,/subject/32585/ep 只会返回前1000集本篇的数据
固定IP长时间间断请求 search subject后会返回html并提示
“
呜咕,出错了
对不起,您在 秒内只能进行一次搜索,请返回。”
http://api.bgm.tv/user/h82258652/collections/anime
返回
{"request":"\/user\/h82258652\/collections\/anime","code":404,"error":"Error: APP ID Parameter is Missing"}
然而api文档中没有说明需要appid
GET https://api.bgm.tv/ep/{episode_id}
response:
{
"id": 1027,
"belong": ${subject_id}, # 或者subject_id做为key
"url": "http://bgm.tv/ep/1027",
"type": 0,
"sort": 1,
"name": "ちぃ 目覚める",
"name_cn": "叽,觉醒了",
"duration": "24m",
"airdate": "2002-04-03",
"comment": 9,
"desc": "string",
"status": "Air"
}
用户收藏概览 & 用户收藏统计的返回结构需要统一,请勿在生产环境中使用。
比如
{ request: '/subject/253/update/watched_eps',
code: 202,
error: 'Accepted' }
{ request: '/ep/7036/status/drop', code: 200, error: 'OK' }
把确认信息写在error
里很奇怪,容易造成一些lib跳转到catch里
It's confused returning a HTTP 200 OK
but an error in the response body.
当前此API只会返回
[
{
"subject_id": 0,
"eps": [
{
"id": 0,
"status": {
"id": 2,
"css_name": "Watched",
"url_name": "watched",
"cn_name": "看过"
}
}
]
}
条目的id和状态,如果想知道某话数的sort(第几集)和该话的名称则需要向/subject/{subject_id}
发送请求获取条目的详细话数信息,在用户同时观看多个条目时这就意味着需要对每个条目都请求一次subject的api(比如用户同时在看25个动画,需要至少请求收视进度API一次+请求25次subject api),无论对客户端还是服务器来说都属于很大的一笔额外负担,希望在请求/user/{username}/progress
后能返回sort和话数名称
I'm requesting MAL Sync to add support for Bangumi. According to the list of required APIs they provided, current APIs can already satisfy most requirements, except for listing all collection records of a user (#20) and (optionally) MAL ID for entries. Is there any plan to support these in the near future?
Ref: MALSync/MALSync#792
例如:请求https://api.bgm.tv/user/amtoaer/collection?cat=all_watching&responseGroup=medium
,返回结果为
[
{
"name": "ダーリン・イン・ザ・フランキス",
"subject_id": 218711,
"ep_status": 14,
"vol_status": 0,
"lasttouch": 1602213288,
"subject": {
"id": 218711,
"url": "http://bgm.tv/subject/218711",
"type": 2,
"name": "ダーリン・イン・ザ・フランキス",
"name_cn": "DARLING in the FRANXX",
"summary": "",
"eps": 24,
"eps_count": 24,
"air_date": "2018-01-13",
"air_weekday": 6,
"images": {
"large": "http://lain.bgm.tv/pic/cover/l/77/dd/218711_5Z5t1.jpg",
"common": "http://lain.bgm.tv/pic/cover/c/77/dd/218711_5Z5t1.jpg",
"medium": "http://lain.bgm.tv/pic/cover/m/77/dd/218711_5Z5t1.jpg",
"small": "http://lain.bgm.tv/pic/cover/s/77/dd/218711_5Z5t1.jpg",
"grid": "http://lain.bgm.tv/pic/cover/g/77/dd/218711_5Z5t1.jpg"
},
"collection": {
"doing": 1530
}
}
},
{
"name": "半沢直樹",
"subject_id": 108596,
"ep_status": 4,
"vol_status": 0,
"lasttouch": 1602212615,
"subject": {
"id": 108596,
"url": "http://bgm.tv/subject/108596",
"type": 6,
"name": "半沢直樹",
"name_cn": "半泽直树 2",
"summary": "",
"eps": 10,
"eps_count": 10,
"air_date": "2020-07-19",
"air_weekday": 7,
"images": {
"large": "http://lain.bgm.tv/pic/cover/l/79/8a/108596_U15B6.jpg",
"common": "http://lain.bgm.tv/pic/cover/c/79/8a/108596_U15B6.jpg",
"medium": "http://lain.bgm.tv/pic/cover/m/79/8a/108596_U15B6.jpg",
"small": "http://lain.bgm.tv/pic/cover/s/79/8a/108596_U15B6.jpg",
"grid": "http://lain.bgm.tv/pic/cover/g/79/8a/108596_U15B6.jpg"
},
"collection": {
"doing": 187
}
}
}
]
{
"id": 239912,
"url": "http://bgm.tv/subject/239912",
"type": 2,
"name": "キャロル&チューズデイ",
"name_cn": "CAROLE & TUESDAY",
"summary": "",
"air_date": "2019-04-10",
"air_weekday": 3,
"rating": {
"total": 635,
"count": {
"1": 5,
"2": 0,
"3": 0,
"4": 3,
"5": 12,
"6": 38,
"7": 116,
"8": 305,
"9": 111,
"10": 45
},
"score": 7.9
},
"rank": 347,
"images": {
"large": "http://lain.bgm.tv/pic/cover/l/50/aa/239912_z34n4.jpg",
"common": "http://lain.bgm.tv/pic/cover/c/50/aa/239912_z34n4.jpg",
"medium": "http://lain.bgm.tv/pic/cover/m/50/aa/239912_z34n4.jpg",
"small": "http://lain.bgm.tv/pic/cover/s/50/aa/239912_z34n4.jpg",
"grid": "http://lain.bgm.tv/pic/cover/g/50/aa/239912_z34n4.jpg"
},
"collection": {
"doing": 2213
}
},
客户端可以增加删除收藏的功能。这样如果用户不小心把一个并不想看的番标记了想看,可以删除这个标记。
比如海贼王的这个,返回的数据已经很大了,但有些情况下用不到这么多的数据
Request:
GET /user/396795/collections/book?app_id=bgm545a962720a5fcb HTTP/1.1
Accept-Encoding: gzip, deflate
Authorization: Bearer ******
Host: api.bgm.tv
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: chii_sid=EDllb5; chii_sid=MltUhK; __cfduid=d166e8895504316ddd65946c1bf1f40ac1519801548
Response:
HTTP/1.1 200 OK
Date: Mon, 11 Jun 2018 10:25:47 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Set-Cookie: chii_sid=0L0w0n; expires=Mon, 18-Jun-2018 10:25:47 GMT; path=/
Expires: Mon, 11 Jun 2018 11:25:47GMT
Cache-Control: max-age=3600
Vary: Accept-Encoding
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 4293602bcf1a995b-LAX
Content-Length: 4
null
使用浏览器请求时:
Request:
GET /user/396795/collections/book?app_id=bgm545a962720a5fcb HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/17.17134
Accept-Encoding: gzip, deflate, br
Host: api.bgm.tv
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: chii_sid=XXQCea; chii_sid=IZXJXP; chii_cookietime=2592000; chii_auth=******; __cfduid=d8a07b1e4b2436bfadce9d0d763a1f9c21519804036
Response:
HTTP/1.1 200 OK
Date: Mon, 11 Jun 2018 10:38:09 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Set-Cookie: chii_sid=gIGcia; expires=Mon, 18-Jun-2018 10:38:09 GMT; path=/
Expires: Mon, 11 Jun 2018 11:38:09GMT
Cache-Control: max-age=3600
Vary: Accept-Encoding
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 4293724ddb14997f-LAX
Content-Length: 1348
[{"type":1,"name":"book","name_cn":"\u4e66\u7c4d","collects":[{"status":{"id":3,"type":"do","name":"\u5728\u8bfb"},"count":1,"list":[{"subject_id":9093,"subject":{"id":9093,"url":"http:\/\/bgm.tv\/subject\/9093","type":1,"name":"SLAM DUNK \u5b8c\u5168\u7248 (01)","name_cn":"","summary":"","air_date":"","air_weekday":0,"images":{"large":"http:\/\/lain.bgm.tv\/pic\/cover\/l\/7b\/ea\/9093_jp.jpg","common":"http:\/\/lain.bgm.tv\/pic\/cover\/c\/7b\/ea\/9093_jp.jpg","medium":"http:\/\/lain.bgm.tv\/pic\/cover\/m\/7b\/ea\/9093_jp.jpg","small":"http:\/\/lain.bgm.tv\/pic\/cover\/s\/7b\/ea\/9093_jp.jpg","grid":"http:\/\/lain.bgm.tv\/pic\/cover\/g\/7b\/ea\/9093_jp.jpg"}}}]},{"status":{"id":2,"type":"collect","name":"\u8bfb\u8fc7"},"count":1,"list":[{"subject_id":18462,"subject":{"id":18462,"url":"http:\/\/bgm.tv\/subject\/18462","type":1,"name":"SLAM DUNK \u5b8c\u5168\u7248","name_cn":"\u704c\u7bee\u9ad8\u624b \u5b8c\u5168\u7248","summary":"","air_date":"","air_weekday":0,"images":{"large":"http:\/\/lain.bgm.tv\/pic\/cover\/l\/92\/46\/18462_r2N1o.jpg","common":"http:\/\/lain.bgm.tv\/pic\/cover\/c\/92\/46\/18462_r2N1o.jpg","medium":"http:\/\/lain.bgm.tv\/pic\/cover\/m\/92\/46\/18462_r2N1o.jpg","small":"http:\/\/lain.bgm.tv\/pic\/cover\/s\/92\/46\/18462_r2N1o.jpg","grid":"http:\/\/lain.bgm.tv\/pic\/cover\/g\/92\/46\/18462_r2N1o.jpg"}}}]}]}]
缺少 Cookie chii_auth
和 UA 都会导致返回为 null
,Authorization
头无效
请求 /subject/:id
在 responseGroup 为 medium/small 的时候,返回的 eps
字段为 number;
而 responseGroup 为 large 的时候,返回的 eps
字段为详细内容的 array。
期望能统一一下。
比如 small/medium 的的时候去掉 eps
而改为 eps_count
。(因为 user api 里也是用的 eps_count
http://api.bgm.tv/user/h82258652/collection?cat=watching&ids=202615,218711
应该只返回游戏王和FRANXX才对,但其它条目的信息也返回了
It is my suggestion that there should be a field in the returned data of /user/:username indicating that a user is prohibited.
目前看了一下大概是这样的几个类型,但没发现有5的类型.
1: ItemType.Book,
2: ItemType.Anime,
3: ItemType.Album,
4: ItemType.Game,
6: ItemType.RealWorld
我目前得到的是86400 (24h?), 那用户是不是要每天登录一次..
更新进度好像是 POST /subject/{subject_id}/update/watched_eps 但是没找到获取已有进度的..
/collection/190385/update
comment=&privacy=1&rating=5&status=do&tags=
{
"status": {
"id": 3,
"type": "do",
"name": null
},
"rating": 5,
"comment": "",
"private": 0,
"tag": [""],
"ep_status": 0,
"lasttouch": 1520498509,
"user": {
"id": 16433,
"url": "http:\/\/bgm.tv\/user\/ainopara",
"username": "ainopara",
"nickname": "ainopara",
"avatar": {
"large": "http:\/\/lain.bgm.tv\/pic\/user\/l\/000\/01\/64\/16433.jpg?r=1461302084",
"medium": "http:\/\/lain.bgm.tv\/pic\/user\/m\/000\/01\/64\/16433.jpg?r=1461302084",
"small": "http:\/\/lain.bgm.tv\/pic\/user\/s\/000\/01\/64\/16433.jpg?r=1461302084"
},
"sign": ""
}
}
private
字段的值应该反映更新后的状态。
/calendar
[
{
"weekday": {
"en": "Mon",
"cn": "\u661f\u671f\u4e00",
"ja": "\u6708\u8000\u65e5",
"id": 1
},
"items": [
{
"id": 217629,
"url": "http:\/\/bgm.tv\/subject\/217629",
"type": 0,
"name": "\u5f31\u866b\u30da\u30c0\u30eb GLORY LINE",
"name_cn": "\u98d9\u901f\u5b85\u7537 GLORY LINE",
"summary": "",
"air_date": "2018-01-08",
"air_weekday": 1,
"rating": {
"total": 19,
"count": {
"10": 0,
"9": 0,
"8": 6,
"7": 9,
"6": 4,
"5": 0,
"4": 0,
"3": 0,
"2": 0,
"1": 0
},
"score": 7.1
},
"images": {
"large": "http:\/\/lain.bgm.tv\/pic\/cover\/l\/a4\/2b\/217629_nAx7R.jpg",
"common": "http:\/\/lain.bgm.tv\/pic\/cover\/c\/a4\/2b\/217629_nAx7R.jpg",
"medium": "http:\/\/lain.bgm.tv\/pic\/cover\/m\/a4\/2b\/217629_nAx7R.jpg",
"small": "http:\/\/lain.bgm.tv\/pic\/cover\/s\/a4\/2b\/217629_nAx7R.jpg",
"grid": "http:\/\/lain.bgm.tv\/pic\/cover\/g\/a4\/2b\/217629_nAx7R.jpg"
},
"collection": {
"doing": 115
}
}
]
}
]
返回正确的 type 值。
比如 https://api.bgm.tv/user/yingchen/collection?cat=watching 返回的是 HTML 的 404 页面,而不是一个 json。虽然硬着头皮写也能处理,但 API 不应该返回 html 吧
/user/:username/collection/:subject_type
也是一样的情况
POST /collection/{subject_id}/update HTTP/1.1
Host: api.bgm.tv
Content-Type: application/x-www-form-urlencoded
Authorization: Bearer {token}
Cache-Control: no-cache
status=do&comment=test&tags=%F0%9F%98%8E+&rating=0&privacy=0
</table>
</table>
</table>
</table>
</table>
<p style="font-family: Verdana, Tahoma; font-size: 11px; background: #FFFFFF;">
<b>Chobits Said</b>: MySQL Query Error
<br />
<br />
<b>Time</b>: 2018-5-6 3:03pm
<br />
<b>Script</b>: /router.php
<br />
<br />
<b>Error</b>: Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation 'like'
<br />
<b>Errno.</b>: 1267
<br />
<br />An error report has been dispatched to our administrator.
</p>
和#26 类似的问题,期待返回一个json
顺便,文档里说此处description: 章节状态,参考 [EpStatusType](#model-EpStatusType)
是不正确的吧,应该参考的是CollectionStatusType
还有就是在根据文档设置status
为一些非法值(如watched
)后,会不提示参数错误而把条目状态重置为想看,并清除状态,感觉这个是不是也应该在文档里提一下...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.