From 25d636c95f74b98a3aa2c1d5e4bb9ccdba4d413c Mon Sep 17 00:00:00 2001 From: HCLonely Date: Sun, 18 Aug 2024 15:33:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D:Bangumi=E6=BA=90=E5=8F=AA?= =?UTF-8?q?=E8=83=BD=E8=8E=B7=E5=8F=96=E7=AC=AC=E4=B8=80=E9=A1=B5(#499);?= =?UTF-8?q?=20>>=20=E6=96=B0=E5=A2=9E:`progressBar`=E9=80=89=E9=A1=B9?= =?UTF-8?q?=EF=BC=8C=E5=8F=AF=E9=85=8D=E7=BD=AE=E6=98=AF=E5=90=A6=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E8=BF=BD=E7=95=AA=E8=BF=9B=E5=BA=A6=E6=9D=A1(#499)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++++ lib/bangumi-generator.js | 3 ++- lib/get-bgm-data.js | 2 +- lib/templates/bangumi.ejs | 12 ++++++------ lib/templates/bgmv0-template.ejs | 2 +- lib/templates/bili-template.ejs | 2 +- package.json | 2 +- src/lib/bangumi-generator.js | 1 + src/lib/get-bgm-data.js | 2 +- 9 files changed, 18 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 2388ba8..9dde2f3 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ bangumi: # 追番设置 color: webp: progress: + progressBar: extraOrder: order: latest proxy: @@ -63,6 +64,7 @@ cinema: # 追剧设置 color: webp: progress: + progressBar: extraOrder: order: extra_options: @@ -84,6 +86,7 @@ game: # 游戏设置,仅支持source: bgmv0 color: webp: progress: + progressBar: extraOrder: order: extra_options: @@ -110,6 +113,7 @@ game: # 游戏设置,仅支持source: bgmv0 - **color**: 简介字体颜色 - **webp**: 番剧封面使用`webp`格式(此格式在`safari`浏览器下不显示,但是图片大小可以缩小 100 倍左右,仅支持哔哩哔哩源), 默认`true` - **progress**: 获取番剧数据时是否显示进度条,默认`true` +- **progressBar**: 追番页面是否显示进度条,默认`true`。仅支持`bili`和`bgmv0`数据源 - **extraOrder**: 手动添加的番剧/追剧数据是否优先显示,`1`为优先,其它为不优先 - **showMyComment**: 使用`bgm`源时显示自己的评价及评论,默认`false` - **pagination**: 分页优化,只将第一页的数据渲染到`html`文件中,其余数据将通过异步请求加载,避免番剧过多时html文件过大导致页面加载缓慢,建议番剧较多时使用,默认`false` diff --git a/lib/bangumi-generator.js b/lib/bangumi-generator.js index cddf80c..6c00383 100644 --- a/lib/bangumi-generator.js +++ b/lib/bangumi-generator.js @@ -22,7 +22,7 @@ var log = typeof hexoLog["default"] === 'function' ? hexoLog["default"]({ }); module.exports = /*#__PURE__*/function () { var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(locals) { - var _config$type, _config$type$lazyload, _config$type$source, _config$type$showMyCo, _config$type$paginati, _config$type2; + var _config$type, _config$type$lazyload, _config$type$source, _config$type$showMyCo, _config$type$paginati, _config$type$progress, _config$type2; var type, config, full_url_for, @@ -110,6 +110,7 @@ module.exports = /*#__PURE__*/function () { source: (_config$type$source = config[type].source) !== null && _config$type$source !== void 0 ? _config$type$source : 'bili', showMyComment: (_config$type$showMyCo = config[type].showMyComment) !== null && _config$type$showMyCo !== void 0 ? _config$type$showMyCo : false, pagination: (_config$type$paginati = config[type].pagination) !== null && _config$type$paginati !== void 0 ? _config$type$paginati : false, + progressBar: (_config$type$progress = config[type].progressBar) !== null && _config$type$progress !== void 0 ? _config$type$progress : true, theme: fs.existsSync(path.join(__dirname, "templates/theme/".concat(config.theme, ".min.css"))) ? config.theme : null, ejsTemplate: fs.readFileSync(path.join(__dirname, "templates/".concat(config[type].source === 'bili' ? 'bili' : config[type].source === 'bgmv0' ? 'bgmv0' : 'bgm', "-template.ejs"))).toString().replace('class="bangumi-item"', 'class="bangumi-item bangumi-hide"'), wantWatch: ['score', '-score'].includes(config[type].order) ? wantWatch.sort(function (a, b) { diff --git a/lib/get-bgm-data.js b/lib/get-bgm-data.js index 6540868..eb55635 100644 --- a/lib/get-bgm-data.js +++ b/lib/get-bgm-data.js @@ -403,7 +403,7 @@ var getItemsId = /*#__PURE__*/function () { return axios.get("https://".concat(host, "/").concat(type, "/list/").concat(vmid, "/").concat(status, "?page=1"), options); case 7: response = _context6.sent; - username = (_response$request$pat = response.request.path.match(/(anime|game)\/list\/(.*?)\//)) === null || _response$request$pat === void 0 ? void 0 : _response$request$pat[1]; + username = (_response$request$pat = response.request.path.match(/(anime|game)\/list\/(.*?)\//)) === null || _response$request$pat === void 0 ? void 0 : _response$request$pat[2]; if (username) { _context6.next = 11; break; diff --git a/lib/templates/bangumi.ejs b/lib/templates/bangumi.ejs index e3262f1..f4310af 100644 --- a/lib/templates/bangumi.ejs +++ b/lib/templates/bangumi.ejs @@ -28,12 +28,12 @@
<% if (pagination) { %> <% wantWatch.slice(0, 10).forEach(function(item){ %> - <%- include((source === 'bili' ? 'bili' : (source === 'bgmv0' ? 'bgmv0' : 'bgm')) + '-template.ejs', {item,loading,metaColor,type,lazyloadAttrName,srcValue}) %> + <%- include((source === 'bili' ? 'bili' : (source === 'bgmv0' ? 'bgmv0' : 'bgm')) + '-template.ejs', {item,loading,metaColor,type,lazyloadAttrName,srcValue,progressBar}) %> <% }); %> <%- include('pagination.ejs', {__: __}) %> <% } else { %> <% wantWatch.forEach(function(item){ %> - <%- include((source === 'bili' ? 'bili' : (source === 'bgmv0' ? 'bgmv0' : 'bgm')) + '-template.ejs', {item,loading,metaColor,type,lazyloadAttrName,srcValue}) %> + <%- include((source === 'bili' ? 'bili' : (source === 'bgmv0' ? 'bgmv0' : 'bgm')) + '-template.ejs', {item,loading,metaColor,type,lazyloadAttrName,srcValue,progressBar}) %> <% }); %> <%- include('pagination.ejs', {__: __}) %> <% } %> @@ -41,12 +41,12 @@
<% if (pagination) { %> <% watching.slice(0, 10).forEach(function(item){ %> - <%- include((source === 'bili' ? 'bili' : (source === 'bgmv0' ? 'bgmv0' : 'bgm')) + '-template.ejs', {item,loading,metaColor,type,lazyloadAttrName,srcValue}) %> + <%- include((source === 'bili' ? 'bili' : (source === 'bgmv0' ? 'bgmv0' : 'bgm')) + '-template.ejs', {item,loading,metaColor,type,lazyloadAttrName,srcValue,progressBar}) %> <% }); %> <%- include('pagination.ejs', {__: __}) %> <% } else { %> <% watching.forEach(function(item){ %> - <%- include((source === 'bili' ? 'bili' : (source === 'bgmv0' ? 'bgmv0' : 'bgm')) + '-template.ejs', {item,loading,metaColor,type,lazyloadAttrName,srcValue}) %> + <%- include((source === 'bili' ? 'bili' : (source === 'bgmv0' ? 'bgmv0' : 'bgm')) + '-template.ejs', {item,loading,metaColor,type,lazyloadAttrName,srcValue,progressBar}) %> <% }); %> <%- include('pagination.ejs', {__: __}) %> <% } %> @@ -54,12 +54,12 @@
<% if (pagination) { %> <% watched.slice(0, 10).forEach(function(item){ %> - <%- include((source === 'bili' ? 'bili' : (source === 'bgmv0' ? 'bgmv0' : 'bgm')) + '-template.ejs', {item,loading,metaColor,type,lazyloadAttrName,srcValue}) %> + <%- include((source === 'bili' ? 'bili' : (source === 'bgmv0' ? 'bgmv0' : 'bgm')) + '-template.ejs', {item,loading,metaColor,type,lazyloadAttrName,srcValue,progressBar}) %> <% }); %> <%- include('pagination.ejs', {__: __}) %> <% } else { %> <% watched.forEach(function(item){ %> - <%- include((source === 'bili' ? 'bili' : (source === 'bgmv0' ? 'bgmv0' : 'bgm')) + '-template.ejs', {item,loading,metaColor,type,lazyloadAttrName,srcValue}) %> + <%- include((source === 'bili' ? 'bili' : (source === 'bgmv0' ? 'bgmv0' : 'bgm')) + '-template.ejs', {item,loading,metaColor,type,lazyloadAttrName,srcValue,progressBar}) %> <% }); %> <%- include('pagination.ejs', {__: __}) %> <% } %> diff --git a/lib/templates/bgmv0-template.ejs b/lib/templates/bgmv0-template.ejs index ba3a180..81388ed 100644 --- a/lib/templates/bgmv0-template.ejs +++ b/lib/templates/bgmv0-template.ejs @@ -30,7 +30,7 @@
- <% if(item.type !=='游戏' ){ %> + <% if(item.type !=='游戏' && progressBar !== false){ %>
追番进度:<%= item.ep_status %>/<%= item.totalCount %>
diff --git a/lib/templates/bili-template.ejs b/lib/templates/bili-template.ejs index 469b563..cea7895 100644 --- a/lib/templates/bili-template.ejs +++ b/lib/templates/bili-template.ejs @@ -35,7 +35,7 @@
- <% if (item.progress !== false) { %> + <% if (item.progress !== false && progressBar !== false) { %>
追番进度:<%= item.ep_status %>/<%= item.new_ep %>
diff --git a/package.json b/package.json index 308d418..41b28f9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-bilibili-bangumi", - "version": "1.10.1", + "version": "1.10.2", "description": "hexo bilibili番剧页", "main": "index.js", "scripts": { diff --git a/src/lib/bangumi-generator.js b/src/lib/bangumi-generator.js index 8f99df3..44cb146 100644 --- a/src/lib/bangumi-generator.js +++ b/src/lib/bangumi-generator.js @@ -78,6 +78,7 @@ module.exports = async function (locals, type = 'bangumi') { source: config[type].source ?? 'bili', showMyComment: config[type].showMyComment ?? false, pagination: config[type].pagination ?? false, + progressBar: config[type].progressBar ?? true, theme: fs.existsSync(path.join(__dirname, `templates/theme/${config.theme}.min.css`)) ? config.theme : null, ejsTemplate: fs.readFileSync(path.join(__dirname, `templates/${config[type].source === 'bili' ? 'bili' : (config[type].source === 'bgmv0' ? 'bgmv0' : 'bgm')}-template.ejs`)).toString() .replace('class="bangumi-item"', 'class="bangumi-item bangumi-hide"'), diff --git a/src/lib/get-bgm-data.js b/src/lib/get-bgm-data.js index e1ff441..744136e 100644 --- a/src/lib/get-bgm-data.js +++ b/src/lib/get-bgm-data.js @@ -231,7 +231,7 @@ const getItemsId = async ({ vmid, type, status, showProgress, sourceDir, proxy, } const response = await axios.get(`https://${host}/${type}/list/${vmid}/${status}?page=1`, options); - const username = response.request.path.match(/(anime|game)\/list\/(.*?)\//)?.[1]; + const username = response.request.path.match(/(anime|game)\/list\/(.*?)\//)?.[2]; if (!username) { return console.error('Failed to get "username"!'); }