From b34de488334dfea0fffacb115cde251d4b6fd444 Mon Sep 17 00:00:00 2001 From: HCLonely Date: Mon, 31 Jan 2022 11:52:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BB=A3=E7=90=86=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E9=80=89=E9=A1=B9=EF=BC=9B=E6=B7=BB=E5=8A=A0=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=BC=93=E5=AD=98=E5=8A=9F=E8=83=BD=EF=BC=9B=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=B7=B2=E7=9F=A5BUG(125)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 + index.js | 2 +- lib/bangumi-generator.js | 4 +- lib/get-bgm-data.js | 209 ++++++++++++++++++++++++++------------- package.json | 7 +- src/index.js | 2 +- src/lib/get-bgm-data.js | 105 +++++++++++++------- 7 files changed, 219 insertions(+), 114 deletions(-) diff --git a/README.md b/README.md index a8c06cf..a89a7aa 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,9 @@ bangumi: # 追番设置 color: webp: progress: + proxy: + host: '代理host' + port: '代理端口' extra_options: key: value cinema: # 追剧设置 @@ -56,6 +59,7 @@ cinema: # 追剧设置 - **enable**: 是否启用 - **source**: 数据源,仅支持追番,追剧仅支持哔哩哔哩源。`bili`: [哔哩哔哩源](https://www.bilibili.com/), `bgm`: [Bangumi源](https://bangumi.tv/) +- **proxy**: 代理设置,仅在使用支持`bgm`源追番时生效。默认`false` - **path**: 页面路径,默认`bangumis/index.html`, `cinemas/index.html` - **vmid**: 哔哩哔哩的 `vmid(uid)`[如何获取?](#获取-bilibili-uid)或Bangumi的用户`id`[如何获取?](#获取-bangumi-id) - **title**: 该页面的标题 diff --git a/index.js b/index.js index a282a11..cf5a1ff 100644 --- a/index.js +++ b/index.js @@ -72,7 +72,7 @@ hexo.extend.console.register('bangumi', 'Generate pages of bangumis for Hexo', o if (this.config.bangumi.source === 'bgm') { var _this$config$bangumi$; - getBgmData(this.config.bangumi.vmid, (_this$config$bangumi$ = this.config.bangumi.progress) !== null && _this$config$bangumi$ !== void 0 ? _this$config$bangumi$ : true, this.source_dir); + getBgmData(this.config.bangumi.vmid, (_this$config$bangumi$ = this.config.bangumi.progress) !== null && _this$config$bangumi$ !== void 0 ? _this$config$bangumi$ : true, this.source_dir, this.config.bangumi.proxy); } else { var _this$config$bangumi$2; diff --git a/lib/bangumi-generator.js b/lib/bangumi-generator.js index 28a4f9d..465aff9 100644 --- a/lib/bangumi-generator.js +++ b/lib/bangumi-generator.js @@ -8,9 +8,9 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); -function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } -function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } var ejs = require('ejs'); diff --git a/lib/get-bgm-data.js b/lib/get-bgm-data.js index 58b63bb..c672aff 100644 --- a/lib/get-bgm-data.js +++ b/lib/get-bgm-data.js @@ -8,6 +8,7 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); +/* eslint-disable no-underscore-dangle */ var fs = require('hexo-fs'); var path = require('path'); @@ -23,6 +24,8 @@ var ProgressBar = require('progress'); var cheerio = require('cheerio'); +var tunnel = require('tunnel'); + var bangumiData = require('bangumi-data'); var getItemsId = /*#__PURE__*/function () { @@ -41,7 +44,7 @@ var getItemsId = /*#__PURE__*/function () { response = _context2.sent; if (!(response !== null && response !== void 0 && response.data)) { - _context2.next = 18; + _context2.next = 19; break; } @@ -55,24 +58,24 @@ var getItemsId = /*#__PURE__*/function () { }; }).get(); - if (!(pageNum < 2)) { - _context2.next = 10; - break; - } - - return _context2.abrupt("return", items); - - case 10: if (showProgress) { // eslint-disable-next-line no-nested-ternary bar = new ProgressBar("\u6B63\u5728\u83B7\u53D6 ".concat(status === 'wish' ? '[想看]' : status === 'do' ? '[在看]' : '[已看]', " \u756A\u5267 [:bar] :percent :elapseds"), { - total: pageNum, + total: pageNum < 2 ? 1 : pageNum, complete: '█' }); bar.tick(); - } // eslint-disable-next-line no-plusplus + } + if (!(pageNum < 2)) { + _context2.next = 12; + break; + } + log.info('正在获取番剧详细数据,请耐心等待...'); + return _context2.abrupt("return", items); + + case 12: _loop = /*#__PURE__*/_regenerator["default"].mark(function _loop(i) { var response, $; return _regenerator["default"].wrap(function _loop$(_context) { @@ -105,24 +108,24 @@ var getItemsId = /*#__PURE__*/function () { }); i = 2; - case 13: + case 14: if (!(i <= pageNum)) { - _context2.next = 18; + _context2.next = 19; break; } - return _context2.delegateYield(_loop(i), "t0", 15); + return _context2.delegateYield(_loop(i), "t0", 16); - case 15: + case 16: i++; - _context2.next = 13; + _context2.next = 14; break; - case 18: + case 19: log.info('正在获取番剧详细数据,耗时与追番数量成正比,请耐心等待...'); return _context2.abrupt("return", items); - case 20: + case 21: case "end": return _context2.stop(); } @@ -152,31 +155,65 @@ var TYPE = { }; var getBangumiData = /*#__PURE__*/function () { - var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(items) { + var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(items, sourceDir, proxy) { return _regenerator["default"].wrap(function _callee2$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: _context3.next = 2; - return axios.all(items.map(function (item) { - return axios.get("https://cdn.jsdelivr.net/gh/czy0729/Bangumi-Subject@master/data/".concat(parseInt(parseInt(item.id, 10) / 100, 10), "/").concat(item.id, ".json"), { + return Promise.all(items.map(function (item) { + var cachePath = path.join(sourceDir, '/_data/Bangumi-Subject-Cache'); + var subjectPath = path.join(cachePath, "".concat(item.id, ".json")); + + if (!fs.existsSync(cachePath)) { + fs.mkdirsSync(cachePath); + } + + if (fs.existsSync(subjectPath)) { + return { + config: { + itemData: item + }, + data: fs.readFileSync(subjectPath).toString(), + status: 200 + }; + } + + var options = { itemData: item, responseType: 'json', validateStatus: function validateStatus(status) { - return status >= 200 && status < 300 || status === 403; // default + return status >= 200 && status < 300 || status === 403; } + }; + + if (proxy !== null && proxy !== void 0 && proxy.host && proxy !== null && proxy !== void 0 && proxy.port) { + options.httpsAgent = tunnel.httpsOverHttp({ + proxy: proxy, + rejectUnauthorized: false + }); + } + + return axios.get("https://cdn.jsdelivr.net/gh/czy0729/Bangumi-Subject@master/data/".concat(parseInt(parseInt(item.id, 10) / 100, 10), "/").concat(item.id, ".json"), options).then(function (response) { + return response; + })["catch"](function (error) { + if (error.response) { + console.error('Error', error.response.status); + } else { + console.error('Error', error.stack); + } + + return error; }); })); case 2: return _context3.abrupt("return", _context3.sent.map(function (_ref3) { - var _data, _data2, _data3, _data4, _data5, _data5$rating, _data6, _data6$summary, _data7, _data7$collection, _data8, _data8$collection, _data9, _data9$collection, _data10, _data10$eps, _data11, _data11$eps; - var config = _ref3.config, data = _ref3.data, status = _ref3.status; - if (status === 403) { + if (status === 403 || !data) { return { id: config.itemData.id, title: jp2cnName(config.itemData.name), @@ -201,17 +238,57 @@ var getBangumiData = /*#__PURE__*/function () { } } + var _data = data, + id = _data.id, + name = _data.name, + type = _data.type, + image = _data.image, + _data$rating = _data.rating; + _data$rating = _data$rating === void 0 ? {} : _data$rating; + var score = _data$rating.score, + summary = _data.summary, + _data$collection = _data.collection; + _data$collection = _data$collection === void 0 ? {} : _data$collection; + var wish = _data$collection.wish, + doing = _data$collection.doing, + collect = _data$collection.collect, + eps = _data.eps, + epsLength = _data.epsLength; + var totalCount = epsLength || (eps === null || eps === void 0 ? void 0 : eps.length); + var subjectPath = path.join(sourceDir, '/_data/Bangumi-Subject-Cache', "".concat(config.itemData.id, ".json")); + + if (!fs.existsSync(subjectPath)) { + if (id && name && type && image && score && summary && wish && doing && collect && (eps === null || eps === void 0 ? void 0 : eps.length) > 0) { + fs.writeFileSync(subjectPath, JSON.stringify({ + id: id, + name: name, + type: type, + image: image, + rating: { + score: score + }, + summary: summary, + collection: { + wish: wish, + doing: doing, + collect: collect + }, + epsLength: eps.length + })); + } + } + return { - id: ((_data = data) === null || _data === void 0 ? void 0 : _data.id) || config.itemData.id, - title: jp2cnName(((_data2 = data) === null || _data2 === void 0 ? void 0 : _data2.name) || config.itemData.name), - type: TYPE[(_data3 = data) === null || _data3 === void 0 ? void 0 : _data3.type] || '未知', - cover: ((_data4 = data) === null || _data4 === void 0 ? void 0 : _data4.image) || config.itemData.cover, - score: ((_data5 = data) === null || _data5 === void 0 ? void 0 : (_data5$rating = _data5.rating) === null || _data5$rating === void 0 ? void 0 : _data5$rating.score) || '-', - des: ((_data6 = data) === null || _data6 === void 0 ? void 0 : (_data6$summary = _data6.summary) === null || _data6$summary === void 0 ? void 0 : _data6$summary.replace(/\r?\n/g, '').trim()) || '-', - wish: ((_data7 = data) === null || _data7 === void 0 ? void 0 : (_data7$collection = _data7.collection) === null || _data7$collection === void 0 ? void 0 : _data7$collection.wish) || '-', - doing: ((_data8 = data) === null || _data8 === void 0 ? void 0 : (_data8$collection = _data8.collection) === null || _data8$collection === void 0 ? void 0 : _data8$collection.doing) || '-', - collect: ((_data9 = data) === null || _data9 === void 0 ? void 0 : (_data9$collection = _data9.collection) === null || _data9$collection === void 0 ? void 0 : _data9$collection.collect) || '-', - totalCount: (_data10 = data) !== null && _data10 !== void 0 && (_data10$eps = _data10.eps) !== null && _data10$eps !== void 0 && _data10$eps.length ? "\u5168".concat((_data11 = data) === null || _data11 === void 0 ? void 0 : (_data11$eps = _data11.eps) === null || _data11$eps === void 0 ? void 0 : _data11$eps.length, "\u8BDD") : '-' + id: id || config.itemData.id, + title: jp2cnName(name || config.itemData.name), + type: TYPE[type] || '未知', + cover: image || config.itemData.cover, + score: score || '-', + des: (summary === null || summary === void 0 ? void 0 : summary.replace(/\r?\n/g, '').trim()) || '-', + wish: wish || '-', + doing: doing || '-', + collect: collect || '-', + totalCount: totalCount ? "\u5168".concat(totalCount, "\u8BDD") : '-' }; })); @@ -223,25 +300,13 @@ var getBangumiData = /*#__PURE__*/function () { }, _callee2); })); - return function getBangumiData(_x4) { + return function getBangumiData(_x4, _x5, _x6) { return _ref2.apply(this, arguments); }; }(); -/* -(async () => { - console.log(await getBangumiData([{ id: '975' }])); -})(); -function count(e) { - return e ? (e > 10000 && e < 100000000 ? `${(e / 10000).toFixed(1)} 万` : e > 100000000 ? `${(e / 100000000).toFixed(1)} 亿` : e) : '-'; -} -function total(e, typeNum) { - return e ? (e === -1 ? '未完结' : `全${e}${typeNum === 1 ? '话' : '集'}`) : '-'; -} -*/ - module.exports.getBgmData = /*#__PURE__*/function () { - var _getBgmData = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(vmid, showProgress, sourceDir) { + var _getBgmData = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(vmid, showProgress, sourceDir, proxy) { var startTime, wantWatch, watching, watched, endTime, bangumis; return _regenerator["default"].wrap(function _callee3$(_context4) { while (1) { @@ -255,32 +320,38 @@ module.exports.getBgmData = /*#__PURE__*/function () { case 5: _context4.t1 = _context4.sent; - _context4.next = 8; - return (0, _context4.t0)(_context4.t1); + _context4.t2 = sourceDir; + _context4.t3 = proxy; + _context4.next = 10; + return (0, _context4.t0)(_context4.t1, _context4.t2, _context4.t3); - case 8: + case 10: wantWatch = _context4.sent; - _context4.t2 = getBangumiData; - _context4.next = 12; + _context4.t4 = getBangumiData; + _context4.next = 14; return getItemsId(vmid, 'do', showProgress); - case 12: - _context4.t3 = _context4.sent; - _context4.next = 15; - return (0, _context4.t2)(_context4.t3); + case 14: + _context4.t5 = _context4.sent; + _context4.t6 = sourceDir; + _context4.t7 = proxy; + _context4.next = 19; + return (0, _context4.t4)(_context4.t5, _context4.t6, _context4.t7); - case 15: + case 19: watching = _context4.sent; - _context4.t4 = getBangumiData; - _context4.next = 19; + _context4.t8 = getBangumiData; + _context4.next = 23; return getItemsId(vmid, 'collect', showProgress); - case 19: - _context4.t5 = _context4.sent; - _context4.next = 22; - return (0, _context4.t4)(_context4.t5); + case 23: + _context4.t9 = _context4.sent; + _context4.t10 = sourceDir; + _context4.t11 = proxy; + _context4.next = 28; + return (0, _context4.t8)(_context4.t9, _context4.t10, _context4.t11); - case 22: + case 28: watched = _context4.sent; endTime = new Date().getTime(); log.info("".concat(wantWatch.length + watching.length + watched.length, " bangumis have been loaded in ").concat(endTime - startTime, " ms")); @@ -299,11 +370,11 @@ module.exports.getBgmData = /*#__PURE__*/function () { log.info('Failed to write data to bangumis.json'); console.error(err); } else { - log.info('Bilibili bangumis data has been saved'); + log.info('Bangumi bangumis data has been saved'); } }); - case 28: + case 34: case "end": return _context4.stop(); } @@ -311,7 +382,7 @@ module.exports.getBgmData = /*#__PURE__*/function () { }, _callee3); })); - function getBgmData(_x5, _x6, _x7) { + function getBgmData(_x7, _x8, _x9, _x10) { return _getBgmData.apply(this, arguments); } diff --git a/package.json b/package.json index 9a15007..2be5200 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-bilibili-bangumi", - "version": "1.7.2", + "version": "1.7.4", "description": "hexo bilibili番剧页", "main": "index.js", "scripts": { @@ -20,14 +20,15 @@ ], "dependencies": { "@babel/runtime": "^7.15.3", + "axios": "^0.25.0", "bangumi-data": "^0.3.81", "cheerio": "^1.0.0-rc.10", - "axios": "^0.25.0", "ejs": "3.1.6", "hexo-fs": "^3.1.0", "hexo-i18n": "^1.0.0", "hexo-log": "^3.0.0", - "progress": "^2.0.3" + "progress": "^2.0.3", + "tunnel": "^0.0.6" }, "repository": { "type": "git", diff --git a/src/index.js b/src/index.js index 1f330a2..c66724a 100644 --- a/src/index.js +++ b/src/index.js @@ -49,7 +49,7 @@ hexo.extend.console.register('bangumi', 'Generate pages of bangumis for Hexo', o return; } if (this.config.bangumi.source === 'bgm') { - getBgmData(this.config.bangumi.vmid, this.config.bangumi.progress ?? true, this.source_dir); + getBgmData(this.config.bangumi.vmid, this.config.bangumi.progress ?? true, this.source_dir, this.config.bangumi.proxy); } else { getBiliData(this.config.bangumi.vmid, 'bangumi', this.config.bangumi.progress ?? true, this.source_dir, this.config.bangumi.webp); } diff --git a/src/lib/get-bgm-data.js b/src/lib/get-bgm-data.js index 303c585..4dcfe37 100644 --- a/src/lib/get-bgm-data.js +++ b/src/lib/get-bgm-data.js @@ -1,3 +1,4 @@ +/* eslint-disable no-underscore-dangle */ const fs = require('hexo-fs'); const path = require('path'); const axios = require('axios'); @@ -7,6 +8,7 @@ const log = require('hexo-log')({ }); const ProgressBar = require('progress'); const cheerio = require('cheerio'); +const tunnel = require('tunnel'); const bangumiData = require('bangumi-data'); const getItemsId = async (vmid, status, showProgress) => { @@ -26,15 +28,16 @@ const getItemsId = async (vmid, status, showProgress) => { })) .get(); - if (pageNum < 2) { - return items; - } if (showProgress) { // eslint-disable-next-line no-nested-ternary bar = new ProgressBar(`正在获取 ${status === 'wish' ? '[想看]' : (status === 'do' ? '[在看]' : '[已看]')} 番剧 [:bar] :percent :elapseds`, - { total: pageNum, complete: '█' }); + { total: pageNum < 2 ? 1 : pageNum, complete: '█' }); bar.tick(); } + if (pageNum < 2) { + log.info('正在获取番剧详细数据,请耐心等待...'); + return items; + } // eslint-disable-next-line no-plusplus for (let i = 2; i <= pageNum; i++) { @@ -67,17 +70,45 @@ const TYPE = { 4: '游戏', 6: '三次元' }; -const getBangumiData = async (items) => (await axios.all( +const getBangumiData = async (items, sourceDir, proxy) => (await Promise.all( items.map( - (item) => axios.get(`https://cdn.jsdelivr.net/gh/czy0729/Bangumi-Subject@master/data/${ - parseInt(parseInt(item.id, 10) / 100, 10)}/${item.id}.json`, { itemData: item, - responseType: 'json', - validateStatus(status) { - return (status >= 200 && status < 300) || status === 403; // default - } }) + (item) => { + const cachePath = path.join(sourceDir, '/_data/Bangumi-Subject-Cache'); + const subjectPath = path.join(cachePath, `${item.id}.json`); + if (!fs.existsSync(cachePath)) { + fs.mkdirsSync(cachePath); + } + if (fs.existsSync(subjectPath)) { + return { config: { itemData: item }, data: fs.readFileSync(subjectPath).toString(), status: 200 }; + } + const options = { + itemData: item, + responseType: 'json', + validateStatus(status) { + return (status >= 200 && status < 300) || status === 403; + } + }; + if (proxy?.host && proxy?.port) { + options.httpsAgent = tunnel.httpsOverHttp({ + proxy, + rejectUnauthorized: false + }); + } + return axios.get(`https://cdn.jsdelivr.net/gh/czy0729/Bangumi-Subject@master/data/${ + parseInt(parseInt(item.id, 10) / 100, 10)}/${item.id}.json`, options) + .then((response) => response) + .catch((error) => { + if (error.response) { + console.error('Error', error.response.status); + } else { + console.error('Error', error.stack); + } + return error; + }); + } ) )).map(({ config, data, status }) => { - if (status === 403) { + if (status === 403 || !data) { return { id: config.itemData.id, title: jp2cnName(config.itemData.name), @@ -100,36 +131,34 @@ const getBangumiData = async (items) => (await axios.all( console.error(e); } } + const { id, name, type, image, rating: { score } = {}, summary, collection: { wish, doing, collect } = {}, eps, epsLength } = data; + const totalCount = epsLength || eps?.length; + const subjectPath = path.join(sourceDir, '/_data/Bangumi-Subject-Cache', `${config.itemData.id}.json`); + if (!fs.existsSync(subjectPath)) { + if (id && name && type && image && score && summary && wish && doing && collect && eps?.length > 0) { + fs.writeFileSync(subjectPath, JSON.stringify({ id, name, type, image, rating: { score }, summary, collection: { wish, doing, collect }, epsLength: eps.length })); + } + } return { - id: data?.id || config.itemData.id, - title: jp2cnName(data?.name || config.itemData.name), - type: TYPE[data?.type] || '未知', - cover: data?.image || config.itemData.cover, - score: data?.rating?.score || '-', - des: data?.summary?.replace(/\r?\n/g, '').trim() || '-', - wish: data?.collection?.wish || '-', - doing: data?.collection?.doing || '-', - collect: data?.collection?.collect || '-', - totalCount: data?.eps?.length ? `全${data?.eps?.length}话` : '-' + id: id || config.itemData.id, + title: jp2cnName(name || config.itemData.name), + type: TYPE[type] || '未知', + cover: image || config.itemData.cover, + score: score || '-', + des: summary?.replace(/\r?\n/g, '').trim() || '-', + wish: wish || '-', + doing: doing || '-', + collect: collect || '-', + totalCount: totalCount ? `全${totalCount}话` : '-' }; }); -/* -(async () => { - console.log(await getBangumiData([{ id: '975' }])); -})(); -function count(e) { - return e ? (e > 10000 && e < 100000000 ? `${(e / 10000).toFixed(1)} 万` : e > 100000000 ? `${(e / 100000000).toFixed(1)} 亿` : e) : '-'; -} -function total(e, typeNum) { - return e ? (e === -1 ? '未完结' : `全${e}${typeNum === 1 ? '话' : '集'}`) : '-'; -} -*/ -module.exports.getBgmData = async function getBgmData(vmid, showProgress, sourceDir) { + +module.exports.getBgmData = async function getBgmData(vmid, showProgress, sourceDir, proxy) { log.info('Getting bangumis, please wait...'); const startTime = new Date().getTime(); - const wantWatch = await getBangumiData(await getItemsId(vmid, 'wish', showProgress)); - const watching = await getBangumiData(await getItemsId(vmid, 'do', showProgress)); - const watched = await getBangumiData(await getItemsId(vmid, 'collect', showProgress)); + const wantWatch = await getBangumiData(await getItemsId(vmid, 'wish', showProgress), sourceDir, proxy); + const watching = await getBangumiData(await getItemsId(vmid, 'do', showProgress), sourceDir, proxy); + const watched = await getBangumiData(await getItemsId(vmid, 'collect', showProgress), sourceDir, proxy); const endTime = new Date().getTime(); log.info(`${wantWatch.length + watching.length + watched.length} bangumis have been loaded in ${endTime - startTime} ms`); const bangumis = { wantWatch, watching, watched }; @@ -141,7 +170,7 @@ module.exports.getBgmData = async function getBgmData(vmid, showProgress, source log.info('Failed to write data to bangumis.json'); console.error(err); } else { - log.info('Bilibili bangumis data has been saved'); + log.info('Bangumi bangumis data has been saved'); } }); };