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

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

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

@ -1,12 +1,13 @@
import { CheerioAPI } from 'cheerio';
import DoubanAbstractLoadHandler from "./DoubanAbstractLoadHandler";
import DoubanPlugin from "main";
import { DoubanPluginSettings } from "src/douban/Douban";
import {DoubanPluginSettings, PersonNameMode} from "src/douban/Douban";
import SchemaOrg from "src/utils/SchemaOrg";
import { moment } from "obsidian";
import DoubanSubject from '../model/DoubanSubject';
import DoubanGameSubject from '../model/DoubanGameSubject';
import DoubanBookSubject from "@App/data/model/DoubanBookSubject";
import { log } from 'src/utils/Logutil';
export default class DoubanGameLoadHandler extends DoubanAbstractLoadHandler<DoubanGameSubject> {
@ -14,9 +15,15 @@ export default class DoubanGameLoadHandler extends DoubanAbstractLoadHandler<Dou
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
.replaceAll("{{platform}}", extract.platform ? extract.platform.join(settings.arraySpilt) : "")
.replaceAll("{{aliases}}", extract.aliases ? extract.aliases.join(settings.arraySpilt) : "")
.replaceAll("{{developer}}", extract.developer ? extract.developer : "");
}
@ -50,34 +57,61 @@ export default class DoubanGameLoadHandler extends DoubanAbstractLoadHandler<Dou
dt.map((index, info) => {
let key = html(info).text().trim();
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());
});
}else if (key.indexOf('别名') >= 0) {
let cc = html(info.next.next).text().trim();
value = cc.split("/");
}else{
value = html(info.next).text().trim();
value = html(info.next.next).text().trim();
}
log.trace(key + ":" + value);
valueMap.set(GameKeyValueMap.get(key), value);
})
const result:DoubanGameSubject = {
id: id,
type: "Game",
title: title,
desc: desc,
url: url,
genre: valueMap.has('genre') ? valueMap.get('genre') : "",
genre: valueMap.has('genre') ? valueMap.get('genre') : [],
image: image,
datePublished: valueMap.has('datePublished') ? new Date(valueMap.get('datePublished')) : undefined,
publisher: valueMap.has('publisher') ? valueMap.get('publisher') : "",
score: Number(score),
aliases: valueMap.has('aliases') ? valueMap.get('aliases') : "",
aliases: valueMap.has('aliases') ? valueMap.get('aliases') : [],
developer: valueMap.has('developer') ? valueMap.get('developer') : "",
platform: valueMap.has('platform') ? valueMap.get('platform') : ""
platform: valueMap.has('platform') ? valueMap.get('platform') : []
};
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.1": "0.12.0",
"1.1.0": "0.12.0",
"1.2.0": "0.12.0",
"1.3.0": "0.12.0",
"1.4.0": "0.12.0",
"1.4.1": "0.12.0",
"1.4.2": "0.12.0",
"v1.4.3": "0.12.0"
}
{
"1.0.0": "0.9.7",
"1.0.1": "0.12.0",
"1.1.0": "0.12.0",
"1.2.0": "0.12.0",
"1.3.0": "0.12.0",
"1.4.0": "0.12.0",
"1.4.1": "0.12.0",
"1.4.2": "0.12.0",
"v1.4.3": "0.12.0",
"v1.5.0": "0.12.0"
}