Code Monkey home page Code Monkey logo

api's Issues

批量更新收视进度无法更新sp集数进度并且会导致用户当前进度丢失

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集本篇的数据

需要无cdn版本的api.bgm.tv

由于api.bgm.tv在cloudflare后,应用很容易因为请求过快撞到ddos保护,产生http 503。
需要api.bangumi.tv或api.chii.in一类无cdn的api访问地址。

当前我的解决方案:直接用bangumi.tv的ip,改主机头

name_cn和name字段应该进行html unescape

{
"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
}
},

每日放送 API 返回的 type 值始终为 0

Request

/calendar

Response

[
  {
    "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 值。

请求多个新API,及现有API扩充

最近在开发一个利用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

章节数据、用户收藏等api返回的数据中summary项为空

例如:请求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
      }
    }
  }
]

希望增加删除收藏的 API

客户端可以增加删除收藏的功能。这样如果用户不小心把一个并不想看的番标记了想看,可以删除这个标记。

希望/user/{username}/progress 用户收视进度api能返回更多信息

当前此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和话数名称

Progress end point 返回 2xx “错误”

比如

{ request: '/subject/253/update/watched_eps',
  code: 202,
  error: 'Accepted' }
{ request: '/ep/7036/status/drop', code: 200, error: 'OK' }

把确认信息写在error里很奇怪,容易造成一些lib跳转到catch里

Subject api 的 eps 字段类型不确定

请求 /subject/:id

在 responseGroup 为 medium/small 的时候,返回的 eps 字段为 number;
而 responseGroup 为 large 的时候,返回的 eps 字段为详细内容的 array。

期望能统一一下。
比如 small/medium 的的时候去掉 eps 而改为 eps_count。(因为 user api 里也是用的 eps_count

/user/{username}/collections/{subject_type} 依赖 User-Agent 和 Cookie

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 都会导致返回为 nullAuthorization 头无效

[feature request]: 直接获取单集信息的接口

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"
    }

无法批量更新章节状态

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 这一个章节被更新了

Open API 中的 TODO 事项

  1. Bangumi API 本身的版本为必填项,怎么填?

  2. 文档中 /user/:username/collectioncat 参数 required 未打钩,实际不传的话不返回数据,应该是必填项?

  3. 目前 api.yml 里按 /subject/:subject_id 的 responseGroup 给条目定义了三个模型 SubjectSmall、SubjectMedium、SubjectLarge。但下列接口返回的条目数据都比 SubjectSmall 还小(没有 ratingranksummary 永远为空,有些缺少 eps_count 字段,air_dateair_weekday 数据也没的):

    • /user/:username/collection
    • /user/:username/collections/:subject_type
    • /user/:username/collections/status
    • /subject/:subject_id/ep

    能否确定一个最小模型,至少包含的字段?

  4. /user/:username/progress 返回的 css_name 是指什么?

  5. /subject/:subject_id/update/watched_eps 文档中 watched_eps 是 required,watched_vols 不是,应该是必填其一吧?

  6. SubjectLarge 里 blog 的 image 是什么意思?日志中的第一张?

`管理收藏`api的实际行为与文档不符

现在只有在content-typemultipart/form-data 或者application/x-www-form-urlencoded的情况下,把status做为body才能修改状态

无论是在content-type: application/json的情况下做为body,还是放在queryString中均会导致状态变成wish

但是文档里 是直接放在url里的...

tags里有特殊字符(如emoji)时会返回html&相关文档描述的改进

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)后,会不提示参数错误而把条目状态重置为想看,并清除状态,感觉这个是不是也应该在文档里提一下...

更新收藏 response 中的 privacy 字段始终返回 0

Request

/collection/190385/update

Request Body

comment=&privacy=1&rating=5&status=do&tags=

Response

{
	"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 字段的值应该反映更新后的状态。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.