From b77afa847e9b909ef528b014f9109ff91734763e Mon Sep 17 00:00:00 2001
From: Hans362
Date: Fri, 12 Feb 2021 11:01:34 +0800
Subject: [PATCH] :sparkles: Fix progress information error
---
api/index.js | 3 +--
dist/bilibili-bangumi.js | 2 +-
index.html | 5 +++++
package-lock.json | 2 +-
package.json | 4 ++--
src/bilibili-bangumi.js | 30 ++++++++++++++++++++++++++----
6 files changed, 36 insertions(+), 10 deletions(-)
diff --git a/api/index.js b/api/index.js
index 884e59e..3f34093 100644
--- a/api/index.js
+++ b/api/index.js
@@ -58,13 +58,12 @@ function getSuccess(data, res) {
}
app.get('/api', (req, res) => {
- const type = req.query.type || "1";
const pn = req.query.pn || "1";
const ps = req.query.ps || "20";
const vmid = req.query.vmid;
const userCookie = process.env.COOKIES || "No cookies.";
let URL = new Url();
- let apiPath = URL.getUrl("/x/space/bangumi/follow/list", { type: type, pn: pn, ps: ps, vmid: vmid });
+ let apiPath = URL.getUrl("/x/space/bangumi/follow/list", { type: "1", follow_status: "0", pn: pn, ps: ps, vmid: vmid });
nodePostGetRequest(apiHost, 80, 'GET', null, getSuccess, apiPath, userCookie, res);
});
diff --git a/dist/bilibili-bangumi.js b/dist/bilibili-bangumi.js
index 663dbe0..1cf0a1c 100644
--- a/dist/bilibili-bangumi.js
+++ b/dist/bilibili-bangumi.js
@@ -1 +1 @@
-/*! Bilibili-Bangumi-API v1.0.0 | Hans362 (https://hans362.cn) | https://bilibili-bangumi-api.vercel.app | MIT License */"use strict";var bangumiJson=(apiUrl||"https://bilibili-bangumi-api.vercel.app/api")+"?vmid="+userId+"&token="+(new Date).getTime()+Math.random();$.getJSON(bangumiJson,function(t){$.each(t.data.list,function(t,a){var i=a.follow_status/a.formal_ep_count*100;$("#bgm-collection").append('\n \n \n \n
'+a.title+'\n
'+a.title+'\n
\n
\n 进度:'+a.follow_status+" / "+a.formal_ep_count+"\n
\n
\n \n ")})});
\ No newline at end of file
+/*! Bilibili-Bangumi-API v1.0.0 | Hans362 (https://hans362.cn) | https://bilibili-bangumi-api.vercel.app | MIT License */"use strict";var bangumiJson=(apiUrl||"https://bilibili-bangumi-api.vercel.app/api")+"?vmid="+userId+"&token="+(new Date).getTime()+Math.random();$.getJSON(bangumiJson,function(i){$.each(i.data.list,function(i,t){var s=0;t.is_finish?s=t.total_count:t.is_started&&"即将开播"!=t.new_ep.index_show?(s=t.new_ep.title,$.isNumeric(s)||(s=t.total_count)):s=0,s<0&&(s=0);var e=0;t.is_started?0<=t.progress.indexOf("已看完")?e=s:void 0!==t.progress&&-1==t.progress.indexOf("PV")?(e=t.progress.substring(t.progress.indexOf("第")+1,t.progress.indexOf("话")),$.isNumeric(e)||(e=s)):e=0:e=0;var a=e/s*100,n=t.cover.replace("http","https");$("#bgm-collection").append('\n \n \n \n
'+t.title+'\n
'+t.evaluate+'\n
\n
\n \n ")})});
\ No newline at end of file
diff --git a/index.html b/index.html
index c0b013e..7bb3f3e 100644
--- a/index.html
+++ b/index.html
@@ -3,6 +3,7 @@
+ Bilibili-Bangumi-JS
@@ -13,6 +14,10 @@
+
+ Bilibili-Bangumi-JS
+ Render your Bilibili bangumi progress on a static web page
+
diff --git a/package-lock.json b/package-lock.json
index 1869a90..53c989c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,5 +1,5 @@
{
- "name": "bilibili-bangumi-api",
+ "name": "bilibili-bangumi-js",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
diff --git a/package.json b/package.json
index 47ce4a2..9d9e7b6 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
- "name": "bilibili-bangumi-api",
+ "name": "bilibili-bangumi-js",
"version": "1.0.0",
- "description": "Render your Bilibili bangumi list on a web page",
+ "description": "Render your Bilibili bangumi progress on a static web page",
"main": "api/index.js",
"scripts": {
"start": "node api/index.js"
diff --git a/src/bilibili-bangumi.js b/src/bilibili-bangumi.js
index 4b79476..8389f85 100644
--- a/src/bilibili-bangumi.js
+++ b/src/bilibili-bangumi.js
@@ -2,17 +2,39 @@ var bangumiJson = (apiUrl || "https://bilibili-bangumi-api.vercel.app/api") + "?
$.getJSON(bangumiJson, function (data) {
$.each(data.data.list, function (index, value) {
- var percentage = value.follow_status / value.formal_ep_count * 100;
+ var total = 0;
+ if (value.is_finish) {
+ total = value.total_count;
+ } else if (!value.is_started || value.new_ep.index_show == '即将开播') {
+ total = 0;
+ } else {
+ total = value.new_ep.title;
+ if (!$.isNumeric(total)) total = value.total_count;
+ }
+ if (total < 0) total = 0;
+ var ep = 0;
+ if (!value.is_started) {
+ ep = 0;
+ } else if (value.progress.indexOf('已看完') >= 0) {
+ ep = total;
+ } else if (typeof value.progress !== 'undefined' && value.progress.indexOf('PV') == -1) {
+ ep = value.progress.substring(value.progress.indexOf('第') + 1, value.progress.indexOf('话'));
+ if (!$.isNumeric(ep)) ep = total;
+ } else {
+ ep = 0;
+ }
+ var percentage = ep / total * 100;
+ var cover = value.cover.replace('http','https');
$("#bgm-collection").append(`
+ style="background-image:url(${cover})">
${value.title}
-
${value.title}
+
${value.evaluate}
- 进度:${value.follow_status} / ${value.formal_ep_count}
+ 进度:${ep} / ${total}