diff --git a/README.md b/README.md index 87115e2..c7d93eb 100644 --- a/README.md +++ b/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 -享受开发吧 - - - -[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 +享受开发吧 + + + +[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 diff --git a/package.json b/package.json index b048310..c4fbcfc 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/douban/Douban.ts b/src/douban/Douban.ts index 3e91e66..15ba5d9 100644 --- a/src/douban/Douban.ts +++ b/src/douban/Douban.ts @@ -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}} diff --git a/src/douban/data/handler/DoubanGameLoadHandler.ts b/src/douban/data/handler/DoubanGameLoadHandler.ts index 0bfde63..58737a7 100644 --- a/src/douban/data/handler/DoubanGameLoadHandler.ts +++ b/src/douban/data/handler/DoubanGameLoadHandler.ts @@ -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 { @@ -14,9 +15,15 @@ export default class DoubanGameLoadHandler extends DoubanAbstractLoadHandler { 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; + // } } diff --git a/versions.json b/versions.json index bc913d0..aa4521d 100644 --- a/versions.json +++ b/versions.json @@ -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" +}