Fix progress information error

pull/1/head
Hans362 5 years ago
parent d40a61626d
commit b77afa847e
Signed by: hans362
GPG Key ID: B186D77ABEC2A785

@ -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);
});

@ -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 <a class="bgm-item" href="'+a.url+'" target="_blank">\n <div class="bgm-item-thumb"\n style="background-image:url('+a.cover+')"></div>\n <div class="bgm-item-info">\n <span class="bgm-item-title main">'+a.title+'</span>\n <span class="bgm-item-title">'+a.title+'</span>\n <div class="bgm-item-statusBar-container">\n <div class="bgm-item-statusBar" style="width:'+i+'%"></div>\n 进度:'+a.follow_status+" / "+a.formal_ep_count+"\n </div>\n </div>\n </a>\n ")})});
/*! 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 <a class="bgm-item" href="'+t.url+'" target="_blank">\n <div class="bgm-item-thumb"\n style="background-image:url('+n+')"></div>\n <div class="bgm-item-info">\n <span class="bgm-item-title main">'+t.title+'</span>\n <span class="bgm-item-title">'+t.evaluate+'</span>\n <div class="bgm-item-statusBar-container">\n <div class="bgm-item-statusBar" style="width:'+a+'%"></div>\n 进度:'+e+" / "+s+"\n </div>\n </div>\n </a>\n ")})});

@ -3,6 +3,7 @@
<head>
<meta charset="UTF-8">
<title>Bilibili-Bangumi-JS</title>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.3.1"></script>
<link rel="stylesheet" href="dist/bilibili-bangumi.css">
</head>
@ -13,6 +14,10 @@
<script src="dist/bilibili-bangumi.js"></script>
<body>
<center>
<h1>Bilibili-Bangumi-JS</h1>
<h3>Render your Bilibili bangumi progress on a static web page</h3>
</center>
<div class="bgm-container">
<div class="bgm-collection" id="bgm-collection">

2
package-lock.json generated

@ -1,5 +1,5 @@
{
"name": "bilibili-bangumi-api",
"name": "bilibili-bangumi-js",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,

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

@ -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(`
<a class="bgm-item" href="${value.url}" target="_blank">
<div class="bgm-item-thumb"
style="background-image:url(${value.cover})"></div>
style="background-image:url(${cover})"></div>
<div class="bgm-item-info">
<span class="bgm-item-title main">${value.title}</span>
<span class="bgm-item-title">${value.title}</span>
<span class="bgm-item-title">${value.evaluate}</span>
<div class="bgm-item-statusBar-container">
<div class="bgm-item-statusBar" style="width:${percentage}%"></div>
进度${value.follow_status} / ${value.formal_ep_count}
进度${ep} / ${total}
</div>
</div>
</a>

Loading…
Cancel
Save