Skip to content

Commit

Permalink
增加手动添加番剧数据的功能
Browse files Browse the repository at this point in the history
支持从sources/_data/extra_bangumis.json手动载入番剧数据,详情见README.md
  • Loading branch information
mmdjiji committed Mar 10, 2021
1 parent b5f2235 commit ed41b00
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,43 @@ bangumi:

![示例图片](https://github.com/HCLonely/hexo-bilibili-bangumi/raw/master/example.png)

## 手动添加番剧数据
因为某些番剧在哔哩哔哩上没有,但是又想在hexo中展示,怎么办呢?现在支持手动添加番剧数据了!

在 `sources/_data/` 目录下新建文件,命名为 `extra_bangumis.json` ,并添加以如下内容:
```json
{
"watched": [
{
"title": "缘之空",
"type": "番剧",
"area": "日本",
"cover": "https://cdn.jsdelivr.net/gh/mmdjiji/bangumis@main/Yosuga-no-Sora/cover.jpg",
"totalCount": "全12话",
"id": 0,
"follow": "不可用",
"view": "不可用",
"danmaku": "不可用",
"coin": "不可用",
"score": "不可用",
"des": "远离都市的田园小镇,奥木染。春日野悠带着妹妹穹,来到了这座城镇。坐落在这里的是,儿时暑假经常造访的充满回忆的已故祖父的家。双亲因意外事故而丧生,变得无依无靠..."
}
]
}
```

`title` 是番剧的标题,`cover` 是封面图链接, `des` 是简介,上述字段均根据需要修改。

另外除了 `watched` 数组,还可以在后面添加新的数组,可用数组名如下:

|可用数组名|含义|
|-|-|
|wantWatch|想看|
|watching|在看|
|watched|看过|

需要注意,在两个数组之间需要用 `,` 分隔。

## Lisense

[Apache Licence 2.0](https://github.com/HCLonely/hexo-bilibili-bangumi/blob/master/LICENSE)
16 changes: 16 additions & 0 deletions lib/bangumi-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,22 @@ module.exports = /*#__PURE__*/function () {
wantWatch = _JSON$parse.wantWatch;
watching = _JSON$parse.watching;
watched = _JSON$parse.watched;

// extra bangumis
console.log(path.join(this.source_dir, '/_data/extra_bangumis.json'));
if(fs.existsSync(path.join(this.source_dir, '/_data/extra_bangumis.json'))) {
log.info('Found extra bangumi data');
_JSON$parse = JSON.parse(fs.readFileSync(path.join(this.source_dir, '/_data/extra_bangumis.json')));
if(_JSON$parse.wantWatch) {
wantWatch = wantWatch.concat(_JSON$parse.wantWatch);
}
if(_JSON$parse.watching) {
watching = watching.concat(_JSON$parse.watching);
}
if(_JSON$parse.watched) {
watched = watched.concat(_JSON$parse.watched);
}
}
log.info(wantWatch.length + watching.length + watched.length + ' bangumis have been loaded');
}

Expand Down

0 comments on commit ed41b00

Please sign in to comment.