upgrade version to v1.5.0

This commit is contained in:
wanxp 2022-10-26 21:41:40 +08:00
parent b326e1e4e1
commit 6fd21b7c97
5 changed files with 152 additions and 116 deletions

183
README.md

@ -1,91 +1,92 @@
# Obsidian Douban Plugin # Obsidian Douban Plugin
[![Version][version-shield]][version-url] [![Version][version-shield]][version-url]
[![Stargazers][stars-shield]][stars-url] [![Stargazers][stars-shield]][stars-url]
[![Issues][issues-shield]][issues-url] [![Issues][issues-shield]][issues-url]
[![Downloads][downloads-shield]][downloads-url] [![Downloads][downloads-shield]][downloads-url]
[![Contributors][contributors-shield]][contributors-url] [![Contributors][contributors-shield]][contributors-url]
Import Movies, Books, Music, Teleplay, Note even Broadcast Data from Douban in [Obsidian](https://obsidian.md/) Import Movies, Books, Music, Teleplay, Note, Game even Broadcast Data from Douban in [Obsidian](https://obsidian.md/)
在[Obsidian](https://obsidian.md/)使用并导入豆瓣中的电影/书籍/音乐/电视剧/日记甚至是广播, 包含评分/发布日期/演员表等信息 在[Obsidian](https://obsidian.md/)使用并导入豆瓣中的电影/书籍/音乐/电视剧/日记/游戏甚至是广播, 包含评分/发布日期/演员表等信息
If you want some features or have any questions about this plugin, create issues or join the development is welcome. If you want some features or have any questions about this plugin, create issues or join the development is welcome.
关于当前的插件如果有任何疑问或者想要什么功能, 欢迎提issues或加入到开发当中. 关于当前的插件如果有任何疑问或者想要什么功能, 欢迎提issues或加入到开发当中.
- [Bugs, Issues, & Feature Requests](https://github.com/Wanxp/obsidian-douban/issues) - [Bugs, Issues, & Feature Requests](https://github.com/Wanxp/obsidian-douban/issues)
- [Development Roadmap](https://github.com/users/Wanxp/projects/1) - [Development Roadmap](https://github.com/users/Wanxp/projects/1)
## Target ## Target
- [x] Movie/电影 - [x] Movie/电影
- [x] Teleplay/电视剧 - [x] Teleplay/电视剧
- [x] Book/书籍 - [x] Book/书籍
- [x] Music/音乐 - [x] Music/音乐
- [x] Note/日记 - [x] Note/日记
- [ ] Broadcast/广播 - [x] Game/游戏
- [ ] Broadcast/广播
## How to use
### Movie ## How to use
- Search Movie By Input Text/通过输入文本搜索 ### Movie
![Search Movie By Input Text](./doc/search_by_input.gif) - Search Movie By Input Text/通过输入文本搜索
![Search Movie By Input Text](./doc/search_by_input.gif)
- Search Movie By File Name/通过文件名搜索
![Search Movie By File Name](./doc/search_by_file_name.gif) - Search Movie By File Name/通过文件名搜索
![Search Movie By File Name](./doc/search_by_file_name.gif)
## Settings
- Setting Example1/设置案例1 ## Settings
![Setting Example1](./doc/setting_zh.gif) - Setting Example1/设置案例1
![Setting Example1](./doc/setting_zh.gif)
- Setting Example2/设置案例2
![Setting Example2](./doc/setting_en.gif) - Setting Example2/设置案例2
![Setting Example2](./doc/setting_en.gif)
## How to install
### From Obsidian ## How to install
1. Go to Obsidian plugin center/进入Obsidian插件中心 ### From Obsidian
2. Search obsidian-douban/搜索obsidian-douban 1. Go to Obsidian plugin center/进入Obsidian插件中心
3. Click install/安装 2. Search obsidian-douban/搜索obsidian-douban
4. Enable plugin/开启插件 3. Click install/安装
### Manmel 4. Enable plugin/开启插件
1. Download `main.js`, `manifest.json`, `styles.css` from GitHub release page ### Manmel
从Github release 页面下载 `main.js`, `manifest.json`, `styles.css` 1. Download `main.js`, `manifest.json`, `styles.css` from GitHub release page
2. Copy step1 downloaded file to your vault folder `/.obsidian/plugins/obsidian-douban/` 从Github release 页面下载 `main.js`, `manifest.json`, `styles.css`
将下载的文件复制到你的Obsidian文档根目录下的`/.obsidian/plugins/obsidian-douban`路径,若不存在则新建文件夹(注意.obsidian文件夹可能是个隐藏为文件夹) 2. Copy step1 downloaded file to your vault folder `/.obsidian/plugins/obsidian-douban/`
3. Enable plugin in Obsidian 将下载的文件复制到你的Obsidian文档根目录下的`/.obsidian/plugins/obsidian-douban`路径,若不存在则新建文件夹(注意.obsidian文件夹可能是个隐藏为文件夹)
在obsidian插件中心开启当前插件功能 3. Enable plugin in Obsidian
## How to Develop 在obsidian插件中心开启当前插件功能
1. Enter your test vault folder `/.obsidian/plugins/` ## How to Develop
进入你的Obsidian测试文档文件夹下的`/.obsidian/plugins/` 1. Enter your test vault folder `/.obsidian/plugins/`
2. Clone Code/克隆代码 进入你的Obsidian测试文档文件夹下的`/.obsidian/plugins/`
`git clone git@github.com:Wanxp/obsidian-douban.git` 2. Clone Code/克隆代码
3. Enter folder/进入代码文件夹 `git clone git@github.com:Wanxp/obsidian-douban.git`
`cd obsidian-douban` 3. Enter folder/进入代码文件夹
4. Build/构建 `cd obsidian-douban`
`npm run build` 4. Build/构建
5. Run and Watch code change/运行 `npm run build`
`npm run dev` 5. Run and Watch code change/运行
6. Go to your Obsidian plugin center reload this plugin `npm run dev`
进入Obsidian插件中心重新加载当前插件 6. Go to your Obsidian plugin center reload this plugin
7. Enjoy your develop 进入Obsidian插件中心重新加载当前插件
享受开发吧 7. Enjoy your develop
享受开发吧
<!-- MARKDOWN LINKS & IMAGES -->
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links --> <!-- MARKDOWN LINKS & IMAGES -->
[contributors-shield]: https://img.shields.io/github/contributors/Wanxp/obsidian-douban.svg?style=for-the-badge <!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
[contributors-url]: https://github.com/Wanxp/obsidian-douban/graphs/contributors [contributors-shield]: https://img.shields.io/github/contributors/Wanxp/obsidian-douban.svg?style=for-the-badge
[forks-shield]: https://img.shields.io/github/forks/Wanxp/obsidian-douban.svg?style=for-the-badge [contributors-url]: https://github.com/Wanxp/obsidian-douban/graphs/contributors
[forks-url]: https://github.com/Wanxp/obsidian-douban/network/members [forks-shield]: https://img.shields.io/github/forks/Wanxp/obsidian-douban.svg?style=for-the-badge
[stars-shield]: https://img.shields.io/github/stars/Wanxp/obsidian-douban.svg?style=for-the-badge [forks-url]: https://github.com/Wanxp/obsidian-douban/network/members
[stars-url]: https://github.com/Wanxp/obsidian-douban/stargazers [stars-shield]: https://img.shields.io/github/stars/Wanxp/obsidian-douban.svg?style=for-the-badge
[issues-shield]: https://img.shields.io/github/issues/Wanxp/obsidian-douban.svg?style=for-the-badge [stars-url]: https://github.com/Wanxp/obsidian-douban/stargazers
[issues-url]: https://github.com/Wanxp/obsidian-douban/issues [issues-shield]: https://img.shields.io/github/issues/Wanxp/obsidian-douban.svg?style=for-the-badge
[license-shield]: https://img.shields.io/github/license/Wanxp/obsidian-douban.svg?style=for-the-badge [issues-url]: https://github.com/Wanxp/obsidian-douban/issues
[license-url]: https://github.com/Wanxp/obsidian-douban/blob/master/LICENSE.txt [license-shield]: https://img.shields.io/github/license/Wanxp/obsidian-douban.svg?style=for-the-badge
[product-screenshot]: images/screenshot.png [license-url]: https://github.com/Wanxp/obsidian-douban/blob/master/LICENSE.txt
[version-shield]: https://img.shields.io/github/package-json/v/Wanxp/obsidian-douban.svg?style=for-the-badge [product-screenshot]: images/screenshot.png
[version-url]: https://github.com/Wanxp/obsidian-douban/releases/latest [version-shield]: https://img.shields.io/github/package-json/v/Wanxp/obsidian-douban.svg?style=for-the-badge
[version-url]: https://github.com/Wanxp/obsidian-douban/releases/latest
[downloads-shield]: https://img.shields.io/github/downloads/Wanxp/obsidian-douban/total.svg?style=for-the-badge
[downloads-url]: https://github.com/Wanxp/obsidian-douban [downloads-shield]: https://img.shields.io/github/downloads/Wanxp/obsidian-douban/total.svg?style=for-the-badge
[downloads-url]: https://github.com/Wanxp/obsidian-douban

@ -1,7 +1,7 @@
{ {
"name": "obsidian-sample-plugin", "name": "obsidian-douban-plugin",
"version": "v1.4.3", "version": "v1.5.0",
"description": "This is a sample plugin for Obsidian (https://obsidian.md)", "description": "This is a plugin for Obsidian (https://obsidian.md) that can import data from Douban (https://www.douban.com/).",
"main": "main.js", "main": "main.js",
"scripts": { "scripts": {
"dev": "node esbuild.config.mjs", "dev": "node esbuild.config.mjs",

@ -109,13 +109,13 @@ aliases: {{aliases}}
type: {{type}} type: {{type}}
score: {{score}} score: {{score}}
tags: Game tags: Game
dateTimePublished: {{datePublished}} {{timePublished}} dateTimePublished: {{datePublished}}
publisher: {{publisher}} publisher: {{publisher}}
genre: {{genre}} genre: {{genre}}
developer: {{developer}} developer: {{developer}}
platform: {{platform}} platform: {{platform}}
url: {{url}} url: {{url}}
desc: {{desc}}} desc: {{desc}}
`, `,
// totalWord: {{totalWord}} // totalWord: {{totalWord}}

@ -1,12 +1,13 @@
import { CheerioAPI } from 'cheerio'; import { CheerioAPI } from 'cheerio';
import DoubanAbstractLoadHandler from "./DoubanAbstractLoadHandler"; import DoubanAbstractLoadHandler from "./DoubanAbstractLoadHandler";
import DoubanPlugin from "main"; import DoubanPlugin from "main";
import { DoubanPluginSettings } from "src/douban/Douban"; import {DoubanPluginSettings, PersonNameMode} from "src/douban/Douban";
import SchemaOrg from "src/utils/SchemaOrg"; import SchemaOrg from "src/utils/SchemaOrg";
import { moment } from "obsidian"; import { moment } from "obsidian";
import DoubanSubject from '../model/DoubanSubject'; import DoubanSubject from '../model/DoubanSubject';
import DoubanGameSubject from '../model/DoubanGameSubject'; import DoubanGameSubject from '../model/DoubanGameSubject';
import DoubanBookSubject from "@App/data/model/DoubanBookSubject"; import DoubanBookSubject from "@App/data/model/DoubanBookSubject";
import { log } from 'src/utils/Logutil';
export default class DoubanGameLoadHandler extends DoubanAbstractLoadHandler<DoubanGameSubject> { export default class DoubanGameLoadHandler extends DoubanAbstractLoadHandler<DoubanGameSubject> {
@ -14,9 +15,15 @@ export default class DoubanGameLoadHandler extends DoubanAbstractLoadHandler<Dou
return settings.gameTemplate; return settings.gameTemplate;
} }
parseText(beforeContent:string, extract: DoubanGameSubject, settings:DoubanPluginSettings): string { // parse(extract: DoubanGameSubject, settings: DoubanPluginSettings): string {
// extract.title = this.handleI18nName(extract.title, settings);
// return super.parse(extract, settings);
// }
parseText(beforeContent:string, extract: DoubanGameSubject, settings:DoubanPluginSettings): string {
return beforeContent return beforeContent
.replaceAll("{{platform}}", extract.platform ? extract.platform.join(settings.arraySpilt) : "") .replaceAll("{{platform}}", extract.platform ? extract.platform.join(settings.arraySpilt) : "")
.replaceAll("{{aliases}}", extract.aliases ? extract.aliases.join(settings.arraySpilt) : "")
.replaceAll("{{developer}}", extract.developer ? extract.developer : ""); .replaceAll("{{developer}}", extract.developer ? extract.developer : "");
} }
@ -50,34 +57,61 @@ export default class DoubanGameLoadHandler extends DoubanAbstractLoadHandler<Dou
dt.map((index, info) => { dt.map((index, info) => {
let key = html(info).text().trim(); let key = html(info).text().trim();
if(key.indexOf('平台') >= 0 || key.indexOf('类型') >= 0){ if(key.indexOf('平台') >= 0 || key.indexOf('类型') >= 0){
html(info.next).find("a").map((index, a) => { value = [];
html(info.next.next).find("a").map((index, a) => {
value.push(html(a).text().trim()); value.push(html(a).text().trim());
}); });
}else if (key.indexOf('别名') >= 0) {
let cc = html(info.next.next).text().trim();
value = cc.split("/");
}else{ }else{
value = html(info.next).text().trim(); value = html(info.next.next).text().trim();
} }
log.trace(key + ":" + value);
valueMap.set(GameKeyValueMap.get(key), value); valueMap.set(GameKeyValueMap.get(key), value);
}) })
const result:DoubanGameSubject = { const result:DoubanGameSubject = {
id: id, id: id,
type: "Game", type: "Game",
title: title, title: title,
desc: desc, desc: desc,
url: url, url: url,
genre: valueMap.has('genre') ? valueMap.get('genre') : "", genre: valueMap.has('genre') ? valueMap.get('genre') : [],
image: image, image: image,
datePublished: valueMap.has('datePublished') ? new Date(valueMap.get('datePublished')) : undefined, datePublished: valueMap.has('datePublished') ? new Date(valueMap.get('datePublished')) : undefined,
publisher: valueMap.has('publisher') ? valueMap.get('publisher') : "", publisher: valueMap.has('publisher') ? valueMap.get('publisher') : "",
score: Number(score), score: Number(score),
aliases: valueMap.has('aliases') ? valueMap.get('aliases') : "", aliases: valueMap.has('aliases') ? valueMap.get('aliases') : [],
developer: valueMap.has('developer') ? valueMap.get('developer') : "", developer: valueMap.has('developer') ? valueMap.get('developer') : "",
platform: valueMap.has('platform') ? valueMap.get('platform') : "" platform: valueMap.has('platform') ? valueMap.get('platform') : []
}; };
return result return result
} }
//TODO support game's name i18n
// handleI18nName(title: string, settings: DoubanPluginSettings):string {
// if (!title) {
// return "";
// }
// if (!settings) {
// return title;
// }
// let resultName:string = "";
// let regValue:RegExpExecArray;
// switch(settings.personNameMode) {
// case PersonNameMode.CH_NAME:
// regValue = /[\u4e00-\u9fa5]{2,20}/g.exec(title);
// resultName = regValue?regValue[0]:title;
// break;
// case PersonNameMode.EN_NAME:
// regValue = /[a-zA-Z.\s\-]{2,50}/g.exec(title);
// resultName = regValue?regValue[0]:title;
// break;
// default:
// resultName = title;
// }
// return resultName;
// }
} }

@ -1,11 +1,12 @@
{ {
"1.0.0": "0.9.7", "1.0.0": "0.9.7",
"1.0.1": "0.12.0", "1.0.1": "0.12.0",
"1.1.0": "0.12.0", "1.1.0": "0.12.0",
"1.2.0": "0.12.0", "1.2.0": "0.12.0",
"1.3.0": "0.12.0", "1.3.0": "0.12.0",
"1.4.0": "0.12.0", "1.4.0": "0.12.0",
"1.4.1": "0.12.0", "1.4.1": "0.12.0",
"1.4.2": "0.12.0", "1.4.2": "0.12.0",
"v1.4.3": "0.12.0" "v1.4.3": "0.12.0",
} "v1.5.0": "0.12.0"
}