Skip to content

Commit

Permalink
修复:Bangumi源只能获取第一页(#499);
Browse files Browse the repository at this point in the history
>> 新增:`progressBar`选项,可配置是否显示追番进度条(#499)
  • Loading branch information
HCLonely committed Aug 18, 2024
1 parent e918ac9 commit 25d636c
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 12 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ bangumi: # 追番设置
color:
webp:
progress:
progressBar:
extraOrder:
order: latest
proxy:
Expand All @@ -63,6 +64,7 @@ cinema: # 追剧设置
color:
webp:
progress:
progressBar:
extraOrder:
order:
extra_options:
Expand All @@ -84,6 +86,7 @@ game: # 游戏设置,仅支持source: bgmv0
color:
webp:
progress:
progressBar:
extraOrder:
order:
extra_options:
Expand All @@ -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`
Expand Down
3 changes: 2 additions & 1 deletion lib/bangumi-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/get-bgm-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions lib/templates/bangumi.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -28,38 +28,38 @@
<div id="bangumi-item1">
<% 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', {__: __}) %>
<% } %>
</div>
<div id="bangumi-item2">
<% 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', {__: __}) %>
<% } %>
</div>
<div id="bangumi-item3">
<% 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', {__: __}) %>
<% } %>
Expand Down
2 changes: 1 addition & 1 deletion lib/templates/bgmv0-template.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</span>
</span>
</div>
<% if(item.type !=='游戏' ){ %>
<% if(item.type !=='游戏' && progressBar !== false){ %>
<div class="bangumi-progress" style="margin-top:5px;">
<div class="bangumi-progress-text">追番进度:<%= item.ep_status %>/<%= item.totalCount %></div>
<div class="progress-bar" style="width: <%= item.progress > 100 ? 100 : item.progress %>%;"></div>
Expand Down
2 changes: 1 addition & 1 deletion lib/templates/bili-template.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</span>
</span>
</div>
<% if (item.progress !== false) { %>
<% if (item.progress !== false && progressBar !== false) { %>
<div class="bangumi-progress" style="margin-top:5px;">
<div class="bangumi-progress-text">追番进度:<%= item.ep_status %>/<%= item.new_ep %>
</div>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hexo-bilibili-bangumi",
"version": "1.10.1",
"version": "1.10.2",
"description": "hexo bilibili番剧页",
"main": "index.js",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions src/lib/bangumi-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"'),
Expand Down
2 changes: 1 addition & 1 deletion src/lib/get-bgm-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"!');
}
Expand Down

0 comments on commit 25d636c

Please sign in to comment.