Compare commits
No commits in common. "master" and "v1.5.0" have entirely different histories.
51
.github/ISSUE_TEMPLATE/异常反馈-bug-report.md
vendored
@ -1,51 +0,0 @@
|
||||
---
|
||||
name: 异常反馈/Bug report
|
||||
about: 使用遇到问题时反馈问题/Create a report to help us improve
|
||||
title: "[Bug]:简要描述你的问题"
|
||||
labels: ''
|
||||
assignees: Wanxp
|
||||
|
||||
---
|
||||
|
||||
1. 问题说明
|
||||
|
||||
1.1 操作:
|
||||
比如进行同步电影时,无法获取我自己的评论...
|
||||
|
||||
1.2 结果:
|
||||
截图或者文本...
|
||||
```text
|
||||
---
|
||||
title: 英雄
|
||||
comment:
|
||||
---
|
||||
```
|
||||
1.3 我想要的效果:
|
||||
```text
|
||||
---
|
||||
title: 英雄
|
||||
comment: 我的评论
|
||||
---
|
||||
```
|
||||
|
||||
2. 书影音名称
|
||||
《英雄》
|
||||
|
||||
3. 模板展示
|
||||
```txt
|
||||
---
|
||||
title: {{name}}
|
||||
comment: {{myComment}}
|
||||
---
|
||||
```
|
||||
4. 其它
|
||||
如相关的插件设置...
|
||||
|
||||
5. 操作系统版本
|
||||
- [x] windows
|
||||
- [ ] ubuntu
|
||||
- [ ] mac
|
||||
- [ ] android
|
||||
- [ ] ios
|
||||
6. obisidian版本
|
||||
...
|
||||
10
.github/ISSUE_TEMPLATE/新功能建议-feature-request.md
vendored
@ -1,10 +0,0 @@
|
||||
---
|
||||
name: 新功能建议/Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: "[Feature]:"
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
|
||||
71
.github/workflows/pages.yml
vendored
@ -1,71 +0,0 @@
|
||||
# This workflow uses actions that are not certified by GitHub.
|
||||
# They are provided by a third-party and are governed by
|
||||
# separate terms of service, privacy policy, and support
|
||||
# documentation.
|
||||
|
||||
# Sample workflow for building and deploying a Jekyll site to GitHub Pages
|
||||
name: Deploy Jekyll site to Pages
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "master"
|
||||
paths:
|
||||
- "doc/**"
|
||||
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
# Allow one concurrent deployment
|
||||
concurrency:
|
||||
group: "pages"
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
# Build job
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: doc
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Setup Ruby
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: '3.3' # Not needed with a .ruby-version file
|
||||
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
||||
cache-version: 0 # Increment this number if you need to re-download cached gems
|
||||
working-directory: '${{ github.workspace }}/doc'
|
||||
|
||||
- name: Setup Pages
|
||||
id: pages
|
||||
uses: actions/configure-pages@v3
|
||||
- name: Build with Jekyll
|
||||
# Outputs to the './_site' directory by default
|
||||
run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"
|
||||
env:
|
||||
JEKYLL_ENV: production
|
||||
- name: Upload artifact
|
||||
# Automatically uploads an artifact from the './_site' directory by default
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
path: "doc/_site/"
|
||||
# Deployment job
|
||||
deploy:
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v4
|
||||
97
.github/workflows/release-draft.yml
vendored
@ -1,97 +0,0 @@
|
||||
name: Release Draft
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'manifest.json'
|
||||
branches:
|
||||
- "master"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
environment: node18
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '18'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
|
||||
- name: Build project
|
||||
run: npm run build
|
||||
|
||||
- name: Extract version from package.json
|
||||
id: extract_version
|
||||
run: echo "VERSION=$(jq -r '.version' package.json)" >> $GITHUB_ENV
|
||||
|
||||
- name: Set Git user
|
||||
run: |
|
||||
git config --global user.name "github-actions[bot]"
|
||||
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
- name: Create tag
|
||||
run: git tag -a "${{ env.VERSION }}" -m "Release version ${{ env.VERSION }}"
|
||||
|
||||
- name: Push tag
|
||||
run: git push origin "${{ env.VERSION }}"
|
||||
|
||||
- name: Create GitHub release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: "${{ env.VERSION }}"
|
||||
release_name: "${{ env.VERSION }}"
|
||||
draft: true
|
||||
prerelease: false
|
||||
generate_release_notes: true
|
||||
|
||||
- name: Upload release assets
|
||||
uses: actions/upload-release-asset@v1
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: ./main.js
|
||||
asset_name: main.js
|
||||
asset_content_type: application/javascript
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
VERSION: ${{ env.VERSION }}
|
||||
|
||||
- name: Upload manifest.json
|
||||
uses: actions/upload-release-asset@v1
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: ./manifest.json
|
||||
asset_name: manifest.json
|
||||
asset_content_type: application/json
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
VERSION: ${{ env.VERSION }}
|
||||
|
||||
- name: Upload style.css
|
||||
uses: actions/upload-release-asset@v1
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: ./styles.css
|
||||
asset_name: styles.css
|
||||
asset_content_type: text/css
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
VERSION: ${{ env.VERSION }}
|
||||
|
||||
- name: Output release message
|
||||
run: echo "发布预发布版本${{ env.VERSION }}正常"
|
||||
2
.gitignore
vendored
@ -20,5 +20,3 @@ data.json
|
||||
|
||||
# Exclude macOS Finder (System Explorer) View States
|
||||
.DS_Store
|
||||
doc/.vitepress/dist
|
||||
doc/.vitepress/cache
|
||||
|
||||
143
README.en.md
@ -1,143 +0,0 @@
|
||||
# Obsidian Douban Plugin
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/Wanxp/obsidian-douban/releases/latest">
|
||||
<img src="https://img.shields.io/github/manifest-json/v/Wanxp/obsidian-douban?color=blue">
|
||||
</a>
|
||||
<img src="https://img.shields.io/github/release-date/Wanxp/obsidian-douban">
|
||||
<a href="https://github.com/Wanxp/obsidian-douban/blob/master/License">
|
||||
<img src="https://img.shields.io/github/license/Wanxp/obsidian-douban">
|
||||
</a>
|
||||
<img src="https://img.shields.io/github/downloads/Wanxp/obsidian-douban/total">
|
||||
<a href="https://github.com/Wanxp/obsidian-douban/issues">
|
||||
<img src="https://img.shields.io/github/issues/Wanxp/obsidian-douban">
|
||||
</a>
|
||||
<br>
|
||||
<img src="https://img.shields.io/tokei/lines/github/Wanxp/obsidian-douban">
|
||||
<a href="https://www.codefactor.io/repository/github/wanxp/obsidian-douban">
|
||||
<img src="https://www.codefactor.io/repository/github/wanxp/obsidian-douban/badge" alt="CodeFactor" />
|
||||
</a>
|
||||
</p>
|
||||
|
||||
Bring your data from [Douban]() to Your [Obsidian](https://obsidian.md/)
|
||||
Including your _Movie, Book, Music, Teleplay, Note, Game_ even your personal State and Comment
|
||||

|
||||
|
||||
---
|
||||
If you want some features or have any questions about this plugin, create issues or join the development is welcome or ⭐Star
|
||||
|
||||
- [Bugs, Issues, & Feature Requests](https://github.com/Wanxp/obsidian-douban/issues)
|
||||
- Read Other Languages: English | [简体中文](README.md)
|
||||
|
||||
## Target
|
||||
- [x] Sync Personal Movie/TV/Book/Music
|
||||
- [x] Import Movie/Teleplay/Book/Music/Note/Game
|
||||
- [x] Personal Comment/State/Rate
|
||||
- [x] Custom Variables
|
||||
|
||||
## 效果
|
||||
1. 结合Timeline插件 __构建个人观影时间线__,请参照[结合timeline插件实现时间线效果](doc/Obsidian-Douban-TimeLine.md)
|
||||

|
||||
<!--2. 结合DataView插件,__构建个人电子书架(书库数据)__,请参照[结合dateview插件实现个人书架效果](./doc/Obsidian-Douban-DataView.md))-->
|
||||
2. 结合主题 __构建类豆瓣网页效果__,请参照[结合Blue Topaz实现网页效果](doc/Obsidian-Douban-BlueTopaz.md)
|
||||

|
||||
|
||||
## How to use
|
||||
### Sync
|
||||
- Sync Data From Douban
|
||||
Sync data from Douban (to learn how to use the TimeLine plugin to build a reading/movie watching timeline, please refer to [here](Obsidian-Douban-TimeLine.en.md)).
|
||||

|
||||
### Search
|
||||
Use the following method: Enter <kbd>Ctrl</kbd> + <kbd>P</kbd>, enter "Douban", select search and use
|
||||
- Search Data And Create Note
|
||||
- Search Data By File Name
|
||||
- Search Movie By Input Text
|
||||

|
||||
|
||||
|
||||
## Support Field
|
||||
(若有缺少想导入的字段, 欢迎提issues反馈)
|
||||
|
||||
| 字段 | 电影 | 电视剧 | 书籍 | 音乐 | 日记 | 游戏 | 广播 |
|
||||
|-----------------|-------------------|------------------|-------------------|----------------|----------------|---------------| ---- |
|
||||
| `id` | 豆瓣ID | 豆瓣ID | 豆瓣ID | 豆瓣ID | 豆瓣ID | 豆瓣ID | - |
|
||||
| `title` | 电影名称 | 电视剧名称 | 书名 | 音乐名 | 日记标题 | 游戏名称 | - |
|
||||
| `type` | 类型 | 类型 | 类型 | 类型 | 类型 | 类型 | - |
|
||||
| `score` | 评分 | 评分 | 评分 | 评分 | 评分 | 评分 | - |
|
||||
| `image` | 封面 | 封面 | 封面 | 封面 | 图片 | 封面 | - |
|
||||
| `url` | 豆瓣网址 | 豆瓣网址 | 豆瓣网址 | 豆瓣网址 | 豆瓣网址 | 豆瓣网址 | - |
|
||||
| `desc` | 简介 | 简介 | 内容简介 | 简介 | 简介 | 简介 | - |
|
||||
| `publisher` | - | - | 出版社 | 出版者 | 发布者 | 发行商 | - |
|
||||
| datePublished | 上映日期 | 上映日期 | 出版年 | 发行时间 | 发布时间 | 发行日期 | - |
|
||||
| yearPublished | 上映年份 | 上映年份 | 出版年份 | 发行年份 | 发布年份 | 发行年份 | - |
|
||||
| genre | 类型 | 类型 | - | 流派 | - | 类型 | - |
|
||||
| currentDate | 今日日期 | 今日日期 | 今日日期 | 今日日期 | 今日日期 | 今日日期 | |
|
||||
| currentTime | 当前时间 | 当前时间 | 当前时间 | 当前时间 | 当前时间 | 当前时间 | |
|
||||
| myTags | 我标记的标签 | 我标记的标签 | 我标记的标签 | 我标记的标签 | - | 我标记的标签 | |
|
||||
| myRating | 我的评分 | 我的评分 | 我的评分 | 我的评分 | - | 我的评分 |
|
||||
| myState | 状态:想看/在看/看过 | 状态:想看/在看/看过 | 状态:想看/在看/看过 | 状态:想听/在听/听过 | - | 状态:想玩/在玩/玩过 | |
|
||||
| myComment | 我的评语 | 我的评语 | 我的评语 | 我的评语 | - | 我的评语 | |
|
||||
| myCollectionDate | 我标记的时间 | 我标记的时间 | 我标记的时间 | 我标记的时间 | - | 我标记的时间 | |
|
||||
| 扩展1 | director:导演 | director:导演 | author:原作者 | actor: 表演者 | author:作者 | aliases:别名 | |
|
||||
| 扩展2 | author:编剧 | author:编剧 | translator:译者 | albumType:专辑类型 | authorUrl:作者网址 | developer:开发商 | |
|
||||
| 扩展3 | actor:主演 | actor:主演 | isbn:isbn | medium:介质 | content:日记内容 | platform:平台 | |
|
||||
| 扩展4 | originalTitle:原作名 | originalTitle:原作名 | originalTitle:原作名 | records:唱片数 | | | |
|
||||
| 扩展5 | country:国家 | country:国家 | subTitle:副标题 | barcode:条形码 | | | |
|
||||
| 扩展6 | language:语言 | language:语言 | totalPage:页数 | | | | |
|
||||
| 扩展7 | time:片长 | time:片长 | series:丛书 | | | | |
|
||||
| 扩展8 | aliases:又名 | aliases:又名 | menu:目录 | | | | |
|
||||
| 扩展9 | IMDb | IMDb | price:定价 | | | | |
|
||||
| 扩展7 | | episode:集数 | binding:装帧 | | | | |
|
||||
| 扩展8 | | | producer: 出品方 | | | | |
|
||||
|
||||
- Notice: myTags, myRating, myState, myComment, myCollectionDate. All parameters are available after logging in to the plugin.
|
||||
|
||||
|
||||
## How to install
|
||||
### From Obsidian
|
||||
1. Go to Obsidian plugin center
|
||||
2. Search obsidian-douban
|
||||
3. Click install
|
||||
4. Enable plugin
|
||||
|
||||
### Manmel
|
||||
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/`
|
||||
3. Enable plugin in Obsidian
|
||||
|
||||
## How to Develop
|
||||
1. Enter your test vault folder `/.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 chang
|
||||
`npm run dev`
|
||||
6. Go to your Obsidian plugin center reload this plugin
|
||||
7. Enjoy your develop
|
||||
|
||||
## Community
|
||||
<img src="doc/img/obsidian-douban-qq-qr_code.svg" width="300px"> <img src="doc/img/wechat_group.png" width="245px">
|
||||
|
||||
## Disclaimer
|
||||
1. This program does not crawl any content such as books and videos, and is only for technical research purposes. It does not violate the copyright of authors of books and videos or the official interests of Douban. If there is any infringement, please contact me to delete it.
|
||||
2. This program is for learning and communication only, and cannot be used for commercial purposes. Otherwise, the consequences will be at your own risk.
|
||||
3. Although every effort is made to avoid it, I am not responsible for any losses caused by the plug-in. Please refer to [here](#impact) for the impact of different operations.
|
||||
|
||||
## Impact
|
||||
Note: Except for checking "Replace documents with the same name" when synchronizing book and video data, which may modify notes with the same path and document name, other operations will not modify existing notes.
|
||||
|
||||
| Operation | Condition | Impact | Example |
|
||||
|-----------------|-----------------------|---------------------------|-----------------------------------------------------------------------------------------------|
|
||||
| Import book and video data | Default condition | Create a note named after the selected item | If you search for "Batman" and select it for import, a note titled "Batman" will be created |
|
||||
| Import book and video data | Note with the same name already exists | No impact, prompted that there is already a note with the same name, and the existing note will not be modified | If you search for "Batman" and select it for import, but there is already a note with the same path and name, a note will not be created |
|
||||
| Import book and video data | Configure the `note name` value to include the path | If there is no such path, it will create a file with the corresponding file name | If you search for "Batman" and select it for import, configure the `note name` value to be `/data/{{type}}/{{title}}`, a folder `data/Movie` will be created |
|
||||
| Import book and video data | Configure the `save image attachment` value to be checked | Save the cover image in the specified location of `attachment storage location` | If you search for "Batman" and select it for import, configure the `attachment storage location` value to be `assets`, the cover file `p462657443.jpg` will be saved in the `assets` folder |
|
||||
| Synchronize book and video data | All of the above | All of the above | All of the above |
|
||||
| Synchronize book and video data | Check the value of `replace the same document` | If the file with the same path and name already exists, overwrite it directly | If there is already a `data/Movie/Batman.md` file, configure the `note name` value to be `/data/{{type}}/{{title}}`, and check "Replace documents with the same name" when synchronizing book and video records, then `data/Movie/Batman.md` will be replaced with the latest one |
|
||||
|
||||
## Thanks
|
||||
### IDE support
|
||||
[<image src="doc/img/jb_beam.svg"> </image>](https://www.jetbrains.com/?from=obsidian-douban)
|
||||
238
README.md
@ -1,180 +1,92 @@
|
||||
# Obsidian Douban Plugin
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/Wanxp/obsidian-douban/releases/latest">
|
||||
<img src="https://img.shields.io/github/manifest-json/v/Wanxp/obsidian-douban?color=blue">
|
||||
</a>
|
||||
<img src="https://img.shields.io/github/release-date/Wanxp/obsidian-douban">
|
||||
<a href="https://github.com/Wanxp/obsidian-douban/blob/master/License">
|
||||
<img src="https://img.shields.io/github/license/Wanxp/obsidian-douban">
|
||||
</a>
|
||||
<img src="https://img.shields.io/github/downloads/Wanxp/obsidian-douban/total">
|
||||
<a href="https://github.com/Wanxp/obsidian-douban/issues">
|
||||
<img src="https://img.shields.io/github/issues/Wanxp/obsidian-douban">
|
||||
</a>
|
||||
<br>
|
||||
<img src="https://img.shields.io/tokei/lines/github/Wanxp/obsidian-douban">
|
||||
<a href="https://www.codefactor.io/repository/github/wanxp/obsidian-douban">
|
||||
<img src="https://www.codefactor.io/repository/github/wanxp/obsidian-douban/badge" alt="CodeFactor" />
|
||||
</a>
|
||||
</p>
|
||||
|
||||
这是一款[Obsidian](https://obsidian.md/)插件,支持在Obsidian中导入[豆瓣]()中的 _电影、书籍、音乐、电视剧、日记、游戏_
|
||||
甚至是 _你标记过的书影音_ , 包含你的评分、观看日期、评论、阅读状态等信息.
|
||||
|
||||
访问[Get Started/指导手册](https://obsidian-douban.wxp.hk/) 获取更多
|
||||
|
||||
[//]: # (访问[Get Started/指导手册](https://obsidian-douban.wanxuping.com/) 获取更多 )
|
||||

|
||||
|
||||
---
|
||||
关于当前的插件如果有任何疑问, 缺少想要的导入内容或者想要什么功能, 欢迎提issues或加入到开发当中.
|
||||
如果觉得喜欢或对您有帮助,欢迎一键三连-点亮 ⭐Star
|
||||
|
||||
- [异常, 问题 & 新的想法](https://github.com/Wanxp/obsidian-douban/issues)
|
||||
- 阅读其它语言的介绍请点击 [English](README.en.md) | 简体中文
|
||||
|
||||
## 功能
|
||||
- ☑️ 导入电影、电视剧、书籍、音乐、游戏、日记
|
||||
- ☑️ 同步个人听过/看过的电影、电视剧、书籍、音乐、游戏
|
||||
- ☑️ 导入个人的评论,评论时间,阅读状态,个人评分
|
||||
- ☑️ 支持保存封面至本地/图床
|
||||
- ⬜ 支持图床自定义
|
||||
- ☑️ 支持自定义参数
|
||||
- ☑️ 支持移动端导入
|
||||
- ⬜ 支持使用AI大模型ChatGPT、Deepseek、Ollama分析导入
|
||||
|
||||
## 效果
|
||||
1. 结合Timeline插件 __构建个人观影时间线__,请参照[结合timeline插件实现时间线效果](./doc/Obsidian-Douban-TimeLine.md)
|
||||

|
||||
<!--2. 结合DataView插件,__构建个人电子书架(书库数据)__,请参照[结合dateview插件实现个人书架效果](./doc/Obsidian-Douban-DataView.md))-->
|
||||
2. 结合主题 __构建类豆瓣网页效果__,请参照[结合Blue Topaz实现网页效果](./doc/Obsidian-Douban-BlueTopaz.md)
|
||||

|
||||
## 如何使用
|
||||
|
||||
### 搜索
|
||||
使用方式: 输入<kbd>Ctrl</kbd> + <kbd>P</kbd>,输入“豆瓣”或“Douban”,选择搜索并使用
|
||||
- 搜索数据并创建笔记
|
||||
- 通过当前文件名搜索
|
||||
- 通过输入文本搜索
|
||||

|
||||
### 同步
|
||||
- 同步个人的观影、观剧、阅读、游戏、音乐记录
|
||||

|
||||
## 设置
|
||||
- 设置豆瓣账号(可选,可使用少部分功能)
|
||||
- 设置导入模板(可选,不设置的情况下使用默认模板)
|
||||
- 设置导入路径(可选,不设置的情况下使用默认路径)
|
||||
[![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]
|
||||
|
||||
|
||||
## 支持的字段
|
||||
(若有缺少想导入的字段, 欢迎提issues反馈)
|
||||
Import Movies, Books, Music, Teleplay, Note, Game even Broadcast Data from Douban in [Obsidian](https://obsidian.md/)
|
||||
|
||||
| 字段 | 电影 | 电视剧 | 书籍 | 音乐 | 日记 | 游戏 | 人物 |
|
||||
|------------------|------------------|-------------------|-------------------|---------------|----------------|---------------|-------|
|
||||
| id | 豆瓣ID | 豆瓣ID | 豆瓣ID | 豆瓣ID | 豆瓣ID | 豆瓣ID | id |
|
||||
| title | 电影名称 | 电视剧名称 | 书名 | 音乐名 | 日记标题 | 游戏名称 | 姓名 |
|
||||
| type | 类型 | 类型 | 类型 | 类型 | 类型 | 类型 | 类型 |
|
||||
| score | 评分 | 评分 | 评分 | 评分 | 评分 | 评分 | |
|
||||
| scoreStar | 评分⭐ | 评分⭐ | 评分⭐ | 评分⭐ | 评分⭐ | 评分⭐ | |
|
||||
| image | 封面 | 封面 | 封面 | 封面 | 图片 | 封面 | 照片 |
|
||||
| imageData.url | 封面url | 封面url | 封面url | 封面url | 封面url | 封面url | 照片url |
|
||||
| url | 豆瓣网址 | 豆瓣网址 | 豆瓣网址 | 豆瓣网址 | 豆瓣网址 | 豆瓣网址 | 豆瓣网址 |
|
||||
| desc | 简介 | 简介 | 内容简介 | 简介 | 简介 | 简介 | 简介 |
|
||||
| publisher | - | - | 出版社 | 出版者 | 发布者 | 发行商 | - |
|
||||
| datePublished | 上映日期 | 上映日期 | 出版年 | 发行时间 | 发布时间 | 发行日期 | - |
|
||||
| yearPublished | 上映年份 | 上映年份 | 出版年份 | 发行年份 | 发布年份 | 发行年份 | - |
|
||||
| genre | 类型 | 类型 | - | 流派 | - | 类型 | - |
|
||||
| currentDate | 今日日期 | 今日日期 | 今日日期 | 今日日期 | 今日日期 | 今日日期 | |
|
||||
| currentTime | 当前时间 | 当前时间 | 当前时间 | 当前时间 | 当前时间 | 当前时间 | |
|
||||
| myTags | 我标记的标签 | 我标记的标签 | 我标记的标签 | 我标记的标签 | - | 我标记的标签 | |
|
||||
| myRating | 我的评分 | 我的评分 | 我的评分 | 我的评分 | - | 我的评分 |
|
||||
| myState | 状态:想看/在看/看过 | 状态:想看/在看/看过 | 状态:想看/在看/看过 | 状态:想听/在听/听过 | - | 状态:想玩/在玩/玩过 | |
|
||||
| myComment | 我的评语 | 我的评语 | 我的评语 | 我的评语 | - | 我的评语 | |
|
||||
| myCollectionDate | 我标记的时间 | 我标记的时间 | 我标记的时间 | 我标记的时间 | - | 我标记的时间 | |
|
||||
| 扩展1 | director:导演* | director:导演* | author:原作者 | actor: 表演者 | author:作者 | aliases:别名 | |
|
||||
| 扩展2 | author:编剧* | author:编剧* | translator:译者 | albumType:专辑类型 | authorUrl:作者网址 | developer:开发商 | |
|
||||
| 扩展3 | actor:主演* | actor:主演* | isbn:isbn | medium:介质 | content:日记内容 | platform:平台 | |
|
||||
| 扩展4 | originalTitle:原作名 | originalTitle:原作名 | originalTitle:原作名 | records:唱片数 | | | |
|
||||
| 扩展5 | country:国家 | country:国家 | subTitle:副标题 | barcode:条形码 | | | |
|
||||
| 扩展6 | language:语言 | language:语言 | totalPage:页数 | | | | |
|
||||
| 扩展7 | time:片长 | time:片长 | series:丛书 | | | | |
|
||||
| 扩展8 | aliases:又名* | aliases:又名* | menu:目录 | | | | |
|
||||
| 扩展9 | IMDb | IMDb | price:定价 | | | | |
|
||||
| 扩展7 | | episode:集数 | binding:装帧 | | | | |
|
||||
| 扩展8 | | | producer: 出品方 | | | | |
|
||||
在[Obsidian](https://obsidian.md/)使用并导入豆瓣中的电影/书籍/音乐/电视剧/日记/游戏甚至是广播, 包含评分/发布日期/演员表等信息
|
||||
|
||||
- 注: myTags, myRating, myRatingStar:⭐ , myState, myComment, myCollectionDate 参数均为在插件中登录后可用
|
||||
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)
|
||||
|
||||
|
||||
## 如何安装
|
||||
### 从Obsidian插件中心
|
||||
1. 进入Obsidian插件中心
|
||||
2. 搜索obsidian-douban
|
||||
3. 安装
|
||||
4. 开启插件
|
||||
## Target
|
||||
- [x] Movie/电影
|
||||
- [x] Teleplay/电视剧
|
||||
- [x] Book/书籍
|
||||
- [x] Music/音乐
|
||||
- [x] Note/日记
|
||||
- [x] Game/游戏
|
||||
- [ ] Broadcast/广播
|
||||
|
||||
### 手动安装
|
||||
## How to use
|
||||
### Movie
|
||||
- Search Movie By Input Text/通过输入文本搜索
|
||||

|
||||
|
||||
1. 从[Github release](https://github.com/Wanxp/obsidian-douban/releases) 页面下载 `main.js`, `manifest.json`, `styles.css`
|
||||
2. 将下载的文件复制到你的Obsidian文档根目录下的`/.obsidian/plugins/obsidian-douban`路径,若不存在则新建文件夹(注意.obsidian文件夹可能是个隐藏为文件夹)
|
||||
3. 在obsidian插件中心开启当前插件功能
|
||||
- Search Movie By File Name/通过文件名搜索
|
||||

|
||||
|
||||
## 如何开发调试
|
||||
### 开发
|
||||
1. 进入你的Obsidian测试文档文件夹下的`/.obsidian/plugins/`
|
||||
2. 克隆代码
|
||||
## Settings
|
||||
- Setting Example1/设置案例1
|
||||

|
||||
|
||||
|
||||
- Setting Example2/设置案例2
|
||||

|
||||
|
||||
## 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. 进入代码文件夹
|
||||
3. Enter folder/进入代码文件夹
|
||||
`cd obsidian-douban`
|
||||
4. install
|
||||
`npm install`
|
||||
5. 构建
|
||||
4. Build/构建
|
||||
`npm run build`
|
||||
6. 运行
|
||||
5. Run and Watch code change/运行
|
||||
`npm run dev`
|
||||
7. 进入Obsidian插件中心重新加载当前插件
|
||||
8. 享受开发吧
|
||||
#### 文档
|
||||
```shell
|
||||
npm run docs: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
|
||||
|
||||
## 交流社群
|
||||
<img src="doc/img/obsidian-douban-qq-qr_code.svg" width="300px"> <img src="doc/img/wechat_group.png" width="245px">
|
||||
|
||||
|
||||
[//]: # (<img src="doc/img/obsidian-douban-discord-qr_code.svg" width="300px"> )
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## 免责声明
|
||||
1. 建议使用本插件前,一定要至少有一种方式备份你的数据,以防万一。
|
||||
2. 本程序没有爬取任何书影音等内容,只供技术研究使用。没有侵犯书影音作者版权和豆瓣官方利益。如有任何侵权行为,请联系我删除。
|
||||
3. 本程序仅供学习交流使用。
|
||||
4. 虽然极力避免,但还是有可能纰漏,所以因使用插件造成的损失,由使用者本人承担。不同操作会有何种影响,请参照<a href="#impact">影响</a>
|
||||
5. 使用或修改本插件,即视为同意上述免责声明。
|
||||
## <span id="impact" >影响</span>
|
||||
注意: 除了在同步书影音数据时勾选 `替换同名文档` 有可能会修改同路径同文档名的笔记外,其余操作均不会修改已有笔记。
|
||||
|
||||
| 操作 | 条件 | 影响 | 举例 |
|
||||
|---------|------------------|---------------------------|-----------------------------------------------------------------------------------------------|
|
||||
| 导入书影音数据 | 默认条件 | 新建一条名为所选条目的笔记 | 如搜索蝙蝠侠并选中导入,则会创建笔记 《蝙蝠侠》 |
|
||||
| 导入书影音数据 | 已有同名笔记 | 无任何影响,提示已经存在同名笔记,不会修改已有笔记 | 如搜索蝙蝠侠并选中导入,但因存在同路径同名称笔记,则会不会创建笔记 |
|
||||
| 导入书影音数据 | 配置 `笔记名称`值包含路径 | 若没有此路径则会创建对应文件名 | 如搜索蝙蝠侠并选中导入,配置`笔记名称`值为`/data/{{type}}/{{title}}`,则会创建文件夹`data/电影` |
|
||||
| 导入书影音数据 | 配置 `保存图片附件`值为勾选 | 则会在`附件存放位置`指定位置保存封面图片 | 如搜索蝙蝠侠并选中导入,配置`附件存放位置`值为`assets`,则会在`assets`文件夹中保存封面文件`p462657443.jpg` |
|
||||
| 同步书影音数据 | 以上所有 | 以上所有 | 以上所有 |
|
||||
| 同步书影音数据 | `替换同名文档`值为勾选 | 已经存在 **同路径同文档名** ,直接覆盖 | 如已经存在在`data/Movie/蝙蝠侠.md`,配置`笔记名称`值为`/data/{{type}}/{{title}}`, 同步书影音记录时勾选 `替换同名文档`, 则`data/Movie/蝙蝠侠.md`会被替换成最新 |
|
||||
|
||||
|
||||
|
||||
[//]: # (### IDE支持)
|
||||
|
||||
[//]: # ([<image src="doc/img/jb_beam.svg"> </image>](https://www.jetbrains.com/?from=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,11 +0,0 @@
|
||||
编写github action ,完成以下目标:
|
||||
1. 当文件mainfest.json文件发生变更时才运行
|
||||
2. 提供node18 环境
|
||||
3. 执行npm install
|
||||
4. 执行npm run build
|
||||
5. 提取 package.json中的版本
|
||||
6. 将当前master创建为版本的tag
|
||||
7. 发布到github release 预发布版本,且版本的名称为当前版本
|
||||
8. 发布的信息从commit中提取
|
||||
9. 发布的内容为生成的main.js、mainfest.json、style.css 三个文件
|
||||
10. 输出内容: 发布预发布版本{版本}正常
|
||||
15
doc/.gitignore
vendored
@ -1,15 +0,0 @@
|
||||
# Not sure what a .gitignore is?
|
||||
# See: https://git-scm.com/docs/gitignore
|
||||
|
||||
# These are directly copied from Jekyll's first-party docs on `.gitignore` files:
|
||||
# https://jekyllrb.com/tutorials/using-jekyll-with-bundler/#commit-to-source-control
|
||||
|
||||
# Ignore the default location of the built site, and caches and metadata generated by Jekyll
|
||||
_site/
|
||||
.sass-cache/
|
||||
.jekyll-cache/
|
||||
.jekyll-metadata
|
||||
|
||||
# Ignore folders generated by Bundler
|
||||
.bundle/
|
||||
vendor/
|
||||
@ -1,56 +0,0 @@
|
||||
import { defineConfig } from 'vitepress'
|
||||
|
||||
// https://vitepress.dev/reference/site-config
|
||||
export default defineConfig({
|
||||
title: "Obsidian Douban",
|
||||
description: "Plugin for obsidian to manage your douban data",
|
||||
themeConfig: {
|
||||
lang: 'zh-CN',
|
||||
search: {
|
||||
provider: 'local'
|
||||
},
|
||||
// https://vitepress.dev/reference/default-theme-config
|
||||
logo: '/obsidian-douban-logo.png',
|
||||
nav: [
|
||||
{ text: '首页', link: '/' },
|
||||
{ text: '特殊效果', items: [
|
||||
{ text: '时间线效果', link: '/Obsidian-Douban-TimeLine' },
|
||||
{ text: '类网页效果', link: '/Obsidian-Douban-BlueTopaz' },
|
||||
{ text: '书架效果', link: 'Obsidian-Douban-DataView-Jump' }
|
||||
] },
|
||||
{ text: '作者', link: 'https://wxp.hk' },
|
||||
],
|
||||
|
||||
sidebar: [
|
||||
{
|
||||
text: '如何安装', link: '/10_install'
|
||||
},
|
||||
{ text: '使用说明', link: '/20_howtouse_10_detail' },
|
||||
{ text: '登录方式', link: '/20_howtouse_25_setting_login_douban_cookie' },
|
||||
{ text: '图床配置', link: '/20_howtouse_30_picturebed' },
|
||||
{ text: '功能支持', link: '/30_function_10' },
|
||||
{ text: '可用参数', link: '/30_function_20_support_variables' },
|
||||
{ text: '时间线效果', link: '/Obsidian-Douban-TimeLine' },
|
||||
{ text: '类网页效果', link: '/Obsidian-Douban-BlueTopaz' },
|
||||
{ text: '书架效果', link: 'Obsidian-Douban-DataView-Jump' },
|
||||
{ text: '数据影响', link: '/80_others_20_effect' },
|
||||
{ text: '免责声明', link: '/80_others_disclaimer' },
|
||||
{ text: '开发调试', link: '/70_develop' },
|
||||
{ text: '反馈建议', link: '/97_issues' },
|
||||
{ text: '支持作者', link: '/99_support' },
|
||||
|
||||
|
||||
],
|
||||
socialLinks: [
|
||||
{ icon: 'github', link: 'https://github.com/Wanxp/obsidian-douban' },
|
||||
// { icon: 'blog', link: 'https://github.com/Wanxp/obsidian-douban' }
|
||||
],
|
||||
lastUpdated: {
|
||||
text: '最后更新于',
|
||||
formatOptions: {
|
||||
dateStyle: 'full',
|
||||
timeStyle: 'medium'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -1,15 +0,0 @@
|
||||
:root {
|
||||
--vp-c-brand-1: #646cff;
|
||||
--vp-c-brand-2: #747bff;
|
||||
--vp-home-hero-name-color: transparent;
|
||||
--vp-home-hero-name-background: -webkit-linear-gradient(120deg, #34fe48, #bd34fe);
|
||||
--vp-home-hero-image-background-image: linear-gradient( 135deg, #34fe48 10%, #bd34fe 100%);
|
||||
--vp-home-hero-image-filter: blur(80px);
|
||||
/*--vp-home-hero-image-background-image: linear-gradient(*/
|
||||
/* -45deg,*/
|
||||
/* #34fe48 50%,*/
|
||||
/* #bd34fe 50%*/
|
||||
/*);*/
|
||||
/*--vp-home-hero-image-filter: blur(44px);*/
|
||||
}
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
import DefaultTheme from 'vitepress/theme'
|
||||
import './custom.css'
|
||||
|
||||
|
||||
export default DefaultTheme
|
||||
@ -1,16 +0,0 @@
|
||||
---
|
||||
title: 如何安装
|
||||
nav_order: 200
|
||||
---
|
||||
# 如何安装
|
||||
## 从Obsidian插件中心
|
||||
1. 进入Obsidian插件中心
|
||||
2. 搜索obsidian-douban
|
||||
3. 安装
|
||||
4. 开启插件
|
||||
|
||||
## 手动安装
|
||||
|
||||
1. 从[Github release](https://github.com/Wanxp/obsidian-douban/releases) 页面下载 `main.js`, `manifest.json`, `styles.css`
|
||||
2. 将下载的文件复制到你的Obsidian文档根目录下的`/.obsidian/plugins/obsidian-douban`路径,若不存在则新建文件夹(注意.obsidian文件夹可能是个隐藏为文件夹)
|
||||
3. 在obsidian插件中心开启当前插件功能
|
||||
@ -1,6 +0,0 @@
|
||||
---
|
||||
title: 如何使用
|
||||
layout: default
|
||||
nav_order: 300
|
||||
has_children: true
|
||||
---
|
||||
@ -1,17 +0,0 @@
|
||||
---
|
||||
title: 使用说明
|
||||
nav_order: 300
|
||||
parent: 如何使用
|
||||
---
|
||||
# 如何使用
|
||||
# 搜索
|
||||
使用方式: 输入<kbd>Ctrl</kbd> + <kbd>P</kbd>,输入“豆瓣”或“Douban”,选择搜索并使用
|
||||
- 搜索数据并创建笔记
|
||||
- 通过当前文件名搜索
|
||||
- 通过输入文本搜索
|
||||

|
||||
|
||||
|
||||
# 同步
|
||||
- 同步个人的观影、观剧、阅读、游戏、音乐记录
|
||||

|
||||
@ -1,11 +0,0 @@
|
||||
---
|
||||
title: 设置
|
||||
nav_order: 350
|
||||
parent: 如何使用
|
||||
---
|
||||
|
||||
# 设置
|
||||
- 设置豆瓣账号(可选,可使用少部分功能)
|
||||
- 设置导入模板(可选,不设置的情况下使用默认模板)
|
||||
- 设置导入路径(可选,不设置的情况下使用默认路径)
|
||||
|
||||
@ -1,32 +0,0 @@
|
||||
---
|
||||
title: Cookie登录Douban
|
||||
nav_order: 350
|
||||
parent: 如何使用
|
||||
---
|
||||
# 登录方式
|
||||
Obsidian-Douban插件提供了两种登录方式,扫码登录和Cookie登录。扫码登录是推荐的方式,但如果扫码登录失败,可以使用Cookie登录。
|
||||
## 扫码登录
|
||||
扫码登录是Obsidian-Douban插件的默认登录方式,适用于大多数用户。扫码登录的步骤如下:
|
||||
1. 在Obsidian-Douban插件设置中点击`登录按钮`
|
||||
2. 弹出扫码登录窗口
|
||||
3. 使用手机或其他设备的豆瓣APP 扫描二维码
|
||||
4. 在手机上确认登录
|
||||
5. 登录成功后,Obsidian-Douban插件会自动获取您的豆瓣账号信息
|
||||
## Cookie登录Douban
|
||||
此方式仅在Obsidian-Douban中点击`登录按钮`,弹窗后,扫码登录失败的用户
|
||||
### 操作
|
||||
1. 打开浏览器(此处默认为您使用的浏览器为Chrome或Chromium衍生浏览器)
|
||||
2. 访问[豆瓣网站](https://www.douban.com/)
|
||||
3. 在豆瓣网站中 登录豆瓣
|
||||
4. 再次访问`https://douban.com`
|
||||
5. 打开浏览器开发者工具(按键 ctrl + shift +i 或者 F12 或者 右键选择 检查)
|
||||
6. 选择开发者工具中的`网络`(Network)页签
|
||||
7. 在出现的页签中选择`全部`(All)
|
||||
8. 在出现的列表中网上翻找到最上面一条`www.douban.com`, 并点击
|
||||
9. 点击后出现的`请求头`(Headers) 栏目,找到`请求头`(Request Headers)
|
||||
10. 找到请求头中的Cookie,选中并复制右边的值
|
||||

|
||||
11. 然后回到Obsidian-Douban插件设置中,点击Cookie登录
|
||||
12. 将浏览器中复制的Cookie值粘贴到弹窗中的输入框中
|
||||
13. 点击确认
|
||||
|
||||
@ -1,21 +0,0 @@
|
||||
---
|
||||
title: 图床
|
||||
nav_order: 380
|
||||
parent: 如何使用
|
||||
---
|
||||
|
||||
# 图床
|
||||
## PicGo
|
||||
### 设置步骤
|
||||
1. 安装并下载PicGo图床软件
|
||||
2. 设置PicGo图床
|
||||
3. (由于Obsidian-Douban是通过剪贴板上传图片的)需要在PicGo设置中开启剪贴板上传
|
||||
4. 需要设置Server,开启并设置 端口36677
|
||||
5. 设置完成之后,可以尝试点击PicGo主界面的`剪贴板上传`按钮,验证是否可以上传图片
|
||||
6. 若在Obsidian-Douban设置中使用PicGo上传图片至图床,则每次导入书影音数据前,需要保证提前打开了PicGo软件
|
||||
### 注意事项
|
||||
Obsidian-Douban插件使用PicGo上传图片至图床仅在Linux系统下测试通过,其他系统未测试,其它系统有问题欢迎及时反馈
|
||||
#### Linux
|
||||
1. x11图形界面下,还需要安装xclip软件,否则无法使用剪贴板上传图片
|
||||
2. wayland图形界面下, 还需要安装wl-clipboard软件,否则无法使用剪贴板上传图片
|
||||
3. 若无法上传图片,可尝试开启PicGo软件设置中的`使用内置剪贴板上传`选项
|
||||
@ -1,6 +0,0 @@
|
||||
---
|
||||
title: 功能
|
||||
layout: default
|
||||
nav_order: 400
|
||||
has_children: true
|
||||
---
|
||||
@ -1,14 +0,0 @@
|
||||
---
|
||||
title: 基础功能
|
||||
nav_order: 400
|
||||
parent: 功能
|
||||
---
|
||||
# 功能
|
||||
- ☑️ 导入电影、电视剧、书籍、音乐、游戏、日记
|
||||
- ☑️ 同步个人听过/看过的电影、电视剧、书籍、音乐、游戏
|
||||
- ☑️ 导入个人的评论,评论时间,阅读状态,个人评分
|
||||
- ☑️ 支持保存封面至本地/图床
|
||||
- ⬜ 支持图床自定义
|
||||
- ☑️ 支持自定义参数
|
||||
- ☑️ 支持移动端导入
|
||||
- ⬜ 支持使用AI大模型ChatGPT、Deepseek、Ollama分析导入
|
||||
@ -1,42 +0,0 @@
|
||||
---
|
||||
title: 支持的参数
|
||||
nav_order: 500
|
||||
parent: 功能
|
||||
---
|
||||
|
||||
# 支持的字段
|
||||
(若有缺少想导入的字段, 欢迎提issues反馈)
|
||||
|
||||
| 字段 | 电影 | 电视剧 | 书籍 | 音乐 | 日记 | 游戏 | 人物 |
|
||||
|------------------|------------------|-------------------|-------------------|---------------|----------------|---------------|-------|
|
||||
| id | 豆瓣ID | 豆瓣ID | 豆瓣ID | 豆瓣ID | 豆瓣ID | 豆瓣ID | id |
|
||||
| title | 电影名称 | 电视剧名称 | 书名 | 音乐名 | 日记标题 | 游戏名称 | 姓名 |
|
||||
| type | 类型 | 类型 | 类型 | 类型 | 类型 | 类型 | 类型 |
|
||||
| score | 评分 | 评分 | 评分 | 评分 | 评分 | 评分 | |
|
||||
| scoreStar | 评分⭐ | 评分⭐ | 评分⭐ | 评分⭐ | 评分⭐ | 评分⭐ | |
|
||||
| image | 封面 | 封面 | 封面 | 封面 | 图片 | 封面 | 照片 |
|
||||
| imageData.url | 封面url | 封面url | 封面url | 封面url | 封面url | 封面url | 照片url |
|
||||
| url | 豆瓣网址 | 豆瓣网址 | 豆瓣网址 | 豆瓣网址 | 豆瓣网址 | 豆瓣网址 | 豆瓣网址 |
|
||||
| desc | 简介 | 简介 | 内容简介 | 简介 | 简介 | 简介 | 简介 |
|
||||
| publisher | - | - | 出版社 | 出版者 | 发布者 | 发行商 | - |
|
||||
| datePublished | 上映日期 | 上映日期 | 出版年 | 发行时间 | 发布时间 | 发行日期 | - |
|
||||
| yearPublished | 上映年份 | 上映年份 | 出版年份 | 发行年份 | 发布年份 | 发行年份 | - |
|
||||
| genre | 类型 | 类型 | - | 流派 | - | 类型 | - |
|
||||
| currentDate | 今日日期 | 今日日期 | 今日日期 | 今日日期 | 今日日期 | 今日日期 | |
|
||||
| currentTime | 当前时间 | 当前时间 | 当前时间 | 当前时间 | 当前时间 | 当前时间 | |
|
||||
| myTags | 我标记的标签 | 我标记的标签 | 我标记的标签 | 我标记的标签 | - | 我标记的标签 | |
|
||||
| myRating | 我的评分 | 我的评分 | 我的评分 | 我的评分 | - | 我的评分 |
|
||||
| myState | 状态:想看/在看/看过 | 状态:想看/在看/看过 | 状态:想看/在看/看过 | 状态:想听/在听/听过 | - | 状态:想玩/在玩/玩过 | |
|
||||
| myComment | 我的评语 | 我的评语 | 我的评语 | 我的评语 | - | 我的评语 | |
|
||||
| myCollectionDate | 我标记的时间 | 我标记的时间 | 我标记的时间 | 我标记的时间 | - | 我标记的时间 | |
|
||||
| 扩展1 | director:导演* | director:导演* | author:原作者 | actor: 表演者 | author:作者 | aliases:别名 | |
|
||||
| 扩展2 | author:编剧* | author:编剧* | translator:译者 | albumType:专辑类型 | authorUrl:作者网址 | developer:开发商 | |
|
||||
| 扩展3 | actor:主演* | actor:主演* | isbn:isbn | medium:介质 | content:日记内容 | platform:平台 | |
|
||||
| 扩展4 | originalTitle:原作名 | originalTitle:原作名 | originalTitle:原作名 | records:唱片数 | | | |
|
||||
| 扩展5 | country:国家 | country:国家 | subTitle:副标题 | barcode:条形码 | | | |
|
||||
| 扩展6 | language:语言 | language:语言 | totalPage:页数 | | | | |
|
||||
| 扩展7 | time:片长 | time:片长 | series:丛书 | | | | |
|
||||
| 扩展8 | aliases:又名* | aliases:又名* | menu:目录 | | | | |
|
||||
| 扩展9 | IMDb | IMDb | price:定价 | | | | |
|
||||
| 扩展7 | | episode:集数 | binding:装帧 | | | | |
|
||||
| 扩展8 | | | producer: 出品方 | | | | |
|
||||
@ -1,6 +0,0 @@
|
||||
---
|
||||
title: 特殊效果
|
||||
layout: default
|
||||
nav_order: 450
|
||||
has_children: true
|
||||
---
|
||||
@ -1,12 +0,0 @@
|
||||
---
|
||||
title: 效果介绍
|
||||
nav_order: 450
|
||||
parent: 特殊效果
|
||||
---
|
||||
|
||||
# 效果
|
||||
1. 结合Timeline插件 __构建个人观影时间线__,请参照[结合timeline插件实现时间线效果](Obsidian-Douban-TimeLine)
|
||||

|
||||
<!--2. 结合DataView插件,__构建个人电子书架(书库数据)__,请参照[结合dateview插件实现个人书架效果](Obsidian-Douban-DataView.md))-->
|
||||
2. 结合主题 __构建类豆瓣网页效果__,请参照[结合Blue Topaz实现网页效果](Obsidian-Douban-BlueTopaz)
|
||||

|
||||
@ -1,21 +0,0 @@
|
||||
---
|
||||
title: 开发
|
||||
nav_order: 700
|
||||
---
|
||||
|
||||
# 如何开发调试
|
||||
|
||||
1. 进入你的Obsidian测试文档文件夹下的`/.obsidian/plugins/`
|
||||
2. 克隆代码
|
||||
`git clone git@github.com:Wanxp/obsidian-douban.git`
|
||||
3. 进入代码文件夹
|
||||
`cd obsidian-douban`
|
||||
4. install
|
||||
`npm install`
|
||||
5. 构建
|
||||
`npm run build`
|
||||
6. 运行
|
||||
`npm run dev`
|
||||
7. 进入Obsidian插件中心重新加载当前插件
|
||||
8. 享受开发吧
|
||||
|
||||
@ -1,7 +0,0 @@
|
||||
---
|
||||
title: 其它
|
||||
layout: default
|
||||
nav_order: 750
|
||||
has_children: true
|
||||
---
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
---
|
||||
title: 数据影响
|
||||
nav_order: 800
|
||||
parent: 其它
|
||||
---
|
||||
|
||||
# 数据影响
|
||||
注意: 除了在同步书影音数据时勾选 `替换同名文档` 有可能会修改同路径同文档名的笔记外,其余操作均不会修改已有笔记。
|
||||
|
||||
| 操作 | 条件 | 影响 | 举例 |
|
||||
|---------|------------------|---------------------------|-----------------------------------------------------------------------------------------------|
|
||||
| 导入书影音数据 | 默认条件 | 新建一条名为所选条目的笔记 | 如搜索蝙蝠侠并选中导入,则会创建笔记 《蝙蝠侠》 |
|
||||
| 导入书影音数据 | 已有同名笔记 | 无任何影响,提示已经存在同名笔记,不会修改已有笔记 | 如搜索蝙蝠侠并选中导入,但因存在同路径同名称笔记,则会不会创建笔记 |
|
||||
| 导入书影音数据 | 配置 `笔记名称`值包含路径 | 若没有此路径则会创建对应文件名 | 如搜索蝙蝠侠并选中导入,配置`笔记名称`值为`/data/{{type}}/{{title}}`,则会创建文件夹`data/电影` |
|
||||
| 导入书影音数据 | 配置 `保存图片附件`值为勾选 | 则会在`附件存放位置`指定位置保存封面图片 | 如搜索蝙蝠侠并选中导入,配置`附件存放位置`值为`assets`,则会在`assets`文件夹中保存封面文件`p462657443.jpg` |
|
||||
| 同步书影音数据 | 以上所有 | 以上所有 | 以上所有 |
|
||||
| 同步书影音数据 | `替换同名文档`值为勾选 | 已经存在 **同路径同文档名** ,直接覆盖 | 如已经存在在`data/Movie/蝙蝠侠.md`,配置`笔记名称`值为`/data/{{type}}/{{title}}`, 同步书影音记录时勾选 `替换同名文档`, 则`data/Movie/蝙蝠侠.md`会被替换成最新 |
|
||||
@ -1,8 +0,0 @@
|
||||
---
|
||||
title: 鸣谢
|
||||
nav_order: 810
|
||||
parent: 其它
|
||||
---
|
||||
# 鸣谢
|
||||
## IDE支持
|
||||
[<image src="img/jb_beam.svg"> </image>](https://www.jetbrains.com/?from=obsidian-douban)
|
||||
@ -1,12 +0,0 @@
|
||||
---
|
||||
title: 免责声明
|
||||
nav_order: 820
|
||||
parent: 其它
|
||||
---
|
||||
|
||||
# 免责声明
|
||||
1. 建议使用本插件前,一定要至少有一种方式备份你的数据,以防万一。
|
||||
2. 本程序没有爬取任何书影音等内容,只供技术研究使用。没有侵犯书影音作者版权和豆瓣官方利益。如有任何侵权行为,请联系我删除。
|
||||
3. 本程序仅供学习交流使用。
|
||||
4. 虽然极力避免,但还是有可能纰漏,所以因使用插件造成的损失,由使用者本人承担。不同操作会有何种影响,请参照<a href="#impact">影响</a>
|
||||
5. 使用或修改本插件,即视为同意上述免责声明。
|
||||
@ -1,9 +0,0 @@
|
||||
---
|
||||
title: 反馈与建议
|
||||
nav_order: 950
|
||||
---
|
||||
|
||||
# 反馈与建议
|
||||
如果你有任何问题或建议,欢迎在提交[Issues](https://github.com/Wanxp/obsidian-douban/issues)
|
||||
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
---
|
||||
title: 支持
|
||||
nav_order: 1000
|
||||
---
|
||||
|
||||
# 支持
|
||||
愿世界充满爱与和平!
|
||||
如果觉得喜欢或对您有帮助,欢迎请我喝杯咖啡,让我有更多的动力去维护和更新插件
|
||||
|
||||

|
||||
|
||||
## 交流社群
|
||||
<img src="/img/obsidian-douban-qq-qr_code.svg" width="300px" style="display: inline-block;"><img src="/img/wechat_group.png" width="245px" style="display: inline-block;">
|
||||
|
||||
|
||||
或者[邮件联系我](mailto:977741432@qq.com)
|
||||
|
||||
10
doc/Gemfile
@ -1,10 +0,0 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gem "jekyll" # installed by `gem jekyll`
|
||||
# gem "webrick" # required when using Ruby >= 3 and Jekyll <= 4.2.2
|
||||
|
||||
gem "just-the-docs" # pinned to the current release
|
||||
# gem "just-the-docs" # always download the latest release
|
||||
|
||||
gem 'json'
|
||||
|
||||
@ -1,87 +0,0 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
addressable (2.8.6)
|
||||
public_suffix (>= 2.0.2, < 6.0)
|
||||
colorator (1.1.0)
|
||||
concurrent-ruby (1.2.3)
|
||||
em-websocket (0.5.3)
|
||||
eventmachine (>= 0.12.9)
|
||||
http_parser.rb (~> 0)
|
||||
eventmachine (1.2.7)
|
||||
ffi (1.16.3)
|
||||
forwardable-extended (2.6.0)
|
||||
google-protobuf (3.25.3-arm64-darwin)
|
||||
google-protobuf (3.25.3-x86_64-linux)
|
||||
http_parser.rb (0.8.0)
|
||||
i18n (1.14.4)
|
||||
concurrent-ruby (~> 1.0)
|
||||
jekyll (4.3.3)
|
||||
addressable (~> 2.4)
|
||||
colorator (~> 1.0)
|
||||
em-websocket (~> 0.5)
|
||||
i18n (~> 1.0)
|
||||
jekyll-sass-converter (>= 2.0, < 4.0)
|
||||
jekyll-watch (~> 2.0)
|
||||
kramdown (~> 2.3, >= 2.3.1)
|
||||
kramdown-parser-gfm (~> 1.0)
|
||||
liquid (~> 4.0)
|
||||
mercenary (>= 0.3.6, < 0.5)
|
||||
pathutil (~> 0.9)
|
||||
rouge (>= 3.0, < 5.0)
|
||||
safe_yaml (~> 1.0)
|
||||
terminal-table (>= 1.8, < 4.0)
|
||||
webrick (~> 1.7)
|
||||
jekyll-include-cache (0.2.1)
|
||||
jekyll (>= 3.7, < 5.0)
|
||||
jekyll-sass-converter (3.0.0)
|
||||
sass-embedded (~> 1.54)
|
||||
jekyll-seo-tag (2.8.0)
|
||||
jekyll (>= 3.8, < 5.0)
|
||||
jekyll-watch (2.2.1)
|
||||
listen (~> 3.0)
|
||||
json (2.7.2)
|
||||
just-the-docs (0.8.2)
|
||||
jekyll (>= 3.8.5)
|
||||
jekyll-include-cache
|
||||
jekyll-seo-tag (>= 2.0)
|
||||
rake (>= 12.3.1)
|
||||
kramdown (2.4.0)
|
||||
rexml
|
||||
kramdown-parser-gfm (1.1.0)
|
||||
kramdown (~> 2.0)
|
||||
liquid (4.0.4)
|
||||
listen (3.9.0)
|
||||
rb-fsevent (~> 0.10, >= 0.10.3)
|
||||
rb-inotify (~> 0.9, >= 0.9.10)
|
||||
mercenary (0.4.0)
|
||||
pathutil (0.16.2)
|
||||
forwardable-extended (~> 2.6)
|
||||
public_suffix (5.0.5)
|
||||
rake (13.2.1)
|
||||
rb-fsevent (0.11.2)
|
||||
rb-inotify (0.10.1)
|
||||
ffi (~> 1.0)
|
||||
rexml (3.2.6)
|
||||
rouge (4.2.1)
|
||||
safe_yaml (1.0.5)
|
||||
sass-embedded (1.69.5-arm64-darwin)
|
||||
google-protobuf (~> 3.23)
|
||||
sass-embedded (1.69.5-x86_64-linux-gnu)
|
||||
google-protobuf (~> 3.23)
|
||||
terminal-table (3.0.2)
|
||||
unicode-display_width (>= 1.1.1, < 3)
|
||||
unicode-display_width (2.5.0)
|
||||
webrick (1.8.1)
|
||||
|
||||
PLATFORMS
|
||||
arm64-darwin
|
||||
x86_64-linux-gnu
|
||||
|
||||
DEPENDENCIES
|
||||
jekyll (~> 4.3.3)
|
||||
json
|
||||
just-the-docs (= 0.8.2)
|
||||
|
||||
BUNDLED WITH
|
||||
2.5.9
|
||||
21
doc/LICENSE
@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 just-the-docs
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@ -1,127 +0,0 @@
|
||||
---
|
||||
title: 类豆瓣网页显示
|
||||
nav_order: 455
|
||||
parent: 特殊效果
|
||||
render_with_liquid: false
|
||||
---
|
||||
|
||||
## 效果如下
|
||||

|
||||
|
||||
## 适用人群
|
||||
1. 在豆瓣有标记/评论/评分的习惯的人
|
||||
比如看完电影,会在豆瓣进行评分或评论。或者阅读完的书籍,进行评分或评论。支持包含:电影、书籍、电视剧、音乐、游戏
|
||||
|
||||
## 实现步骤
|
||||
1. 安装[Blue Topaz](https://github.com/PKM-er/Blue-Topaz_Obsidian-css)插件, 可在Obsidian主题搜索中找到 `Blue Topaz`
|
||||
2. 安装[Obsidian-Douban](https://github.com/Wanxp/obsidian-douban)插件(本插件)
|
||||
3. 在Obsidian-Douban插件配置中登录Douban
|
||||
4. 配置需要的模板文件, 在模板中 ==增加== 以下内容,如下所示
|
||||
|
||||
|
||||
````markdown
|
||||
---
|
||||
|
||||
# {{title}}
|
||||
<div style="text-align: center;">{{originalTitle}}</div>
|
||||
<div style="text-align: center;">{{scoreStar}}</div>
|
||||
|
||||
---
|
||||
|
||||
> [!bookinfo|noicon]+ 🗒️ **简介**
|
||||
> 
|
||||
>
|
||||
| 属性 | 内容 |
|
||||
|:-------- |:------------------------ |
|
||||
| 笔记 | [[摘录:{{title}}]] |
|
||||
| 作者 | {{author(ArrayType1)}} |
|
||||
| 译者 | {{translator(ArrayType1)}} |
|
||||
| 来源 | [ {{title}} ]( {{url}} ) |
|
||||
| 网站评分 | {{score}} |
|
||||
| 出版发行 | {{publisher}} |
|
||||
| 原作名 | {{originalTitle}} |
|
||||
| 出版年份 | {{yearPublished}} |
|
||||
|
||||
> [!note]- 书籍简介\
|
||||
> {{desc}}
|
||||
|
||||
---
|
||||
### 评论
|
||||
|
||||
{{myComment}}
|
||||
````
|
||||
|
||||
|
||||
5. 设置模板为上面的模板
|
||||
6. 增加数组输出形式
|
||||
进入插件设置界面,找到[数组输出]
|
||||
|
||||
## 模板参考
|
||||
### 书籍
|
||||
|
||||
````markdown
|
||||
---
|
||||
doubanId: {{id}}
|
||||
title: {{title}}
|
||||
subTitle: {{subTitle}}
|
||||
originalTitle: {{originalTitle}}
|
||||
series: {{series}}
|
||||
type: {{type}}
|
||||
author: {{author}}
|
||||
score: {{score}}
|
||||
scoreStar: {{scoreStar}}
|
||||
myRating: {{myRating}}
|
||||
datePublished: {{datePublished}}
|
||||
translator: {{translator}}
|
||||
publisher: {{publisher}}
|
||||
producer: {{producer}}
|
||||
isbn: {{isbn}}
|
||||
url: {{url}}
|
||||
totalPage: {{totalPage}}
|
||||
price: {{price}}
|
||||
tags: {{myTags}}
|
||||
state: {{myState}}
|
||||
binding: {{binding}}
|
||||
createTime: {{currentDate}} {{currentTime}}
|
||||
collectionDate: {{myCollectionDate}}
|
||||
desc: {{desc}}
|
||||
---
|
||||
|
||||
# {{title}}
|
||||
<div style="text-align: center;">{{originalTitle}}</div>
|
||||
<div style="text-align: center;">{{scoreStar}}</div>
|
||||
|
||||
---
|
||||
|
||||
> [!bookinfo|noicon]+ 🗒️ **简介**
|
||||
> 
|
||||
>
|
||||
| 属性 | 内容 |
|
||||
|:-------- |:------------------------ |
|
||||
| 笔记 | [[摘录:{{title}}]] |
|
||||
| 作者 | {{author(ArrayType1)}} |
|
||||
| 译者 | {{translator(ArrayType1)}} |
|
||||
| 来源 | [ {{title}} ]( {{url}} ) |
|
||||
| 网站评分 | {{score}} |
|
||||
| 出版发行 | {{publisher}} |
|
||||
| 原作名 | {{originalTitle}} |
|
||||
| 出版年份 | {{yearPublished}} |
|
||||
|
||||
> [!note]- 书籍简介\
|
||||
> {{desc}}
|
||||
|
||||
---
|
||||
### 评论
|
||||
|
||||
{{myComment}}
|
||||
|
||||
### 目录
|
||||
|
||||
{{menu}}
|
||||
````
|
||||
|
||||
## 电影、电视剧、音乐、游戏
|
||||
请参照书籍模板
|
||||
|
||||
## 更多
|
||||
此效果来自热心用户的分享,感谢
|
||||
@ -1,3 +0,0 @@
|
||||
## 书架效果
|
||||
点击以下链接跳转至少数派
|
||||
[使用Obsidian打造个人图书馆!](https://sspai.com/post/85574)
|
||||
@ -1,69 +0,0 @@
|
||||
## 效果如下
|
||||

|
||||
## 适用人群
|
||||
1. 在豆瓣有标记/评论/评分的习惯的人
|
||||
比如看完电影,会在豆瓣进行评分或评论。或者阅读完的书籍,进行评分或评论。支持包含:电影、书籍、电视剧、音乐、游戏
|
||||
## 实现步骤
|
||||
1. 安装[obsidian-dataview](https://github.com/blacksmithgu/obsidian-dataview)插件
|
||||
2. 安装[Obsidian-Douban](https://github.com/Wanxp/obsidian-douban)插件(本插件)
|
||||
3. 在Obsidian-Douban插件配置中登录Douban
|
||||
4. 配置同步需要的模板 电影/书籍的模板中的frontmatter,在frontmatter中 **增加** 特定tags(根据自己的需要指定),用于需要过滤成为timeline的笔记,如增加tags:`书籍`
|
||||
````markdown
|
||||
---
|
||||
tags: 书籍
|
||||
---
|
||||
````
|
||||
5. 同时,在电影/书籍... 模板中的 **最后增加** timeline插件需要的html标签如下:
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
6. 选择上述模板导入 电影/书籍...,操作方式是打开obsidian命令窗口,输入豆瓣,找到导入功能,在导入界面配置 选择模板进行导入
|
||||
7. 导入需要一定时间,每条内容导入需要15-30s左右,所有有导入完成后会有导入汇总
|
||||
8. 导入完成后,新建一个笔记,笔记内容加入DataView的代码块,指定搜索上面指定的tags的内容,如`书籍`,代码块如下:
|
||||
````markdown
|
||||
```dataview
|
||||
table file.name
|
||||
```
|
||||
````
|
||||
9. 预览这个笔记就能看出已经出现了时间线
|
||||
## 模板参考
|
||||
### 电影
|
||||
````markdown
|
||||
---
|
||||
doubanId: {{id}}
|
||||
title: {{title}}
|
||||
type: {{type}}
|
||||
score: {{score}}
|
||||
myRate: {{myRate}}
|
||||
originalTitle: {{originalTitle}}
|
||||
genre: {{genre}}
|
||||
datePublished: {{datePublished}}
|
||||
director: {{director}}
|
||||
actor: {{actor}}
|
||||
author: {{author}}
|
||||
tags: {{type}}, 我看过的电影, {{myTags}}
|
||||
state: {{myState}}
|
||||
url: {{url}}
|
||||
coverUrl: {{imageData.url}}
|
||||
createTime: {{currentDate}} {{currentTime}}
|
||||
collectionDate: {{myCollectionDate}}
|
||||
desc: {{desc}}
|
||||
---
|
||||
|
||||

|
||||
|
||||
Comment:
|
||||
---
|
||||
{{myComment}}
|
||||
|
||||
|
||||
<span class='ob-timelines' data-date='{{myCollectionDate}}'
|
||||
data-title='{{title}}' data-img='{{image}}'
|
||||
data-class = "custom-my-movie-time-line">{{myComment}} |简介: {{desc}}
|
||||
</span>
|
||||
````
|
||||
### 书籍、电视剧、音乐、游戏
|
||||
请参照电影模板
|
||||
## 更多
|
||||
参照讨论 [结合timeline插件的妙用](https://github.com/Wanxp/obsidian-douban/issues/19#issuecomment-1428307130)
|
||||
@ -1,93 +0,0 @@
|
||||
---
|
||||
title: 看剧时间线
|
||||
nav_order: 456
|
||||
parent: 特殊效果
|
||||
render_with_liquid: false
|
||||
---
|
||||
|
||||
## 效果如下
|
||||

|
||||
|
||||
## 适用人群
|
||||
1. 在豆瓣有标记/评论/评分的习惯的人
|
||||
比如看完电影,会在豆瓣进行评分或评论。或者阅读完的书籍,进行评分或评论。支持包含:电影、书籍、电视剧、音乐、游戏
|
||||
|
||||
## 实现步骤
|
||||
1. 安装[Timelines](https://github.com/Darakah/obsidian-timelines)插件
|
||||
2. 安装[Obsidian-Douban](https://github.com/Wanxp/obsidian-douban)插件(本插件)
|
||||
3. 在Obsidian-Douban插件配置中登录Douban
|
||||
4. 配置同步需要的模板 电影/书籍的模板中的frontmatter,在frontmatter中 **增加** 特定tags(根据自己的需要指定),用于需要过滤成为timeline的笔记,如增加tags:`我看过的电影`
|
||||
|
||||
|
||||
````markdown
|
||||
---
|
||||
tags: 我看过的电影
|
||||
---
|
||||
````
|
||||
5. 同时,在电影/书籍... 模板中的 **最后增加** timeline插件需要的html标签如下:
|
||||
|
||||
```html
|
||||
<span class='ob-timelines' data-date='{{myCollectionDate}}'
|
||||
data-title='{{title}}' data-img='{{image}}'
|
||||
data-class = "custom-my-movie-time-line">{{myComment}} |简介: {{desc}}
|
||||
</span>
|
||||
```
|
||||
6. 选择上述模板导入 电影/书籍...,操作方式是打开obsidian命令窗口,输入豆瓣,找到导入功能,在导入界面配置 选择模板进行导入
|
||||
7. 导入需要一定时间,每条内容导入需要15-30s左右,所有有导入完成后会有导入汇总
|
||||
8. 导入完成后,新建一个笔记,笔记内容加入timeline的代码块,代码块的内容就是你上面指定的tags的内容,如`我看过的电影`,代码块如下:
|
||||
|
||||
````markdown
|
||||
```timeline
|
||||
我看过的电影
|
||||
```
|
||||
````
|
||||
|
||||
|
||||
9. 预览这个笔记就能看出已经出现了时间线
|
||||
|
||||
## 模板参考
|
||||
### 电影
|
||||
|
||||
|
||||
````markdown
|
||||
---
|
||||
doubanId: {{id}}
|
||||
title: {{title}}
|
||||
type: {{type}}
|
||||
score: {{score}}
|
||||
myRate: {{myRate}}
|
||||
originalTitle: {{originalTitle}}
|
||||
genre: {{genre}}
|
||||
datePublished: {{datePublished}}
|
||||
director: {{director}}
|
||||
actor: {{actor}}
|
||||
author: {{author}}
|
||||
tags: {{type}}, 我看过的电影, {{myTags}}
|
||||
state: {{myState}}
|
||||
url: {{url}}
|
||||
coverUrl: {{imageData.url}}
|
||||
createTime: {{currentDate}} {{currentTime}}
|
||||
collectionDate: {{myCollectionDate}}
|
||||
desc: {{desc}}
|
||||
---
|
||||
|
||||

|
||||
|
||||
Comment:
|
||||
---
|
||||
{{myComment}}
|
||||
|
||||
|
||||
<span class='ob-timelines' data-date='{{myCollectionDate}}'
|
||||
data-title='{{title}}' data-img='{{image}}'
|
||||
data-class = "custom-my-movie-time-line">{{myComment}} |简介: {{desc}}
|
||||
</span>
|
||||
````
|
||||
|
||||
|
||||
## 书籍、电视剧、音乐、游戏
|
||||
请参照电影模板
|
||||
|
||||
## 更多
|
||||
此效果来自热心用户的分享,感谢[](https://github.com/eryajf)
|
||||
参照讨论 [结合timeline插件的妙用](https://github.com/Wanxp/obsidian-douban/issues/19#issuecomment-1428307130)
|
||||
@ -1,10 +0,0 @@
|
||||
title: Obsidian-Douban
|
||||
description: This is a plugin that can import movies/books/musics/notes/games info data from Douban for Obsidian .
|
||||
theme: just-the-docs
|
||||
|
||||
url: https://wanxp.github.io/obsidian-douban
|
||||
|
||||
aux_links: # remove if you don't want this link to appear on your pages
|
||||
Obsidian-Douban on Github: https://github.com/Wanxp/obsidian-douban
|
||||
search:
|
||||
focus_shortcut_key: 'k'
|
||||
|
Before Width: | Height: | Size: 235 KiB |
@ -1 +0,0 @@
|
||||
<svg height="180" viewBox="0 0 180 180" width="180" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><linearGradient id="a" gradientUnits="userSpaceOnUse" x1="32.64" x2="82.77" y1="61.16" y2="85.54"><stop offset=".21" stop-color="#fe2857"/><stop offset="1" stop-color="#293896"/></linearGradient><linearGradient id="b" gradientUnits="userSpaceOnUse" x1="17.38" x2="82.95" y1="69.86" y2="21.23"><stop offset="0" stop-color="#fe2857"/><stop offset=".01" stop-color="#fe2857"/><stop offset=".86" stop-color="#ff318c"/></linearGradient><linearGradient id="c" gradientUnits="userSpaceOnUse" x1="74.17" x2="160.27" y1="21.58" y2="99.76"><stop offset=".02" stop-color="#ff318c"/><stop offset=".21" stop-color="#fe2857"/><stop offset=".86" stop-color="#fdb60d"/></linearGradient><linearGradient id="d" gradientUnits="userSpaceOnUse" x1="155.46" x2="55.07" y1="89.8" y2="158.9"><stop offset=".01" stop-color="#fdb60d"/><stop offset=".86" stop-color="#fcf84a"/></linearGradient><path d="m81.56 83.71-41.35-35a15 15 0 1 0 -14.47 25.7h.15l.39.12 52.16 15.89a3.53 3.53 0 0 0 1.18.21 3.73 3.73 0 0 0 1.93-6.91z" fill="url(#a)"/><path d="m89.85 25.93a10.89 10.89 0 0 0 -16.85-9.18l-50.5 30.66a15 15 0 1 0 17.9 24l45.27-36.89.36-.3a10.93 10.93 0 0 0 3.82-8.29z" fill="url(#b)"/><path d="m163.29 92-76.62-73.79a10.91 10.91 0 1 0 -14.81 16l.14.12 81.4 68.58a7.36 7.36 0 0 0 12.09-5.65 7.39 7.39 0 0 0 -2.2-5.26z" fill="url(#c)"/><path d="m165.5 97.29a7.35 7.35 0 0 0 -11.67-6l-92.71 45.3a15 15 0 1 0 15.48 25.59l85.73-58.84a7.35 7.35 0 0 0 3.17-6.05z" fill="url(#d)"/><path d="m60 60h60v60h-60z"/><g fill="#fff"><path d="m66.53 108.75h22.5v3.75h-22.5z"/><path d="m65.59 75.47 1.67-1.58a1.88 1.88 0 0 0 1.47.87c.64 0 1.06-.45 1.06-1.32v-5.92h2.58v5.94a3.44 3.44 0 0 1 -.92 2.63 3.52 3.52 0 0 1 -2.57 1 3.84 3.84 0 0 1 -3.29-1.62z"/><path d="m73.53 67.52h7.53v2.19h-5v1.43h4.49v2h-4.45v1.49h5v2.2h-7.6z"/><path d="m84.73 69.79h-2.8v-2.27h8.21v2.27h-2.81v7.09h-2.6z"/><path d="m66.63 80.58h4.42a3.47 3.47 0 0 1 2.55.83 2.09 2.09 0 0 1 .61 1.52 2.18 2.18 0 0 1 -1.45 2.09 2.27 2.27 0 0 1 1.86 2.29c0 1.69-1.31 2.69-3.55 2.69h-4.44zm5 2.89c0-.52-.42-.8-1.18-.8h-1.29v1.64h1.25c.78 0 1.24-.27 1.24-.81zm-.9 2.66h-1.57v1.73h1.62c.8 0 1.24-.31 1.24-.86-.02-.53-.4-.87-1.27-.87z"/><path d="m75.45 80.58h4.15a4.14 4.14 0 0 1 3.05 1 2.92 2.92 0 0 1 .83 2.18 3 3 0 0 1 -1.93 2.89l2.24 3.35h-3l-1.89-2.84h-.87v2.84h-2.6zm4 4.5c.87 0 1.4-.43 1.4-1.12 0-.75-.55-1.13-1.41-1.13h-1.39v2.27z"/><path d="m87.09 80.51h2.5l4 9.44h-2.79l-.67-1.69h-3.63l-.67 1.74h-2.71zm2.28 5.73-1.05-2.65-1.06 2.65z"/><path d="m94 80.55h2.6v9.37h-2.6z"/><path d="m97.56 80.55h2.44l3.37 5v-5h2.57v9.37h-2.27l-3.53-5.14v5.14h-2.58z"/><path d="m106.37 88.53 1.44-1.73a4.86 4.86 0 0 0 3 1.13c.71 0 1.08-.25 1.08-.65 0-.41-.3-.61-1.59-.91-2-.46-3.53-1-3.53-2.93 0-1.74 1.38-3 3.63-3a5.88 5.88 0 0 1 3.85 1.25l-1.25 1.78a4.56 4.56 0 0 0 -2.62-.92c-.63 0-.94.25-.94.6 0 .43.32.62 1.63.91 2.15.47 3.48 1.17 3.48 2.92 0 1.91-1.51 3-3.78 3a6.56 6.56 0 0 1 -4.4-1.45z"/></g><path d="m0 0h180v180h-180z" fill="none"/></svg>
|
||||
|
Before Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 117 KiB |
|
Before Width: | Height: | Size: 9.8 KiB |
|
Before Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 356 KiB |
|
Before Width: | Height: | Size: 492 KiB |
|
Before Width: | Height: | Size: 3.2 MiB |
|
Before Width: | Height: | Size: 2.6 MiB |
|
Before Width: | Height: | Size: 494 KiB |
|
Before Width: | Height: | Size: 2.8 MiB |
|
Before Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 57 KiB |
34
doc/index.md
@ -1,34 +0,0 @@
|
||||
---
|
||||
# https://vitepress.dev/reference/default-theme-home-page
|
||||
layout: home
|
||||
|
||||
hero:
|
||||
name: "Obsidian Douban"
|
||||
text: "obsidian插件\n同步你的豆瓣书影音"
|
||||
tagline:
|
||||
image:
|
||||
src: /obsidian-douban-logo.png
|
||||
alt: Obsidian Douban Logo
|
||||
actions:
|
||||
- theme: brand
|
||||
text: 开始使用
|
||||
link: /20_howtouse_10_detail
|
||||
- theme: alt
|
||||
text: 安装
|
||||
link: /10_install
|
||||
|
||||
features:
|
||||
- title: 搜索导入影音
|
||||
icon: 📘
|
||||
details: 搜索豆瓣中您喜欢的电影、电视剧、书籍、音乐、游戏等信息结构化并导入到Obsidian中
|
||||
link: /20_howtouse_10_detail
|
||||
- title: 同步个人数据
|
||||
icon: 🙋
|
||||
details: 登录后可同步个人的观影、观剧、阅读、游戏、音乐记录到您的Obsidian中
|
||||
link: /20_howtouse_10_detail
|
||||
- title: 建立个人书架
|
||||
icon: 📚
|
||||
details: 结合DataView生成,整合你的书籍,建立个人书架,统一管理
|
||||
link: /Obsidian-Douban-DataView-Jump
|
||||
---
|
||||
|
||||
|
Before Width: | Height: | Size: 780 KiB |
BIN
doc/search_by_file_name.gif
Normal file
|
After Width: | Height: | Size: 594 KiB |
BIN
doc/search_by_input.gif
Normal file
|
After Width: | Height: | Size: 2.4 MiB |
BIN
doc/setting_en.gif
Normal file
|
After Width: | Height: | Size: 1.6 MiB |
BIN
doc/setting_zh.gif
Normal file
|
After Width: | Height: | Size: 1.4 MiB |
@ -15,7 +15,7 @@ esbuild.build({
|
||||
banner: {
|
||||
js: banner,
|
||||
},
|
||||
entryPoints: ['src/org/wanxp/main.ts'],
|
||||
entryPoints: ['main.ts'],
|
||||
bundle: true,
|
||||
external: [
|
||||
'obsidian',
|
||||
@ -35,7 +35,7 @@ esbuild.build({
|
||||
'@codemirror/panel',
|
||||
'@codemirror/rangeset',
|
||||
'@codemirror/rectangular-selection',
|
||||
'@codemirror/searcher',
|
||||
'@codemirror/search',
|
||||
'@codemirror/state',
|
||||
'@codemirror/stream-parser',
|
||||
'@codemirror/text',
|
||||
@ -46,8 +46,8 @@ esbuild.build({
|
||||
watch: !prod,
|
||||
target: 'es2016',
|
||||
logLevel: "info",
|
||||
sourcemap: prod ? false : true,
|
||||
sourcemap: prod ? false : 'inline',
|
||||
treeShaking: true,
|
||||
outfile: 'main.js',
|
||||
// minify: true
|
||||
minify: true
|
||||
}).catch(() => process.exit(1));
|
||||
|
||||
85
main.ts
Normal file
@ -0,0 +1,85 @@
|
||||
import { DEFAULT_SETTINGS, DoubanPluginSettings } from "./src/douban/Douban";
|
||||
import { Editor, Plugin } from "obsidian";
|
||||
|
||||
import { DoubanFuzzySuggester } from "src/douban/data/search/DoubanSearchFuzzySuggestModal";
|
||||
import { DoubanSearchChooseItemHandler } from "src/douban/data/handler/DoubanSearchChooseItemHandler";
|
||||
import { DoubanSearchModal } from "src/douban/data/search/DoubanSearchModal";
|
||||
import { DoubanSettingTab } from "src/douban/DoubanSettingTab";
|
||||
import DoubanSubject from "src/douban/data/model/DoubanSubject";
|
||||
import Searcher from "src/douban/data/search/Search";
|
||||
import { i18nHelper } from './src/lang/helper';
|
||||
import { log } from "src/utils/Logutil";
|
||||
|
||||
export default class DoubanPlugin extends Plugin {
|
||||
public settings: DoubanPluginSettings;
|
||||
public doubanEtractHandler: DoubanSearchChooseItemHandler;
|
||||
|
||||
async putToEditor(editor:Editor, extract:DoubanSubject) {
|
||||
if(!editor || !extract) {
|
||||
log.warn(i18nHelper.getMessage('140101'));
|
||||
return;
|
||||
}
|
||||
let content:string = this.doubanEtractHandler.parseText(extract, this.settings)
|
||||
if(content) {
|
||||
editor.replaceSelection(content);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async search(searchTerm:string, editor: Editor) {
|
||||
const resultList = await Searcher.search(searchTerm, this.settings);
|
||||
new DoubanFuzzySuggester(this, editor).showSearchList(resultList);
|
||||
}
|
||||
|
||||
async getDoubanTextForActiveFile(editor: Editor) {
|
||||
const activeFile = await this.app.workspace.getActiveFile();
|
||||
if (activeFile) {
|
||||
const searchTerm = activeFile.basename;
|
||||
if (searchTerm) {
|
||||
await this.search(searchTerm, editor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async geDoubanTextForSearchTerm(editor: Editor) {
|
||||
new DoubanSearchModal(this.app, this, editor).open();
|
||||
}
|
||||
|
||||
async onload() {
|
||||
await this.loadSettings();
|
||||
|
||||
this.addCommand({
|
||||
id: "search-douban-by-current-file-name",
|
||||
name: i18nHelper.getMessage("110001"),
|
||||
editorCallback: (editor: Editor) =>
|
||||
this.getDoubanTextForActiveFile(editor),
|
||||
});
|
||||
|
||||
|
||||
this.addCommand({
|
||||
id: "search-douban-and-input-current-file",
|
||||
name: i18nHelper.getMessage("110002"),
|
||||
editorCallback: (editor: Editor) =>
|
||||
this.geDoubanTextForSearchTerm(editor),
|
||||
});
|
||||
//TODO will support in future
|
||||
// this.addCommand({
|
||||
// id: "sync-douban-broadcast-by-user-id",
|
||||
// name: i18nHelper.getMessage('110006'),
|
||||
// editorCallback: (editor: Editor) =>
|
||||
// this.geDoubanTextForSearchTerm(editor),
|
||||
// });
|
||||
|
||||
this.addSettingTab(new DoubanSettingTab(this.app, this));
|
||||
}
|
||||
|
||||
async loadSettings() {
|
||||
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
|
||||
this.doubanEtractHandler = new DoubanSearchChooseItemHandler(this.app, this);
|
||||
}
|
||||
|
||||
async saveSettings() {
|
||||
await this.saveData(this.settings);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "obsidian-douban-plugin",
|
||||
"name": "Douban",
|
||||
"version": "2.3.2",
|
||||
"version": "v1.5.0",
|
||||
"minAppVersion": "0.12.0",
|
||||
"description": "This is a plugin that can import movies/books/musics/notes/games info data from Douban for Obsidian .",
|
||||
"author": "Wanxp",
|
||||
|
||||
3461
package-lock.json
generated
Normal file
12
package.json
@ -1,16 +1,13 @@
|
||||
{
|
||||
"name": "obsidian-douban-plugin",
|
||||
"version": "2.3.2",
|
||||
"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",
|
||||
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
|
||||
"version": "node version-bump.mjs && git add manifest.json versions.json",
|
||||
"test": "jest",
|
||||
"docs:dev": "vitepress dev doc",
|
||||
"docs:build": "vitepress build doc",
|
||||
"docs:preview": "vitepress preview doc"
|
||||
"test": "jest"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
@ -26,14 +23,11 @@
|
||||
"obsidian": "latest",
|
||||
"ts-jest": "^28.0.5",
|
||||
"tslib": "2.3.1",
|
||||
"typescript": "^4.7.2",
|
||||
"vitepress": "^1.6.3"
|
||||
"typescript": "^4.7.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@notable/html2markdown": "^1.1.3",
|
||||
"@popperjs/core": "^2.11.6",
|
||||
"cheerio": "^1.0.0-rc.11",
|
||||
"follow-redirects": "^1.15.6",
|
||||
"schema-dts": "^1.1.0"
|
||||
}
|
||||
}
|
||||
|
||||
137
src/douban/Douban.ts
Normal file
@ -0,0 +1,137 @@
|
||||
import { i18nHelper } from "src/lang/helper";
|
||||
import { type } from "os";
|
||||
|
||||
export interface DoubanPluginSettings {
|
||||
movieTemplate:string,
|
||||
bookTemplate:string,
|
||||
musicTemplate:string,
|
||||
noteTemplate:string,
|
||||
gameTemplate:string,
|
||||
dateFormat:string,
|
||||
timeFormat:string,
|
||||
searchUrl:string,
|
||||
arraySpilt:string,
|
||||
searchHeaders?:string,
|
||||
personNameMode:PersonNameMode,
|
||||
}
|
||||
|
||||
export enum PersonNameMode {
|
||||
CH_NAME = "CH",
|
||||
EN_NAME = "EN",
|
||||
CH_EN_NAME = "CH_EN",
|
||||
}
|
||||
|
||||
|
||||
export const doubanHeadrs = {
|
||||
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
|
||||
"Accept-Language": "en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7",
|
||||
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.61 Safari/537.36",
|
||||
};
|
||||
|
||||
export const DEFAULT_SETTINGS:DoubanPluginSettings = {
|
||||
movieTemplate:
|
||||
`
|
||||

|
||||
|
||||
doubanId: {{id}}
|
||||
title: {{title}}
|
||||
type: {{type}}
|
||||
score: {{score}}
|
||||
originalTitle: {{originalTitle}}
|
||||
genre: {{genre}}
|
||||
datePublished: {{datePublished}}
|
||||
director: {{director}}
|
||||
actor: {{actor}}
|
||||
author: {{author}}
|
||||
url: {{url}}
|
||||
desc: {{desc}}
|
||||
`,
|
||||
bookTemplate:
|
||||
`
|
||||
|
||||
doubanId: {{id}}
|
||||
title: {{title}}
|
||||
subTitle: {{subTitle}}
|
||||
originalTitle: {{originalTitle}}
|
||||
type: {{type}}
|
||||
author: {{author}}
|
||||
score: {{score}}
|
||||
datePublished: {{datePublished}}
|
||||
translator: {{translator}}
|
||||
publisher: {{publisher}}
|
||||
isbn: {{isbn}}
|
||||
url: {{url}}
|
||||
totalPage: {{totalPage}}
|
||||
price: {{price}}
|
||||
tags: Book
|
||||
desc: {{desc}}
|
||||
`,
|
||||
musicTemplate:
|
||||
`
|
||||

|
||||
|
||||
doubanId: {{id}}
|
||||
title: {{title}}
|
||||
type: {{type}}
|
||||
actor: {{actor}}
|
||||
score: {{score}}
|
||||
genre: {{genre}}
|
||||
medium: {{medium}}
|
||||
albumType: {{albumType}}
|
||||
datePublished: {{datePublished}}
|
||||
publisher: {{publisher}}
|
||||
barcode: {{barcode}}
|
||||
url: {{url}}
|
||||
numberOfRecords: {{numberOfRecords}}
|
||||
tags: Music
|
||||
desc: {{desc}}
|
||||
`,
|
||||
noteTemplate:
|
||||
`---
|
||||
doubanId: {{id}}
|
||||
title: {{title}}
|
||||
type: {{type}}
|
||||
author: [{{author}}]({{authorUrl}})
|
||||
dateTimePublished: {{datePublished}} {{timePublished}}
|
||||
url: {{url}}
|
||||
tags: Article
|
||||
desc: {{desc}}
|
||||
---
|
||||
|
||||
{{content}}
|
||||
`,
|
||||
gameTemplate:
|
||||
`
|
||||
|
||||
doubanId: {{id}}
|
||||
title: {{title}}
|
||||
aliases: {{aliases}}
|
||||
type: {{type}}
|
||||
score: {{score}}
|
||||
tags: Game
|
||||
dateTimePublished: {{datePublished}}
|
||||
publisher: {{publisher}}
|
||||
genre: {{genre}}
|
||||
developer: {{developer}}
|
||||
platform: {{platform}}
|
||||
url: {{url}}
|
||||
desc: {{desc}}
|
||||
`,
|
||||
// totalWord: {{totalWord}}
|
||||
|
||||
searchUrl: 'https://www.douban.com/search?q=',
|
||||
searchHeaders: JSON.stringify(doubanHeadrs),
|
||||
dateFormat: "yyyy-MM-DD",
|
||||
timeFormat: "HH:mm:ss",
|
||||
arraySpilt: ", ",
|
||||
personNameMode: PersonNameMode.CH_NAME
|
||||
|
||||
}
|
||||
|
||||
export const personNameModeRecords: {[key in PersonNameMode]: string} = {
|
||||
[PersonNameMode.CH_NAME]: i18nHelper.getMessage('121206'),
|
||||
[PersonNameMode.EN_NAME]: i18nHelper.getMessage('121207'),
|
||||
[PersonNameMode.CH_EN_NAME]: i18nHelper.getMessage('121208'),
|
||||
}
|
||||
|
||||
|
||||
317
src/douban/DoubanSettingTab.ts
Normal file
@ -0,0 +1,317 @@
|
||||
import { App, PluginSettingTab, Setting } from "obsidian";
|
||||
import { DEFAULT_SETTINGS, PersonNameMode, personNameModeRecords } from "./Douban";
|
||||
|
||||
import DoubanPlugin from "main";
|
||||
import { i18nHelper } from "src/lang/helper";
|
||||
|
||||
export class DoubanSettingTab extends PluginSettingTab {
|
||||
plugin: DoubanPlugin;
|
||||
|
||||
constructor(app: App, plugin: DoubanPlugin) {
|
||||
super(app, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
display(): void {
|
||||
let { containerEl } = this;
|
||||
|
||||
containerEl.empty();
|
||||
|
||||
containerEl.createEl("h2", { text: i18nHelper.getMessage('1201') });
|
||||
|
||||
new Setting(containerEl).setName(i18nHelper.getMessage('120001'))
|
||||
.then((setting) => {
|
||||
setting.addText((textField) => {
|
||||
setting.descEl.appendChild(
|
||||
createFragment((frag) => {
|
||||
frag.appendText(i18nHelper.getMessage('120002'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('120003'));
|
||||
frag.createEl(
|
||||
'a',
|
||||
{
|
||||
text: i18nHelper.getMessage('120901'),
|
||||
href: 'https://www.douban.com',
|
||||
},
|
||||
(a) => {
|
||||
a.setAttr('target', '_blank');
|
||||
}
|
||||
);
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('120004'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('120005'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('120006'));
|
||||
frag.createEl('br');
|
||||
})
|
||||
);
|
||||
textField.inputEl.addClass("obsidian_douban_settings_textField");
|
||||
textField
|
||||
.setPlaceholder(DEFAULT_SETTINGS.searchUrl)
|
||||
.setValue(this.plugin.settings.searchUrl)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.searchUrl = value;
|
||||
await this.plugin.saveSettings();
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
new Setting(containerEl).setName(i18nHelper.getMessage('120101')).then((setting) => {
|
||||
setting.addTextArea((textarea) => {
|
||||
setting.descEl.appendChild(
|
||||
createFragment((frag) => {
|
||||
frag.appendText(i18nHelper.getMessage('120102'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('120103'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('120104'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('120105'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('120106'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('120107'));
|
||||
frag.createEl('br');
|
||||
})
|
||||
);
|
||||
textarea.inputEl.addClass("obsidian_douban_settings_area");
|
||||
textarea.inputEl.setAttr("rows", 10);
|
||||
textarea.setPlaceholder(DEFAULT_SETTINGS.movieTemplate)
|
||||
.setValue(this.plugin.settings.movieTemplate)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.movieTemplate = value;
|
||||
await this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
new Setting(containerEl).setName(i18nHelper.getMessage('120201')).then((setting) => {
|
||||
setting.addTextArea((textarea) => {
|
||||
setting.descEl.appendChild(
|
||||
createFragment((frag) => {
|
||||
frag.appendText(i18nHelper.getMessage('120202'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('120203'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('120204'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('120205'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('120206'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('120207'));
|
||||
frag.createEl('br');
|
||||
})
|
||||
);
|
||||
textarea.inputEl.addClass("obsidian_douban_settings_area");
|
||||
textarea.inputEl.setAttr("rows", 10);
|
||||
textarea.setPlaceholder(DEFAULT_SETTINGS.bookTemplate)
|
||||
.setValue(this.plugin.settings.bookTemplate)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.bookTemplate = value;
|
||||
await this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
new Setting(containerEl).setName(i18nHelper.getMessage('120301')).then((setting) => {
|
||||
setting.addTextArea((textarea) => {
|
||||
setting.descEl.appendChild(
|
||||
createFragment((frag) => {
|
||||
frag.appendText(i18nHelper.getMessage('120302'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('120303'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('120304'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('120305'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('120306'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('120307'));
|
||||
frag.createEl('br');
|
||||
})
|
||||
);
|
||||
textarea.inputEl.addClass("obsidian_douban_settings_area");
|
||||
textarea.inputEl.setAttr("rows", 10);
|
||||
textarea.setPlaceholder(DEFAULT_SETTINGS.musicTemplate)
|
||||
.setValue(this.plugin.settings.musicTemplate)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.musicTemplate = value;
|
||||
await this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
new Setting(containerEl).setName(i18nHelper.getMessage("120401")).then((setting) => {
|
||||
setting.addTextArea((textarea) => {
|
||||
setting.descEl.appendChild(
|
||||
createFragment((frag) => {
|
||||
frag.appendText(i18nHelper.getMessage('120402'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('120403'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('120404'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('120405'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('120406'));
|
||||
frag.createEl('br');
|
||||
|
||||
})
|
||||
);
|
||||
textarea.inputEl.addClass("obsidian_douban_settings_area");
|
||||
textarea.inputEl.setAttr("rows", 10);
|
||||
textarea.setPlaceholder(DEFAULT_SETTINGS.noteTemplate)
|
||||
.setValue(this.plugin.settings.noteTemplate)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.noteTemplate = value;
|
||||
await this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
new Setting(containerEl).setName(i18nHelper.getMessage('121301')).then((setting) => {
|
||||
setting.addTextArea((textarea) => {
|
||||
setting.descEl.appendChild(
|
||||
createFragment((frag) => {
|
||||
frag.appendText(i18nHelper.getMessage('121302'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('121303'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('121304'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('121305'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('121306'));
|
||||
frag.createEl('br');
|
||||
})
|
||||
);
|
||||
textarea.inputEl.addClass("obsidian_douban_settings_area");
|
||||
textarea.inputEl.setAttr("rows", 10);
|
||||
textarea.setPlaceholder(DEFAULT_SETTINGS.gameTemplate)
|
||||
.setValue(this.plugin.settings.gameTemplate)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.gameTemplate = value;
|
||||
await this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
})
|
||||
|
||||
new Setting(containerEl).setName(i18nHelper.getMessage('121201')).then((setting) => {
|
||||
setting.addDropdown((dropdwon) => {
|
||||
setting.descEl.appendChild(
|
||||
createFragment((frag) => {
|
||||
frag.appendText(i18nHelper.getMessage('121202'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('121203'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('121204'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('121205'));
|
||||
frag.createEl('br');
|
||||
})
|
||||
);
|
||||
// dropdwon.inputEl.addClass("settings_area");
|
||||
// dropdwon.inputEl.setAttr("rows", 10);
|
||||
dropdwon.addOption(PersonNameMode.CH_NAME, personNameModeRecords.CH)
|
||||
dropdwon.addOption(PersonNameMode.EN_NAME, personNameModeRecords.EN)
|
||||
dropdwon.addOption(PersonNameMode.CH_EN_NAME, personNameModeRecords.CH_EN)
|
||||
dropdwon.setValue(this.plugin.settings.personNameMode)
|
||||
.onChange(async (value:string) => {
|
||||
this.plugin.settings.personNameMode = value as PersonNameMode;
|
||||
await this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
new Setting(containerEl).setName(i18nHelper.getMessage('120501')).then((setting) => {
|
||||
setting.addMomentFormat((mf) => {
|
||||
setting.descEl.appendChild(
|
||||
createFragment((frag) => {
|
||||
frag.appendText(
|
||||
i18nHelper.getMessage('120503')
|
||||
);
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('120506') + ' ');
|
||||
frag.createEl(
|
||||
'a',
|
||||
{
|
||||
text: i18nHelper.getMessage('120508'),
|
||||
href: 'https://momentjs.com/docs/#/displaying/format/',
|
||||
},
|
||||
(a) => {
|
||||
a.setAttr('target', '_blank');
|
||||
}
|
||||
);
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('120507') + ': ');
|
||||
mf.setSampleEl(frag.createEl('b', { cls: 'u-pop' }));
|
||||
frag.createEl('br');
|
||||
})
|
||||
);
|
||||
mf.setPlaceholder(DEFAULT_SETTINGS.dateFormat);
|
||||
mf.setValue(this.plugin.settings.dateFormat)
|
||||
mf.onChange(async (value) => {
|
||||
this.plugin.settings.dateFormat = value;
|
||||
await this.plugin.saveSettings();
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
new Setting(containerEl).setName(i18nHelper.getMessage('120502')).then((setting) => {
|
||||
setting.addMomentFormat((mf) => {
|
||||
setting.descEl.appendChild(
|
||||
createFragment((frag) => {
|
||||
frag.appendText(
|
||||
i18nHelper.getMessage('120504')
|
||||
);
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('120506') + ' ');
|
||||
frag.createEl(
|
||||
'a',
|
||||
{
|
||||
text: i18nHelper.getMessage('120508'),
|
||||
href: 'https://momentjs.com/docs/#/displaying/format/',
|
||||
},
|
||||
(a) => {
|
||||
a.setAttr('target', '_blank');
|
||||
}
|
||||
);
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('120507') + ': ');
|
||||
mf.setSampleEl(frag.createEl('b', { cls: 'u-pop' }));
|
||||
frag.createEl('br');
|
||||
})
|
||||
);
|
||||
mf.setPlaceholder(DEFAULT_SETTINGS.timeFormat);
|
||||
mf.setValue(this.plugin.settings.timeFormat)
|
||||
mf.onChange(async (value) => {
|
||||
this.plugin.settings.timeFormat = value;
|
||||
await this.plugin.saveSettings();
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName(i18nHelper.getMessage('120601'))
|
||||
.setDesc(i18nHelper.getMessage('120602'))
|
||||
.addText((textField) => {
|
||||
textField.setPlaceholder(DEFAULT_SETTINGS.arraySpilt)
|
||||
.setValue(this.plugin.settings.arraySpilt)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.arraySpilt = value;
|
||||
await this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
13
src/douban/ResponseHandle.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { Notice } from "obsidian";
|
||||
|
||||
export const ensureStatusCode = (expected:any) => {
|
||||
if (!Array.isArray(expected))
|
||||
expected = [expected];
|
||||
return (res:any) => {
|
||||
const { statusCode } = res;
|
||||
if(!expected.includes(statusCode)) {
|
||||
new Notice(`Request Douban failed, Status code must be "${expected}" but actually "${statusCode}"`)
|
||||
}
|
||||
return res;
|
||||
};
|
||||
};
|
||||
@ -0,0 +1,12 @@
|
||||
import { CheerioAPI } from "cheerio";
|
||||
import DoubanBroadcastSubject from "../model/DoubanBroadcastSubject";
|
||||
|
||||
export abstract class DoubanBroadcastAbstractHandler<T extends DoubanBroadcastSubject> {
|
||||
|
||||
abstract support(t:string):boolean;
|
||||
|
||||
abstract transform(data:Element, source:CheerioAPI):T;
|
||||
|
||||
}
|
||||
|
||||
|
||||
15
src/douban/broadcast/handler/DoubanBroadcastMovieHandler.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { CheerioAPI } from "cheerio";
|
||||
import { DoubanBroadcastAbstractHandler } from "./DoubanBroadcastAbstractHandler";
|
||||
import DoubanBroadcastMovieSubject from "../model/DoubanBroadcastMoveSubject";
|
||||
|
||||
//TODO will support in future version
|
||||
export class DoubanBroadcastMovieHandler extends DoubanBroadcastAbstractHandler<DoubanBroadcastMovieSubject>{
|
||||
support(t: string): boolean {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
transform(data: Element, source:CheerioAPI): DoubanBroadcastMovieSubject {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
import { CheerioAPI } from "cheerio";
|
||||
import { DoubanBroadcastAbstractHandler } from "./DoubanBroadcastAbstractHandler";
|
||||
import { DoubanBroadcastMovieHandler } from "./DoubanBroadcastMovieHandler";
|
||||
import DoubanBroadcastSubject from "../model/DoubanBroadcastSubject";
|
||||
import DoubanPageBroadcastSubject from "../model/DoubanPageBroadcastSubject";
|
||||
|
||||
//TODO will support in future version
|
||||
export class DoubanPageBroadcastTransformer {
|
||||
|
||||
private handlers:DoubanBroadcastAbstractHandler<DoubanBroadcastSubject>[];
|
||||
|
||||
|
||||
constructor() {
|
||||
this.handlers = [
|
||||
new DoubanBroadcastMovieHandler(),
|
||||
]
|
||||
|
||||
}
|
||||
|
||||
public transform(data: CheerioAPI):DoubanPageBroadcastSubject {
|
||||
let doubanBroadcastSubjects:DoubanBroadcastSubject[] = data('.new-status .status-wrapper')
|
||||
.get()
|
||||
.map(i => this.transformElement(i, data));
|
||||
return new DoubanPageBroadcastSubject ();
|
||||
}
|
||||
|
||||
public transformElement(element:any, source:CheerioAPI):DoubanBroadcastSubject {
|
||||
let targetType:string = element.innerHTML;
|
||||
return this.handlers.filter(h => h.support(targetType))[0].transform(element, source);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,79 @@
|
||||
import { CheerioAPI } from 'cheerio';
|
||||
import DoubanAbstractLoadHandler from 'src/douban/data/handler/DoubanAbstractLoadHandler';
|
||||
import DoubanNoteSubject from '../model/DoubanPageBroadcastSubject';
|
||||
import DoubanPageBroadcastSubject from '../model/DoubanPageBroadcastSubject';
|
||||
import DoubanPlugin from "main";
|
||||
import { DoubanPluginSettings } from "src/douban/Douban";
|
||||
import DoubanSubject from 'src/douban/data/model/DoubanSubject';
|
||||
|
||||
//TODO will support in future version
|
||||
export default class DoubanPageBroadcatLoadHandler extends DoubanAbstractLoadHandler<DoubanPageBroadcastSubject> {
|
||||
|
||||
getTemplate(settings: DoubanPluginSettings): string {
|
||||
return settings.bookTemplate;
|
||||
}
|
||||
|
||||
parseText(beforeContent:string, extract: DoubanNoteSubject, settings:DoubanPluginSettings): string {
|
||||
return settings.bookTemplate ? null : "";
|
||||
// settings.noteTemplate
|
||||
// .replaceAll("{{id}}", extract.id)
|
||||
// .replaceAll("{{type}}", extract.type ? extract.type : "")
|
||||
// .replaceAll("{{title}}", extract.title ? extract.title : "")
|
||||
// .replaceAll("{{desc}}", extract.desc ? extract.desc : "")
|
||||
// .replaceAll("{{image}}", extract.image ? extract.image : "")
|
||||
// .replaceAll("{{timePublished}}", extract.timePublished ? moment(extract.timePublished).format(settings.dateTimeFormat) : "")
|
||||
// .replaceAll("{{url}}", extract.url ? extract.url : "")
|
||||
// .replaceAll("{{content}}", extract.content ? extract.content : "")
|
||||
// .replaceAll("{{url}}", extract.url ? extract.url : "")
|
||||
// .replaceAll("{{authorUrl}}", extract.authorUrl ? extract.authorUrl : "")
|
||||
// .replaceAll("{{author}}", extract.author ? extract.author : "")
|
||||
}
|
||||
support(extract: DoubanSubject): boolean {
|
||||
return extract && extract.type && (extract.type.contains("广播") || extract.type.contains("Broadcast"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
constructor(doubanPlugin:DoubanPlugin) {
|
||||
super(doubanPlugin);
|
||||
}
|
||||
|
||||
parseSubjectFromHtml(html: CheerioAPI): DoubanPageBroadcastSubject {
|
||||
// return html('.new-status .status-wrapper')
|
||||
// .get()
|
||||
// .map(i -> {
|
||||
// let div = html(i);
|
||||
// div.find('')
|
||||
// });
|
||||
|
||||
let title = html(html("head > meta[property= 'og:title']").get(0)).attr("content");
|
||||
let desc = html(html("head > meta[property= 'og:description']").get(0)).attr("content");
|
||||
let url = html(html("head > meta[property= 'og:url']").get(0)).attr("content");
|
||||
let image = html(html("head > meta[property= 'og:image']").get(0)).attr("content");
|
||||
let type = html(html("head > meta[property= 'og:type']").get(0)).attr("content");
|
||||
let authorA = html(html("a.note-author").get(0));
|
||||
let timePublished = html(html(".pub-date").get(0)).text();
|
||||
let content = html(html(".note").get(1));
|
||||
let idPattern = /(\d){5,10}/g;
|
||||
let id = idPattern.exec(url);
|
||||
|
||||
// const result:DoubanNoteSubject = {
|
||||
// image: image,
|
||||
// timePublished: timePublished ? new Date(timePublished) : null,
|
||||
// content: content ? html2markdown(content.toString()): "",
|
||||
// id: id ? id[0] : "",
|
||||
// type: "Article",
|
||||
// title: title,
|
||||
// desc: desc,
|
||||
// url: url,
|
||||
// author: authorA ? authorA.text() : null,
|
||||
// authorUrl: authorA ? authorA.attr("href") : null,
|
||||
// };
|
||||
// return result;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
4
src/douban/broadcast/model/DoubanBroadcastMoveSubject.ts
Normal file
@ -0,0 +1,4 @@
|
||||
import DoubanBroadcastSubject from "./DoubanBroadcastSubject";
|
||||
|
||||
export default class DoubanBroadcastMovieSubject extends DoubanBroadcastSubject{
|
||||
}
|
||||
12
src/douban/broadcast/model/DoubanBroadcastSubject.ts
Normal file
@ -0,0 +1,12 @@
|
||||
export default class DoubanBroadcastSubject {
|
||||
id: string;
|
||||
type: string;
|
||||
title: string;
|
||||
desc: string;
|
||||
url: string;
|
||||
author:string;
|
||||
authorUrl:string;
|
||||
timePublished:Date;
|
||||
image:string;
|
||||
content:string;
|
||||
}
|
||||
9
src/douban/broadcast/model/DoubanPageBroadcastSubject.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import {AggregateRating, Person, WithContext} from 'schema-dts';
|
||||
|
||||
import DoubanSubject from 'src/douban/data/model/DoubanSubject';
|
||||
|
||||
export default class DoubanPageBroadcastSubject extends DoubanSubject {
|
||||
pageNumber:number;
|
||||
broadcast:DoubanPageBroadcastSubject[];
|
||||
pageSize:number;
|
||||
}
|
||||
118
src/douban/data/handler/DoubanAbstractLoadHandler.ts
Normal file
@ -0,0 +1,118 @@
|
||||
import { DoubanPluginSettings, PersonNameMode } from "src/douban/Douban";
|
||||
|
||||
import DoubanPlugin from "main";
|
||||
import DoubanSubject from '../model/DoubanSubject';
|
||||
import DoubanSubjectLoadHandler from "./DoubanSubjectLoadHandler";
|
||||
import {Editor, moment, request, requestUrl, RequestUrlParam, sanitizeHTMLToDom} from "obsidian";
|
||||
import { i18nHelper } from 'src/lang/helper';
|
||||
import { log } from "src/utils/Logutil";
|
||||
import {CheerioAPI, load} from "cheerio";
|
||||
|
||||
export default abstract class DoubanAbstractLoadHandler<T extends DoubanSubject> implements DoubanSubjectLoadHandler<T> {
|
||||
|
||||
|
||||
public doubanPlugin:DoubanPlugin;
|
||||
|
||||
constructor(doubanPlugin:DoubanPlugin) {
|
||||
this.doubanPlugin = doubanPlugin;
|
||||
}
|
||||
|
||||
parse(extract: T, settings:DoubanPluginSettings): string {
|
||||
let template:string = this.getTemplate(settings);
|
||||
let resultContent = template ? template
|
||||
.replaceAll("{{id}}", extract.id)
|
||||
.replaceAll("{{type}}", extract.type ? extract.type : "")
|
||||
.replaceAll("{{title}}", extract.title ? extract.title : "")
|
||||
.replaceAll("{{desc}}", extract.desc ? extract.desc : "")
|
||||
.replaceAll("{{image}}", extract.image ? extract.image : "")
|
||||
.replaceAll("{{url}}", extract.url ? extract.url : "")
|
||||
.replaceAll("{{score}}", extract.score ? extract.score + "": "")
|
||||
.replaceAll("{{publisher}}", extract.publisher ? extract.publisher : "")
|
||||
.replaceAll("{{datePublished}}", extract.datePublished ? moment(extract.datePublished).format(settings.dateFormat) : "")
|
||||
.replaceAll("{{timePublished}}", extract.datePublished ? moment(extract.datePublished).format(settings.timeFormat) : "")
|
||||
.replaceAll("{{genre}}", extract.genre ? extract.genre.join(settings.arraySpilt) : "")
|
||||
: ""
|
||||
;
|
||||
return this.parseText(resultContent, extract, settings);
|
||||
}
|
||||
|
||||
abstract getTemplate(settings:DoubanPluginSettings):string;
|
||||
|
||||
abstract parseText(beforeContent:string, extract: T, settings:DoubanPluginSettings): string;
|
||||
|
||||
abstract support(extract: DoubanSubject): boolean;
|
||||
|
||||
handle(url:string, editor:Editor):void {
|
||||
let requestUrlParam:RequestUrlParam = {
|
||||
url: url,
|
||||
method: "GET",
|
||||
headers: JSON.parse(this.doubanPlugin.settings.searchHeaders),
|
||||
throw: true
|
||||
};
|
||||
request(requestUrlParam)
|
||||
.then(load)
|
||||
.then(this.parseSubjectFromHtml)
|
||||
.then(content => this.toEditor(editor, content))
|
||||
// .then(content => content ? editor.replaceSelection(content) : content)
|
||||
.catch(e => log.error(i18nHelper.getMessage('130101')))
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
abstract parseSubjectFromHtml(data:CheerioAPI):T | undefined;
|
||||
|
||||
toEditor(editor:Editor, extract: T):T {
|
||||
this.doubanPlugin.putToEditor(editor, extract);
|
||||
return extract;
|
||||
}
|
||||
|
||||
getPersonName(name:string, settings:DoubanPluginSettings):string {
|
||||
if(!name || !settings || !settings.personNameMode) {
|
||||
return "";
|
||||
}
|
||||
let resultName:string = "";
|
||||
let regValue:RegExpExecArray;
|
||||
switch(settings.personNameMode) {
|
||||
case PersonNameMode.CH_NAME:
|
||||
regValue = /[\u4e00-\u9fa5]{2,20}/g.exec(name);
|
||||
resultName = regValue?regValue[0]:name;
|
||||
break;
|
||||
case PersonNameMode.EN_NAME:
|
||||
regValue = /[a-zA-Z.\s\-]{2,50}/g.exec(name);
|
||||
resultName = regValue?regValue[0]:name;
|
||||
break;
|
||||
default:
|
||||
resultName = name;
|
||||
}
|
||||
return resultName;
|
||||
}
|
||||
|
||||
html_encode(str:string):string
|
||||
{
|
||||
let s = "";
|
||||
if (str.length == 0) return "";
|
||||
s = str.replace(/&/g, "&");
|
||||
s = s.replace(/</g, "<");
|
||||
s = s.replace(/>/g, ">");
|
||||
s = s.replace(/ /g, " ");
|
||||
s = s.replace(/\'/g, "'");
|
||||
s = s.replace(/\"/g, """);
|
||||
s = s.replace(/\n/g, "<br/>");
|
||||
return s;
|
||||
}
|
||||
|
||||
html_decode(str:string):string
|
||||
{
|
||||
let s = "";
|
||||
if (str.length == 0) return "";
|
||||
s = str.replace(/&/g, "&");
|
||||
s = s.replace(/</g, "<");
|
||||
s = s.replace(/>/g, ">");
|
||||
s = s.replace(/ /g, " ");
|
||||
s = s.replace(/'/g, "\'");
|
||||
s = s.replace(/"/g, "\"");
|
||||
s = s.replace(/<br\/>/g, "\n");
|
||||
return s;
|
||||
}
|
||||
|
||||
}
|
||||
112
src/douban/data/handler/DoubanBookLoadHandler.ts
Normal file
@ -0,0 +1,112 @@
|
||||
import { Editor, moment, renderResults } from "obsidian";
|
||||
|
||||
import { CheerioAPI } from 'cheerio';
|
||||
import DoubanAbstractLoadHandler from "./DoubanAbstractLoadHandler";
|
||||
import DoubanBookSubject from "../model/DoubanBookSubject";
|
||||
import DoubanPlugin from "main";
|
||||
import { DoubanPluginSettings } from "src/douban/Douban";
|
||||
import DoubanSubject from "../model/DoubanSubject";
|
||||
|
||||
export default class DoubanBookLoadHandler extends DoubanAbstractLoadHandler<DoubanBookSubject> {
|
||||
|
||||
getTemplate(settings: DoubanPluginSettings): string {
|
||||
return settings.bookTemplate;
|
||||
}
|
||||
|
||||
parseText(beforeContent:string, extract: DoubanBookSubject, settings:DoubanPluginSettings): string {
|
||||
return beforeContent
|
||||
.replaceAll("{{author}}", extract.author ? extract.author.join(settings.arraySpilt) : "")
|
||||
.replaceAll("{{translator}}", extract.translator ? extract.translator.join(settings.arraySpilt) : "")
|
||||
.replaceAll("{{totalWord}}", extract.totalWord ? extract.totalWord+"" : "")
|
||||
.replaceAll("{{isbn}}", extract.isbn ? extract.isbn : "")
|
||||
.replaceAll("{{originalTitle}}", extract.originalTitle ? extract.originalTitle : "")
|
||||
.replaceAll("{{subTitle}}", extract.subTitle ? extract.subTitle : "")
|
||||
.replaceAll("{{totalPage}}", extract.totalPage ? extract.totalPage + "" : "")
|
||||
.replaceAll("{{menu}}", extract.menu ? extract.menu.join(settings.arraySpilt) : "")
|
||||
.replaceAll("{{price}}", extract.price ? extract.price + "" : "")
|
||||
.replaceAll("{{labels}}", extract.labels ? extract.labels.join(settings.arraySpilt) : "");
|
||||
}
|
||||
support(extract: DoubanSubject): boolean {
|
||||
return extract && extract.type && (extract.type.contains("书籍") || extract.type.contains("Book") || extract.type.contains("book"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
constructor(doubanPlugin:DoubanPlugin) {
|
||||
super(doubanPlugin);
|
||||
}
|
||||
|
||||
parseSubjectFromHtml(html: CheerioAPI): DoubanBookSubject {
|
||||
let title = html(html("head > meta[property= 'og:title']").get(0)).attr("content");
|
||||
let desc = html(html("head > meta[property= 'og:description']").get(0)).attr("content");
|
||||
let url = html(html("head > meta[property= 'og:url']").get(0)).attr("content");
|
||||
let image = html(html("head > meta[property= 'og:image']").get(0)).attr("content");
|
||||
let type = html(html("head > meta[property= 'og:type']").get(0)).attr("content");
|
||||
let author = html(html("head > meta[property= 'book:author']").get(0)).attr("content");
|
||||
let isbn = html(html("head > meta[property= 'book:isbn']").get(0)).attr("content");
|
||||
let score = html(html("#interest_sectl > div > div.rating_self.clearfix > strong[property= 'v:average']").get(0)).text();
|
||||
let detailDom = html(html("#info").get(0));
|
||||
let publish = detailDom.find("span.pl");
|
||||
|
||||
let valueMap = new Map<string, string>();
|
||||
|
||||
publish.map((index, info) => {
|
||||
let key = html(info).text().trim();
|
||||
let value = ''
|
||||
if(key.indexOf('作者') >= 0 || key.indexOf('丛书') >= 0 || key.indexOf('译者') >= 0 || key.indexOf('出版社') >= 0){
|
||||
value = html(info.next.next).text().trim();
|
||||
}else{
|
||||
value = html(info.next).text().trim();
|
||||
}
|
||||
valueMap.set(BookKeyValueMap.get(key), value);
|
||||
})
|
||||
|
||||
let idPattern = /(\d){5,10}/g;
|
||||
let id = idPattern.exec(url);
|
||||
|
||||
const result:DoubanBookSubject = {
|
||||
author: [author],
|
||||
translator: [valueMap.get('translator')],
|
||||
bookType: "",
|
||||
image: image,
|
||||
datePublished: valueMap.has('datePublished') ? new Date(valueMap.get('datePublished')) : undefined,
|
||||
totalWord: valueMap.has('totalWord') ? Number(valueMap.get('totalWord')) : null,
|
||||
isbn: isbn,
|
||||
publisher: valueMap.has('publisher') ? valueMap.get('publisher') : "",
|
||||
score: Number(score),
|
||||
originalTitle: valueMap.has('originalTitle') ? valueMap.get('originalTitle') : "",
|
||||
subTitle: "",
|
||||
totalPage: valueMap.has('originalTitle') ? Number(valueMap.get('totalPage')) : null,
|
||||
belong: "",
|
||||
menu: [],
|
||||
price: valueMap.has('price') ? Number(valueMap.get('price').replace('元', '')) : null,
|
||||
labels: [],
|
||||
id: id ? id[0] : "",
|
||||
type: "Book",
|
||||
title: title,
|
||||
desc: desc,
|
||||
url: url,
|
||||
genre: []
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
const BookKeyValueMap:Map<string, string> = new Map(
|
||||
[['作者', 'author'],
|
||||
['出版社:', 'publisher'],
|
||||
['原作名:', 'originalTitle'],
|
||||
['出版年:', 'datePublished'],
|
||||
['页数:', 'totalPage'],
|
||||
['定价:', 'price'],
|
||||
['装帧:', 'binding'],
|
||||
['丛书:', 'bush'],
|
||||
['ISBN:', 'isbn'],
|
||||
['译者', 'translator'],
|
||||
]
|
||||
);
|
||||
126
src/douban/data/handler/DoubanGameLoadHandler.ts
Normal file
@ -0,0 +1,126 @@
|
||||
import { CheerioAPI } from 'cheerio';
|
||||
import DoubanAbstractLoadHandler from "./DoubanAbstractLoadHandler";
|
||||
import DoubanPlugin from "main";
|
||||
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> {
|
||||
|
||||
getTemplate(settings: DoubanPluginSettings): string {
|
||||
return settings.gameTemplate;
|
||||
}
|
||||
|
||||
// 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 : "");
|
||||
}
|
||||
|
||||
support(extract: DoubanSubject): boolean {
|
||||
return extract && extract.type && (extract.type.contains("游戏") || extract.type.contains("Game") || extract.type.contains("game"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
constructor(doubanPlugin:DoubanPlugin) {
|
||||
super(doubanPlugin);
|
||||
}
|
||||
|
||||
parseSubjectFromHtml(html: CheerioAPI): DoubanGameSubject {
|
||||
let title = html(html("#content > h1").get(0)).text();
|
||||
let idContent = html(html("head > meta[name= 'mobile-agent']").get(0)).attr("content");
|
||||
let idPattern = /(\d){5,10}/g;
|
||||
let idP = idPattern.exec(idContent);
|
||||
let id = idP ? idP[0] : "";
|
||||
let score = html(html("#interest_sectl > div > div.rating_self.clearfix > strong[property= 'v:average']").get(0)).text();
|
||||
let detailDom = html(html("dl.game-attr").get(0));
|
||||
let dt = detailDom.find("dt");
|
||||
let image = html(html("#content > div > div.article > div.mod.item-subject > div.item-subject-info > div > a > img").get(0)).attr("src");
|
||||
let desc = html(html("#link-report > p").get(0)).text();
|
||||
|
||||
let url = `https://www.douban.com/game/${id}/`;
|
||||
let valueMap = new Map<string, any>();
|
||||
let value:any;
|
||||
dt.map((index, info) => {
|
||||
let key = html(info).text().trim();
|
||||
if(key.indexOf('平台') >= 0 || key.indexOf('类型') >= 0){
|
||||
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.next).text().trim();
|
||||
}
|
||||
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') : [],
|
||||
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') : [],
|
||||
developer: valueMap.has('developer') ? valueMap.get('developer') : "",
|
||||
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;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
const GameKeyValueMap:Map<string, string> = new Map(
|
||||
[['类型:', 'genre'],
|
||||
['平台:', 'platform'],
|
||||
['别名:', 'aliases'],
|
||||
['开发商:', 'developer'],
|
||||
['发行商:', 'publisher'],
|
||||
['发行日期:', 'datePublished'],
|
||||
]
|
||||
);
|
||||
|
||||
76
src/douban/data/handler/DoubanMovieLoadHandler.ts
Normal file
@ -0,0 +1,76 @@
|
||||
import { CheerioAPI } from 'cheerio';
|
||||
import DoubanAbstractLoadHandler from "./DoubanAbstractLoadHandler";
|
||||
import DoubanPlugin from "main";
|
||||
import { DoubanPluginSettings } from "src/douban/Douban";
|
||||
import SchemaOrg from "src/utils/SchemaOrg";
|
||||
import { moment } from "obsidian";
|
||||
import DoubanSubject from '../model/DoubanSubject';
|
||||
import DoubanMovieSubject from '../model/DoubanMovieSubject';
|
||||
|
||||
export default class DoubanMovieLoadHandler extends DoubanAbstractLoadHandler<DoubanMovieSubject> {
|
||||
|
||||
getTemplate(settings: DoubanPluginSettings): string {
|
||||
return settings.movieTemplate;
|
||||
}
|
||||
|
||||
parseText(beforeContent:string, extract: DoubanMovieSubject, settings:DoubanPluginSettings): string {
|
||||
return beforeContent
|
||||
.replaceAll("{{originalTitle}}", extract.originalTitle ? extract.originalTitle : "")
|
||||
.replaceAll("{{director}}", extract.director ? extract.director.map(SchemaOrg.getPersonName).map(name => super.getPersonName(name, settings)).filter(c => c).join(settings.arraySpilt) : "")
|
||||
.replaceAll("{{actor}}", extract.actor ? extract.actor.map(SchemaOrg.getPersonName).map(name => super.getPersonName(name, settings)).filter(c => c).join(settings.arraySpilt) : "")
|
||||
.replaceAll("{{author}}", extract.author ? extract.author.map(SchemaOrg.getPersonName).map(name => super.getPersonName(name, settings)).filter(c => c).join(settings.arraySpilt) : "")
|
||||
;
|
||||
}
|
||||
support(extract: DoubanSubject): boolean {
|
||||
return extract && extract.type && (extract.type.contains("电影") || extract.type.contains("Movie") || extract.type.contains("movie"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
constructor(doubanPlugin:DoubanPlugin) {
|
||||
super(doubanPlugin);
|
||||
}
|
||||
|
||||
parseSubjectFromHtml(data: CheerioAPI): DoubanMovieSubject {
|
||||
return data('script')
|
||||
.get()
|
||||
.filter(scd => "application/ld+json" == data(scd).attr("type"))
|
||||
.map(i => {
|
||||
let item = data(i).text();
|
||||
item = super.html_decode(item);
|
||||
let obj = JSON.parse(item.replace(/[\r\n\s+]/g, ''));
|
||||
let idPattern = /(\d){5,10}/g;
|
||||
let id = idPattern.exec(obj.url);
|
||||
let name = obj.name;
|
||||
let titleExec = /[\u4e00-\u9fa5]{2,20}/g.exec(name);
|
||||
let title = titleExec?titleExec[0]:name;
|
||||
|
||||
let originalTitleExec = /[a-zA-Z.\s\-]{2,50}/g.exec(name);
|
||||
let originalTitle = originalTitleExec?originalTitleExec[0]:name;
|
||||
|
||||
const result:DoubanMovieSubject = {
|
||||
id: id ? id[0] : '',
|
||||
title: title,
|
||||
type: 'Movie',
|
||||
score: obj.aggregateRating ? obj.aggregateRating.ratingValue : undefined,
|
||||
originalTitle: originalTitle,
|
||||
desc: obj.description,
|
||||
url: "https://movie.douban.com" + obj.url,
|
||||
director: obj.director,
|
||||
author: obj.author,
|
||||
actor: obj.actor,
|
||||
aggregateRating: obj.aggregateRating,
|
||||
datePublished: obj.datePublished ? new Date(obj.datePublished) : undefined,
|
||||
image: obj.image,
|
||||
genre: obj.genre,
|
||||
publisher: ''
|
||||
}
|
||||
return result;
|
||||
})[0];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
97
src/douban/data/handler/DoubanMusicLoadHandler.ts
Normal file
@ -0,0 +1,97 @@
|
||||
import { CheerioAPI } from 'cheerio';
|
||||
import DoubanAbstractLoadHandler from "./DoubanAbstractLoadHandler";
|
||||
import DoubanMusicSubject from '../model/DoubanMusicSubject';
|
||||
import DoubanPlugin from "main";
|
||||
import { DoubanPluginSettings } from "src/douban/Douban";
|
||||
import { moment } from "obsidian";
|
||||
import DoubanSubject from '../model/DoubanSubject';
|
||||
|
||||
export default class DoubanMusicLoadHandler extends DoubanAbstractLoadHandler<DoubanMusicSubject> {
|
||||
|
||||
getTemplate(settings: DoubanPluginSettings): string {
|
||||
return settings.musicTemplate;
|
||||
}
|
||||
|
||||
parseText(beforeContent:string, extract: DoubanMusicSubject, settings:DoubanPluginSettings): string {
|
||||
return beforeContent
|
||||
.replaceAll("{{actor}}", extract.actor ? extract.actor.join(settings.arraySpilt) : "")
|
||||
.replaceAll("{{barcode}}", extract.barcode ? extract.barcode : "")
|
||||
.replaceAll("{{medium}}", extract.medium ? extract.medium : "")
|
||||
.replaceAll("{{albumType}}", extract.albumType ? extract.albumType : "")
|
||||
.replaceAll("{{numberOfRecords}}", extract.numberOfRecords ? extract.numberOfRecords + "" : "")
|
||||
;
|
||||
}
|
||||
support(extract: DoubanSubject): boolean {
|
||||
return extract && extract.type && (extract.type.contains("音乐") || extract.type.contains("Music") || extract.type.contains("music"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
constructor(doubanPlugin:DoubanPlugin) {
|
||||
super(doubanPlugin);
|
||||
}
|
||||
|
||||
parseSubjectFromHtml(html: CheerioAPI): DoubanMusicSubject {
|
||||
let title = html(html("head > meta[property= 'og:title']").get(0)).attr("content");
|
||||
let desc = html(html("head > meta[property= 'og:description']").get(0)).attr("content");
|
||||
let url = html(html("head > meta[property= 'og:url']").get(0)).attr("content");
|
||||
let image = html(html("head > meta[property= 'og:image']").get(0)).attr("content");
|
||||
let score = html(html("#interest_sectl > div > div.rating_self.clearfix > strong[property= 'v:average']").get(0)).text();
|
||||
let detailDom = html(html("#info").get(0));
|
||||
let publish = detailDom.find("span.pl");
|
||||
|
||||
let valueMap = new Map<string, string>();
|
||||
|
||||
publish.map((index, info) => {
|
||||
let key = html(info).text().trim();
|
||||
let value = ''
|
||||
if(key.indexOf('表演者') >= 0){
|
||||
// value = html(info.next.next).text().trim();
|
||||
let vas:string[] = key.split("\n \n ");
|
||||
value = vas && vas.length > 1? vas[1]:"";
|
||||
key = vas && vas.length > 0? vas[0]:"";
|
||||
}else{
|
||||
value = html(info.next).text().trim();
|
||||
}
|
||||
valueMap.set(MusicKeyValueMap.get(key), value);
|
||||
})
|
||||
|
||||
let idPattern = /(\d){5,10}/g;
|
||||
let id = idPattern.exec(url);
|
||||
|
||||
const result:DoubanMusicSubject = {
|
||||
image: image,
|
||||
datePublished: valueMap.has('datePublished') ? new Date(valueMap.get('datePublished')) : undefined,
|
||||
publisher: valueMap.has('publisher') ? valueMap.get('publisher') : "",
|
||||
score: Number(score),
|
||||
numberOfRecords: valueMap.has('numberOfRecords') ? Number(valueMap.get('numberOfRecords')) : null,
|
||||
id: id ? id[0] : "",
|
||||
type: "Music",
|
||||
title: title,
|
||||
desc: desc,
|
||||
url: url,
|
||||
actor: [valueMap.has('actor') ? valueMap.get('actor') : null],
|
||||
genre: valueMap.has('genre') ? [valueMap.get('genre')] : [""],
|
||||
albumType: valueMap.has('albumType') ? valueMap.get('albumType') : "",
|
||||
medium: valueMap.has('medium') ? valueMap.get('medium') : "",
|
||||
barcode: valueMap.has('barcode') ? valueMap.get('barcode') : ""
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
const MusicKeyValueMap:Map<string, string> = new Map(
|
||||
[['表演者:', 'actor'],
|
||||
['流派:', 'genre'],
|
||||
['发行时间:', 'datePublished'],
|
||||
['专辑类型:', 'albumType'],
|
||||
['介质:', 'medium'],
|
||||
['出版者:', 'publisher'],
|
||||
['唱片数:', 'numberOfRecords'],
|
||||
['条形码:', 'barcode']]
|
||||
);
|
||||
66
src/douban/data/handler/DoubanNoteLoadHandler.ts
Normal file
@ -0,0 +1,66 @@
|
||||
import { CheerioAPI } from 'cheerio';
|
||||
import DoubanAbstractLoadHandler from "./DoubanAbstractLoadHandler";
|
||||
import DoubanNoteSubject from '../model/DoubanNoteSubject';
|
||||
import DoubanPlugin from "main";
|
||||
import { DoubanPluginSettings } from "src/douban/Douban";
|
||||
import DoubanSubject from '../model/DoubanSubject';
|
||||
import html2markdown from '@notable/html2markdown';
|
||||
import { moment } from "obsidian";
|
||||
|
||||
export default class DoubanNoteLoadHandler extends DoubanAbstractLoadHandler<DoubanNoteSubject> {
|
||||
|
||||
getTemplate(settings: DoubanPluginSettings): string {
|
||||
return settings.noteTemplate;
|
||||
}
|
||||
|
||||
parseText(beforeContent:string, extract: DoubanNoteSubject, settings:DoubanPluginSettings): string {
|
||||
return beforeContent
|
||||
.replaceAll("{{authorUrl}}", extract.authorUrl ? extract.authorUrl : "")
|
||||
.replaceAll("{{content}}", extract.content ? extract.content : "")
|
||||
.replaceAll("{{author}}", extract.author ? extract.author : "")
|
||||
;
|
||||
}
|
||||
support(extract: DoubanSubject): boolean {
|
||||
return extract && extract.type && (extract.type.contains("日记") || extract.type.contains("Note") || extract.type.contains("Article"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
constructor(doubanPlugin:DoubanPlugin) {
|
||||
super(doubanPlugin);
|
||||
}
|
||||
|
||||
parseSubjectFromHtml(html: CheerioAPI): DoubanNoteSubject {
|
||||
let title = html(html("head > meta[property= 'og:title']").get(0)).attr("content");
|
||||
let desc = html(html("head > meta[property= 'og:description']").get(0)).attr("content");
|
||||
let url = html(html("head > meta[property= 'og:url']").get(0)).attr("content");
|
||||
let image = html(html("head > meta[property= 'og:image']").get(0)).attr("content");
|
||||
let type = html(html("head > meta[property= 'og:type']").get(0)).attr("content");
|
||||
let authorA = html(html("a.note-author").get(0));
|
||||
let timePublished = html(html(".pub-date").get(0)).text();
|
||||
let content = html(html(".note").get(1));
|
||||
let idPattern = /(\d){5,10}/g;
|
||||
let id = idPattern.exec(url);
|
||||
|
||||
const result:DoubanNoteSubject = {
|
||||
image: image,
|
||||
datePublished: timePublished ? new Date(timePublished) : undefined,
|
||||
content: content ? html2markdown(content.toString()) : "",
|
||||
id: id ? id[0] : "",
|
||||
type: "Article",
|
||||
title: title,
|
||||
desc: desc,
|
||||
url: url,
|
||||
author: authorA ? authorA.text() : null,
|
||||
authorUrl: authorA ? authorA.attr("href") : null,
|
||||
score: 0,
|
||||
publisher: '',
|
||||
genre: []
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
32
src/douban/data/handler/DoubanOtherLoadHandler.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import { Editor, Notice } from "obsidian";
|
||||
|
||||
import { CheerioAPI } from "cheerio";
|
||||
import DoubanAbstractLoadHandler from "./DoubanAbstractLoadHandler";
|
||||
import { DoubanPluginSettings } from "src/douban/Douban";
|
||||
import DoubanSubject from "../model/DoubanSubject";
|
||||
import { i18nHelper } from "src/lang/helper";
|
||||
import { log } from "src/utils/Logutil";
|
||||
|
||||
/**
|
||||
* 默认的处理器
|
||||
*/
|
||||
export default class DoubanOtherLoadHandler extends DoubanAbstractLoadHandler<DoubanSubject> {
|
||||
getTemplate(settings: DoubanPluginSettings): string {
|
||||
return "";
|
||||
}
|
||||
parseText(beforeContent:string, extract: DoubanSubject, settings:DoubanPluginSettings): string {
|
||||
log.warn(i18nHelper.getMessage('140101'));
|
||||
return "";
|
||||
}
|
||||
support(extract: DoubanSubject): boolean {
|
||||
return false;
|
||||
}
|
||||
parseSubjectFromHtml(data: CheerioAPI): DoubanSubject {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
71
src/douban/data/handler/DoubanSearchChooseItemHandler.ts
Normal file
@ -0,0 +1,71 @@
|
||||
import { App, Editor } from "obsidian";
|
||||
|
||||
import DoubanBookLoadHandler from "./DoubanBookLoadHandler";
|
||||
import DoubanMovieLoadHandler from "./DoubanMovieLoadHandler";
|
||||
import DoubanMusicLoadHandler from "./DoubanMusicLoadHandler";
|
||||
import DoubanNoteLoadHandler from "./DoubanNoteLoadHandler";
|
||||
import DoubanOtherLoadHandler from "./DoubanOtherLoadHandler";
|
||||
import DoubanPlugin from "main";
|
||||
import { DoubanPluginSettings } from "src/douban/Douban";
|
||||
import DoubanSubject from "../model/DoubanSubject";
|
||||
import DoubanSubjectLoadHandler from "./DoubanSubjectLoadHandler";
|
||||
import { DoubanTeleplayLoadHandler } from "./DoubanTeleplayLoadHandler";
|
||||
import DoubanGameLoadHandler from "./DoubanGameLoadHandler";
|
||||
|
||||
export class DoubanSearchChooseItemHandler {
|
||||
|
||||
private _app:App;
|
||||
private _doubanPlugin:DoubanPlugin;
|
||||
private _doubanSubjectHandlers:DoubanSubjectLoadHandler<DoubanSubject>[];
|
||||
private _doubanSubjectHandlerDefault:DoubanSubjectLoadHandler<DoubanSubject>;
|
||||
|
||||
|
||||
|
||||
constructor(app:App, doubanPlugin:DoubanPlugin) {
|
||||
this._app = app;
|
||||
this._doubanPlugin = doubanPlugin;
|
||||
this._doubanSubjectHandlerDefault = new DoubanOtherLoadHandler(doubanPlugin);
|
||||
this._doubanSubjectHandlers = [new DoubanMovieLoadHandler(doubanPlugin), new DoubanBookLoadHandler(doubanPlugin),
|
||||
new DoubanTeleplayLoadHandler(doubanPlugin),
|
||||
new DoubanMusicLoadHandler(doubanPlugin),
|
||||
new DoubanNoteLoadHandler(doubanPlugin),
|
||||
new DoubanGameLoadHandler(doubanPlugin),
|
||||
|
||||
this._doubanSubjectHandlerDefault];
|
||||
|
||||
}
|
||||
|
||||
public handle(searchExtract:DoubanSubject, editor: Editor):void{
|
||||
if(!searchExtract) {
|
||||
return;
|
||||
}
|
||||
let doubanSubjectHandlers:DoubanSubjectLoadHandler<DoubanSubject>[] = this._doubanSubjectHandlers
|
||||
.filter(h => h.support(searchExtract));
|
||||
if(doubanSubjectHandlers && doubanSubjectHandlers.length > 0) {
|
||||
doubanSubjectHandlers[0].handle(searchExtract.url, editor);
|
||||
}else {
|
||||
this._doubanSubjectHandlerDefault.handle(searchExtract.url, editor);
|
||||
}
|
||||
}
|
||||
|
||||
public parseText(extract:DoubanSubject, settings:DoubanPluginSettings):string {
|
||||
if(!settings) {
|
||||
return "";
|
||||
}
|
||||
let doubanSubjectHandlers:DoubanSubjectLoadHandler<DoubanSubject>[] = this._doubanSubjectHandlers
|
||||
.filter(h => h.support(extract));
|
||||
if(doubanSubjectHandlers && doubanSubjectHandlers.length > 0) {
|
||||
let result = doubanSubjectHandlers.map(h => h.parse(extract, settings));
|
||||
if(result && result.length > 0) {
|
||||
return result[0];
|
||||
}else {
|
||||
return "";
|
||||
}
|
||||
}else {
|
||||
return this._doubanSubjectHandlerDefault.parse(extract, settings);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
14
src/douban/data/handler/DoubanSubjectLoadHandler.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { DoubanPluginSettings } from "src/douban/Douban";
|
||||
import DoubanSubject from "../model/DoubanSubject";
|
||||
import { Editor } from "obsidian";
|
||||
|
||||
export default interface DoubanSubjectLoadHandler<T extends DoubanSubject> {
|
||||
|
||||
parse(extract: T, settings:DoubanPluginSettings): string;
|
||||
|
||||
support(extract:DoubanSubject):boolean;
|
||||
|
||||
handle(url:string, editor: Editor):void;
|
||||
|
||||
|
||||
}
|
||||
75
src/douban/data/handler/DoubanTeleplayLoadHandler.ts
Normal file
@ -0,0 +1,75 @@
|
||||
import { CheerioAPI } from "cheerio";
|
||||
import DoubanAbstractLoadHandler from "./DoubanAbstractLoadHandler";
|
||||
import DoubanPlugin from "main";
|
||||
import { DoubanPluginSettings } from "src/douban/Douban";
|
||||
import DoubanSubject from "../model/DoubanSubject";
|
||||
import DoubanTeleplaySubject from "../model/DoubanTeleplaySubject";
|
||||
import SchemaOrg from "src/utils/SchemaOrg";
|
||||
import { moment } from "obsidian";
|
||||
|
||||
/**
|
||||
* teleplay
|
||||
*/
|
||||
export class DoubanTeleplayLoadHandler extends DoubanAbstractLoadHandler<DoubanTeleplaySubject>{
|
||||
|
||||
getTemplate(settings: DoubanPluginSettings): string {
|
||||
return settings.movieTemplate;
|
||||
}
|
||||
|
||||
constructor(doubanPlugin:DoubanPlugin) {
|
||||
super(doubanPlugin);
|
||||
}
|
||||
|
||||
|
||||
parseText(beforeContent:string, extract: DoubanTeleplaySubject, settings:DoubanPluginSettings): string {
|
||||
return beforeContent
|
||||
.replaceAll("{{originalTitle}}", extract.originalTitle ? extract.originalTitle : "")
|
||||
.replaceAll("{{director}}", extract.director ? extract.director.map(SchemaOrg.getPersonName).map(name => super.getPersonName(name, settings)).filter(c => c).join(settings.arraySpilt) : "")
|
||||
.replaceAll("{{actor}}", extract.actor ? extract.actor.map(SchemaOrg.getPersonName).map(name => super.getPersonName(name, settings)).filter(c => c).join(settings.arraySpilt) : "")
|
||||
.replaceAll("{{author}}", extract.author ? extract.author.map(SchemaOrg.getPersonName).map(name => super.getPersonName(name, settings)).filter(c => c).join(settings.arraySpilt) : "")
|
||||
}
|
||||
|
||||
support(extract: DoubanSubject): boolean {
|
||||
return extract && extract.type && (extract.type.contains("电视剧") || extract.type.contains("Teleplay") || extract.type.contains("teleplay"));
|
||||
}
|
||||
|
||||
|
||||
parseSubjectFromHtml(data: CheerioAPI): DoubanTeleplaySubject {
|
||||
return data('script')
|
||||
.get()
|
||||
.filter(scd => "application/ld+json" == data(scd).attr("type"))
|
||||
.map(i => {
|
||||
let item = data(i).text();
|
||||
item = super.html_decode(item);
|
||||
let obj = JSON.parse(item.replace(/[\r\n\s+]/g, ''));
|
||||
let idPattern = /(\d){5,10}/g;
|
||||
let id = idPattern.exec(obj.url);
|
||||
let name = obj.name;
|
||||
let titleExec = /[\u4e00-\u9fa5]{2,20}/g.exec(name);
|
||||
let title = titleExec?titleExec[0]:name;
|
||||
|
||||
let originalTitleExec = /[a-zA-Z.\s\-]{2,50}/g.exec(name);
|
||||
let originalTitle = originalTitleExec?originalTitleExec[0]:name;
|
||||
|
||||
const result:DoubanTeleplaySubject = {
|
||||
id: id ? id[0] : '',
|
||||
type: 'Movie',
|
||||
title: title,
|
||||
originalTitle: originalTitle,
|
||||
desc: obj.description,
|
||||
url: "https://movie.douban.com" + obj.url,
|
||||
director: obj.director,
|
||||
author: obj.author,
|
||||
actor: obj.actor,
|
||||
aggregateRating: obj.aggregateRating,
|
||||
datePublished: obj.datePublished ? new Date(obj.datePublished) : undefined,
|
||||
image: obj.image,
|
||||
genre: obj.genre,
|
||||
score: obj.aggregateRating ? obj.aggregateRating.ratingValue : undefined,
|
||||
publisher: ""
|
||||
}
|
||||
return result;
|
||||
})[0];
|
||||
}
|
||||
|
||||
}
|
||||
18
src/douban/data/model/DoubanBookSubject.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import {AggregateRating, Person, WithContext} from 'schema-dts';
|
||||
|
||||
import DoubanSubject from "./DoubanSubject";
|
||||
|
||||
export default class DoubanBookSubject extends DoubanSubject {
|
||||
author:string[];
|
||||
translator:string[];
|
||||
bookType:string;
|
||||
totalWord:number;
|
||||
isbn:string;
|
||||
originalTitle:string;
|
||||
subTitle:string;
|
||||
totalPage:number
|
||||
belong:string;
|
||||
menu:string[];
|
||||
price:number;
|
||||
labels:string[];
|
||||
}
|
||||
9
src/douban/data/model/DoubanGameSubject.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import {AggregateRating, Person} from 'schema-dts';
|
||||
import DoubanSubject from './DoubanSubject';
|
||||
|
||||
|
||||
export default class DoubanGameSubject extends DoubanSubject {
|
||||
aliases:string[];
|
||||
developer:string;
|
||||
platform:string[];
|
||||
}
|
||||
13
src/douban/data/model/DoubanMovieSubject.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import {AggregateRating, Person, WithContext} from 'schema-dts';
|
||||
|
||||
import DoubanSubject from "./DoubanSubject";
|
||||
|
||||
export default class DoubanMovieSubject extends DoubanSubject {
|
||||
director:Person[];
|
||||
author:Person[];
|
||||
actor:Person[];
|
||||
aggregateRating:AggregateRating;
|
||||
genre:string[];
|
||||
originalTitle:string;
|
||||
|
||||
}
|
||||
11
src/douban/data/model/DoubanMusicSubject.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import {AggregateRating, Person, WithContext} from 'schema-dts';
|
||||
|
||||
import DoubanSubject from "./DoubanSubject";
|
||||
|
||||
export default class DoubanMusicSubject extends DoubanSubject {
|
||||
actor:string[];
|
||||
albumType:string;
|
||||
medium:string;
|
||||
numberOfRecords:number;
|
||||
barcode:string;
|
||||
}
|
||||
9
src/douban/data/model/DoubanNoteSubject.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import {AggregateRating, Person, WithContext} from 'schema-dts';
|
||||
|
||||
import DoubanSubject from "./DoubanSubject";
|
||||
|
||||
export default class DoubanNoteSubject extends DoubanSubject {
|
||||
author:string;
|
||||
authorUrl:string;
|
||||
content:string;
|
||||
}
|
||||
12
src/douban/data/model/DoubanSubject.ts
Normal file
@ -0,0 +1,12 @@
|
||||
export default class DoubanExtract {
|
||||
id: string;
|
||||
title: string;
|
||||
type: string;
|
||||
score:number;
|
||||
image:string;
|
||||
url: string;
|
||||
desc: string;
|
||||
publisher:string;
|
||||
datePublished:Date;
|
||||
genre:string[];
|
||||
}
|
||||
14
src/douban/data/model/DoubanTeleplaySubject.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import {AggregateRating, Person, WithContext} from 'schema-dts';
|
||||
|
||||
import DoubanSubject from "./DoubanSubject";
|
||||
|
||||
export default class DoubanTeleplaySubject extends DoubanSubject {
|
||||
director:Person[];
|
||||
author:Person[];
|
||||
actor:Person[];
|
||||
aggregateRating:AggregateRating;
|
||||
datePublished:Date;
|
||||
image:string;
|
||||
genre:string[];
|
||||
originalTitle:string;
|
||||
}
|
||||
52
src/douban/data/search/DoubanSearchFuzzySuggestModal.ts
Normal file
@ -0,0 +1,52 @@
|
||||
import { App, Editor, FuzzySuggestModal } from "obsidian";
|
||||
|
||||
import DoubanPlugin from "main";
|
||||
import DoubanSearchResultSubject from "../model/DoubanSearchResultSubject";
|
||||
import { log } from "src/utils/Logutil";
|
||||
|
||||
export {DoubanFuzzySuggester}
|
||||
|
||||
|
||||
class DoubanFuzzySuggester extends FuzzySuggestModal<DoubanSearchResultSubject> {
|
||||
|
||||
public editor: Editor;
|
||||
private plugin: DoubanPlugin;
|
||||
private doubanSearchResultExtract:DoubanSearchResultSubject[]
|
||||
|
||||
constructor(plugin: DoubanPlugin, editor: Editor) {
|
||||
super(app);
|
||||
this.editor = editor;
|
||||
this.plugin = plugin;
|
||||
this.setPlaceholder("Choose an item...");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
getItems(): DoubanSearchResultSubject[] {
|
||||
return this.doubanSearchResultExtract;
|
||||
}
|
||||
|
||||
getItemText(item: DoubanSearchResultSubject): string {
|
||||
let text:string = item.type + "/" + item.score + "/" + item.title + "/" + item.cast;
|
||||
return text;
|
||||
}
|
||||
|
||||
onChooseItem(item: DoubanSearchResultSubject, evt: MouseEvent | KeyboardEvent): void {
|
||||
this.plugin.doubanEtractHandler.handle(item, this.editor);
|
||||
}
|
||||
|
||||
public showSearchList(doubanSearchResultExtractList:DoubanSearchResultSubject[]) {
|
||||
this.doubanSearchResultExtract = doubanSearchResultExtractList;
|
||||
this.start();
|
||||
}
|
||||
|
||||
public start(): void {
|
||||
try {
|
||||
this.open();
|
||||
} catch (e) {
|
||||
log.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
64
src/douban/data/search/DoubanSearchModal.ts
Normal file
@ -0,0 +1,64 @@
|
||||
import { App, Editor, Modal, TextComponent } from "obsidian";
|
||||
|
||||
import DoubanPlugin from "main";
|
||||
import { i18nHelper } from "src/lang/helper";
|
||||
|
||||
export class DoubanSearchModal extends Modal {
|
||||
searchTerm: string;
|
||||
plugin: DoubanPlugin;
|
||||
editor: Editor;
|
||||
|
||||
constructor(app: App, plugin: DoubanPlugin, editor: Editor) {
|
||||
super(app);
|
||||
this.plugin = plugin;
|
||||
this.editor = editor;
|
||||
}
|
||||
|
||||
onOpen() {
|
||||
let { contentEl } = this;
|
||||
|
||||
contentEl.createEl("h3", { text: i18nHelper.getMessage('110003') });
|
||||
|
||||
const inputs = contentEl.createDiv("inputs");
|
||||
const searchInput = new TextComponent(inputs).onChange((searchTerm) => {
|
||||
this.searchTerm = searchTerm;
|
||||
});
|
||||
searchInput.inputEl.addClass("obsidian_douban_search_input");
|
||||
|
||||
searchInput.inputEl.focus();
|
||||
searchInput.inputEl.addEventListener("keydown", (event) => {
|
||||
if (event.key === "Enter") {
|
||||
this.close();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
const controls = contentEl.createDiv("controls");
|
||||
const searchButton = controls.createEl("button", {
|
||||
text: i18nHelper.getMessage('110004'),
|
||||
cls: "mod-cta",
|
||||
attr: {
|
||||
autofocus: true,
|
||||
},
|
||||
});
|
||||
searchButton.addClass("obsidian_douban_search_button");
|
||||
|
||||
searchButton.addEventListener("click", this.close.bind(this));
|
||||
const cancelButton = controls.createEl("button", { text: i18nHelper.getMessage('110005') });
|
||||
cancelButton.addEventListener("click", this.close.bind(this));
|
||||
cancelButton.addClass("obsidian_douban_search_button");
|
||||
|
||||
}
|
||||
|
||||
|
||||
async onClose() {
|
||||
let { contentEl } = this;
|
||||
|
||||
contentEl.empty();
|
||||
if (this.searchTerm) {
|
||||
await this.plugin.search(this.searchTerm, this.editor);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
25
src/douban/data/search/Search.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { DoubanPluginSettings, doubanHeadrs } from 'src/douban/Douban';
|
||||
|
||||
import DoubanSearchResultSubject from '../model/DoubanSearchResultSubject';
|
||||
import SearchParserHandler from './SearchParser';
|
||||
import { log } from 'src/utils/Logutil';
|
||||
import {request, RequestUrlParam} from "obsidian";
|
||||
import {i18nHelper} from "../../../lang/helper";
|
||||
import { load } from 'cheerio';
|
||||
|
||||
export default class Searcher {
|
||||
static search(searchItem:string, doubanSettings:DoubanPluginSettings):Promise<DoubanSearchResultSubject[]> {
|
||||
let requestUrlParam:RequestUrlParam = {
|
||||
url: doubanSettings.searchUrl + searchItem,
|
||||
method: "GET",
|
||||
headers: JSON.parse(doubanSettings.searchHeaders),
|
||||
throw: true
|
||||
};
|
||||
return request(requestUrlParam)
|
||||
.then(load)
|
||||
.then(SearchParserHandler.parseSearch)
|
||||
.catch(e => log.error(i18nHelper.getMessage('130101')))
|
||||
;
|
||||
|
||||
};
|
||||
}
|
||||
33
src/douban/data/search/SearchParser.ts
Normal file
@ -0,0 +1,33 @@
|
||||
import { CheerioAPI } from "cheerio";
|
||||
import DoubanSearchResultSubject from "../model/DoubanSearchResultSubject";
|
||||
|
||||
export default class SearchParserHandler {
|
||||
static parseSearch(dataHtml:CheerioAPI):DoubanSearchResultSubject[] {
|
||||
return dataHtml('.result')
|
||||
.get()
|
||||
.map((i:any) => {
|
||||
const item = dataHtml(i);
|
||||
let idPattern = /(\d){5,10}/g;
|
||||
let urlPattern = /(https%3A%2F%2F)\S+(\d){5,10}/g;
|
||||
let linkValue = item.find("div.content > div > h3 > a").attr("href");
|
||||
let ececResult = idPattern.exec(linkValue);
|
||||
let urlResult = urlPattern.exec(linkValue);
|
||||
let cast = item.find(".subject-cast").text();
|
||||
let score = item.find(".rating_nums").text();
|
||||
const result:DoubanSearchResultSubject = {
|
||||
id: ececResult ? ececResult[0] : '',
|
||||
title: item.find("div.content > div > h3 > a").text(),
|
||||
score: score ? Number(score) : null,
|
||||
cast: cast,
|
||||
type: item.find("div.content > div > h3 > span").text(),
|
||||
desc: item.find("div.content > p").text(),
|
||||
url: urlResult ? decodeURIComponent(urlResult[0]) : 'https://www.douban.com',
|
||||
image: "",
|
||||
publisher: "",
|
||||
datePublished: undefined,
|
||||
genre: []
|
||||
};
|
||||
return result;
|
||||
})
|
||||
};
|
||||
}
|
||||
23
src/lang/helper.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import en from './locale/en';
|
||||
import zhCN from './locale/zh-cn';
|
||||
|
||||
const localeMap: { [k: string]: Partial<typeof en> } = {
|
||||
en,
|
||||
zh: zhCN,
|
||||
};
|
||||
|
||||
const lang = window.localStorage.getItem('language');
|
||||
const locale = localeMap[lang || 'en'];
|
||||
|
||||
|
||||
export default class I18nHelper {
|
||||
public getMessage(str: keyof typeof en): string {
|
||||
if (!locale) {
|
||||
console.error('Error: obsidian douban locale not found', lang);
|
||||
}
|
||||
|
||||
return (locale && locale[str]) || en[str];
|
||||
}
|
||||
}
|
||||
|
||||
export const i18nHelper:I18nHelper = new I18nHelper();
|
||||
89
src/lang/locale/en.ts
Normal file
@ -0,0 +1,89 @@
|
||||
//简体中文
|
||||
export default {
|
||||
//main.ts
|
||||
'110001': 'search douban by current file name',
|
||||
'110002': 'search douban and import to current file',
|
||||
'110003': `Enter Search Term:`,
|
||||
'110004': `Search`,
|
||||
'110005': `Cancel`,
|
||||
'110006': `sync douban broadcast ot Obsidian`,
|
||||
|
||||
//DoubanSettingTab
|
||||
'1201' : `Obsidian Douban`,
|
||||
'120001': `Douban Search Url`,
|
||||
'120002': `Douban search page request address. `,
|
||||
'120003': `First go to:`,
|
||||
'120004': `Don't enter anything in the search input box, just click Search,`,
|
||||
'120005': `The redirected web page address is the search address,`,
|
||||
'120006': `Just copy the web address to the current input box.`,
|
||||
|
||||
'120101': `Movie Content Template`,
|
||||
'120102': `Set markdown Movie template for extract to be inserted.`,
|
||||
'120103': `Available template variables are :`,
|
||||
'120104': `{{id}}, {{title}}, {{type}}, {{score}}, {{image}},`,
|
||||
'120105': `{{url}}, {{desc}}, {{datePublished}}, {{genre}}, `,
|
||||
'120106': `{{originalTitle}},{{director}}, {{author}},`,
|
||||
'120107': ` {{actor}}`,
|
||||
|
||||
'120201': `Book Content Template`,
|
||||
'120202': `Set markdown Book template for extract to be inserted.`,
|
||||
'120203': `Available Book template variables are :`,
|
||||
'120204': `{{id}}, {{title}}, {{type}}, {{score}}, {{image}},`,
|
||||
'120205': `{{url}}, {{desc}}, {{datePublished}}, {{publisher}}`,
|
||||
'120206': `{{originalTitle}}, {{subTitle}}, {{author}},`,
|
||||
'120207': `{{translator}}, {{isbn}}, {{price}}, {{totalPage}}`,
|
||||
|
||||
'120301': `Music Content Template`,
|
||||
'120302': `Set markdown Music template for extract to be inserted.`,
|
||||
'120303': `Available Music template variables are :`,
|
||||
'120304': `{{id}}, {{title}}, {{type}}, {{score}}, {{image}},`,
|
||||
'120305': `{{url}}, {{desc}}, {{datePublished}}, {{genre}},`,
|
||||
'120306': `{{actor}}, {{medium}}, {{albumType}},`,
|
||||
'120307': `{{barcode}}, {{numberOfRecords}}`,
|
||||
|
||||
'120401': `Article Content Template`,
|
||||
'120402': `Set markdown Article template for extract to be inserted.`,
|
||||
'120403': `Available Article template variables are :`,
|
||||
'120404': `{{id}}, {{title}}, {{type}}, {{image}},`,
|
||||
'120405': `{{url}}, {{desc}}, {{datePublished}}`,
|
||||
'120406': `{{author}}, {{authorUrl}}, {{content}}`,
|
||||
|
||||
'121301': `Game Content Template`,
|
||||
'121302': `Set markdown Game template for extract to be inserted.`,
|
||||
'121303': `Available Game template variables are :`,
|
||||
'121304': `{{id}}, {{title}}, {{type}}, {{score}}, {{image}},`,
|
||||
'121305': `{{url}}, {{desc}}, {{publisher}}, {{datePublished}}`,
|
||||
'121306': `{{genre}}, {{aliases}}, {{developer}}, {{platform}}`,
|
||||
|
||||
'120501': `Date Format`,
|
||||
'120502': `Time Format`,
|
||||
'120503': `This format will be used when available template variables contain date.`,
|
||||
'120504': `This format will be used when available template variables contain time.`,
|
||||
|
||||
'120506': `For more syntax, refer to`,
|
||||
'120507': `Your current syntax looks like this`,
|
||||
'120508': `format reference`,
|
||||
'120601': `Array Spilt String`,
|
||||
'120602': `string to join between array type, such as authors, actors.
|
||||
example: '/'
|
||||
the list of actor's name will be shown as: 'actor1/actor2/actor3'`,
|
||||
'120701': `Douban Request Headers`,
|
||||
'120801': `This type of import is not supported temporarily, please go to github to submit issues for help`,
|
||||
'120901': `Douban`,
|
||||
'121201': `Person Name Language Mode`,
|
||||
'121202': `options:`,
|
||||
'121203': `Chinese Name mode, person name only show Chinese name`,
|
||||
'121204': `English Name mode, person name only show English name`,
|
||||
'121205': `Chinese English Name mode, show Chinese and English name both`,
|
||||
'121206': `Chinese Name`,
|
||||
'121207': `English Name`,
|
||||
'121208': `Chinese And English Name`,
|
||||
|
||||
|
||||
//error
|
||||
'130101': `Fetch Data Error, You can go to Github add Issues`,
|
||||
'130201': `Obsidian Douban Plugin Error: `,
|
||||
'130301': `Obsidian Douban Plugin Warn: `,
|
||||
'140101': `Not support for current type. You can add Issues at Github:Wanxp/obsidian-douban`,
|
||||
|
||||
}
|
||||
93
src/lang/locale/zh-cn.ts
Normal file
@ -0,0 +1,93 @@
|
||||
//简体中文
|
||||
export default {
|
||||
//main.ts
|
||||
'110001': '用当前文档名搜索豆瓣并写入当前文档',
|
||||
'110002': '在豆瓣搜索并写入到当前文档',
|
||||
'110003': `输入搜索内容:`,
|
||||
'110004': `搜索`,
|
||||
'110005': `取消`,
|
||||
'110006': `同步豆瓣广播至Obsidian`,
|
||||
|
||||
//DoubanSettingTab
|
||||
'1201' : `Obsidian-豆瓣`,
|
||||
'120001': `豆瓣搜索地址`,
|
||||
'120002': `豆瓣搜索页面请求地址, 通常是网页搜索的地址. `,
|
||||
'120003': `先访问:`,
|
||||
'120004': `然后在搜索输入框不输入任何内容,直接点击搜索,`,
|
||||
'120005': `所跳转的网页地址即是搜索地址,`,
|
||||
'120006': `将网页地址复制到当前输入框即可,`,
|
||||
|
||||
'120101': `电影文本模板`,
|
||||
'120102': `设置选择电影后导入的文本内容模板,`,
|
||||
'120103': `支持以下参数名称 :`,
|
||||
'120104': `{{id}}, {{title}}, {{type}}, {{score}}, {{image}},`,
|
||||
'120105': `{{url}}, {{desc}}, {{datePublished}}, {{genre}}, `,
|
||||
'120106': `{{originalTitle}},{{director}}, {{author}},`,
|
||||
'120107': ` {{actor}}`,
|
||||
|
||||
'120201': `书籍文本模板`,
|
||||
'120202': `设置选择书籍后导入的文本内容模板,`,
|
||||
'120203': `支持以下参数名称 :`,
|
||||
'120204': `{{id}}, {{title}}, {{type}}, {{score}}, {{image}},`,
|
||||
'120205': `{{url}}, {{desc}}, {{datePublished}}, {{publisher}}`,
|
||||
'120206': `{{originalTitle}}, {{subTitle}}, {{author}},`,
|
||||
'120207': `{{translator}}, {{isbn}}, {{price}}, {{totalPage}}`,
|
||||
|
||||
'120301': `音乐文本模板`,
|
||||
'120302': `设置选择音乐后导入的文本内容模板,`,
|
||||
'120303': `支持以下参数名称 :`,
|
||||
'120304': `{{id}}, {{title}}, {{type}}, {{image}},`,
|
||||
'120305': `{{url}}, {{desc}}, {{datePublished}}`,
|
||||
'120306': `{{genre}}, {{actor}}, {{medium}}, {{albumType}},`,
|
||||
'120307': `{{barcode}}, {{numberOfRecords}}`,
|
||||
|
||||
'120401': `日记文本模板`,
|
||||
'120402': `设置选择日记后导入的文本内容模板,`,
|
||||
'120403': `支持以下参数名称 :`,
|
||||
'120404': `{{id}}, {{title}}, {{type}}, {{image}},`,
|
||||
'120405': `{{url}}, {{desc}}, {{datePublished}}`,
|
||||
'120406': `{{author}}, {{authorUrl}}, {{content}}`,
|
||||
|
||||
'121301': `游戏文本模板`,
|
||||
'121302': `设置选择游戏后导入的文本内容模板,`,
|
||||
'121303': `支持以下参数名称 :`,
|
||||
'121304': `{{id}}, {{title}}, {{type}}, {{score}}, {{image}},`,
|
||||
'121305': `{{url}}, {{desc}}, {{publisher}}, {{datePublished}}`,
|
||||
'121306': `{{genre}}, {{aliases}}, {{developer}}, {{platform}}`,
|
||||
|
||||
|
||||
'120501': `日期格式`,
|
||||
'120503': `这个格式是给上面获取到的参数进行格式化日期时显示的内容 .`,
|
||||
'120502': `时间格式`,
|
||||
'120504': `这个格式是给上面获取到的参数进行格式化时间时显示的内容 .`,
|
||||
'120506': `详细介绍请参考`,
|
||||
'120507': `时间参数时间格式预览`,
|
||||
'120508': `格式参考`,
|
||||
'120601': `数组分割字符串`,
|
||||
'120602': `当模板中的变量存在数组, 则需要设定数组元素中的分割符号,比如演员列表等.
|
||||
举例: '/'
|
||||
则演员表将会显示为: '演员1/演员2/演员3'`,
|
||||
'120701': `豆瓣HTTP请求头`,
|
||||
'120702': `如果豆瓣搜索或者获取数据失败,请尝试修改这个参数,\n
|
||||
参数获取方式为:\n
|
||||
1. 访问http://www.douban.com
|
||||
2. 复制请求头,仅复制以下请求头 `,
|
||||
'120801': `暂时不支持该类型导入,请至Github提交issuess获取帮助`,
|
||||
'120901': `豆瓣网`,
|
||||
|
||||
'121201': `人名显示模式`,
|
||||
'121202': `可选项:`,
|
||||
'121203': `中文名称模式, 人名只显示中文名`,
|
||||
'121204': `英文名称模式, 人名只显示英文名`,
|
||||
'121205': `中文和英文名称模式, 人名同时显示中文和英文名`,
|
||||
'121206': `中文名`,
|
||||
'121207': `英文名`,
|
||||
'121208': `中文名和英文名`,
|
||||
|
||||
'130101': `获取数据失败,您如有需要请至Github提交Issues`,
|
||||
'130102': `Obsidian Douban插件错误提示:`,
|
||||
'130103': `Obsidian Douban插件异常提示:`,
|
||||
'140101': `当前版本暂不支持该类型导入,请升级Obsidian Douban或至github提交issuess获取帮助`,
|
||||
|
||||
|
||||
}
|
||||
@ -1,550 +0,0 @@
|
||||
import {i18nHelper} from "../lang/helper";
|
||||
import DoubanSearchResultSubject from "../douban/data/model/DoubanSearchResultSubject";
|
||||
import StringUtil from "../utils/StringUtil";
|
||||
import {DoubanPluginOnlineSettings} from "../douban/setting/model/DoubanPluginOnlineSettings";
|
||||
import {DataField} from "../utils/model/DataField";
|
||||
|
||||
/**
|
||||
* 常量池
|
||||
*/
|
||||
export const BasicConst = {
|
||||
YAML_FRONT_MATTER_SYMBOL: '---',
|
||||
/**
|
||||
* 状态栏显示毫秒数
|
||||
*/
|
||||
CLEAN_STATUS_BAR_DELAY: 5000,
|
||||
/**
|
||||
* 请求豆瓣周期(多少秒一次)
|
||||
*/
|
||||
CALL_DOUBAN_DELAY: 4000,
|
||||
/**
|
||||
* 请求豆瓣周期(多少秒一次)
|
||||
*/
|
||||
CALL_DOUBAN_DELAY_RANGE: 4000,
|
||||
/**
|
||||
* 多少条后同步速率变慢,防止403
|
||||
*/
|
||||
SLOW_SIZE: 200,
|
||||
|
||||
/**
|
||||
* 请求豆瓣周期(多少秒一次) 慢速模式
|
||||
*/
|
||||
CALL_DOUBAN_DELAY_SLOW: 10000,
|
||||
/**
|
||||
* 请求豆瓣周期(多少秒一次)
|
||||
*/
|
||||
CALL_DOUBAN_DELAY_RANGE_SLOW: 5000,
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 预估程序处理时间长度
|
||||
* @private
|
||||
*/
|
||||
export const ESTIMATE_TIME_PER: number = 2000;
|
||||
|
||||
/**
|
||||
* 预估每次请求+处理时间长度(慢速模式)
|
||||
* @private
|
||||
*/
|
||||
export const ESTIMATE_TIME_PER_WITH_REQUEST_SLOW: number = ESTIMATE_TIME_PER + BasicConst.CALL_DOUBAN_DELAY_SLOW + BasicConst.CALL_DOUBAN_DELAY_RANGE_SLOW / 2;
|
||||
|
||||
/**
|
||||
* 预估每次请求+处理时间长度(正常模式)
|
||||
* @private
|
||||
*/
|
||||
export const ESTIMATE_TIME_PER_WITH_REQUEST: number = ESTIMATE_TIME_PER + BasicConst.CALL_DOUBAN_DELAY + BasicConst.CALL_DOUBAN_DELAY_RANGE / 2;
|
||||
|
||||
|
||||
/**
|
||||
* 模板类型
|
||||
*/
|
||||
export enum TemplateTextMode {
|
||||
NORMAL,
|
||||
YAML,
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索结果处理模式
|
||||
*/
|
||||
export enum SearchHandleMode {
|
||||
/**
|
||||
* 为了替换当前文档
|
||||
*/
|
||||
FOR_REPLACE,
|
||||
/**
|
||||
* 为了创建文档
|
||||
*/
|
||||
FOR_CREATE,
|
||||
}
|
||||
|
||||
/**
|
||||
* 名称模式
|
||||
*/
|
||||
export enum PersonNameMode {
|
||||
CH_NAME = "CH",
|
||||
EN_NAME = "EN",
|
||||
CH_EN_NAME = "CH_EN",
|
||||
}
|
||||
|
||||
/**
|
||||
* 模板的key
|
||||
*
|
||||
*/
|
||||
export enum TemplateKey {
|
||||
movieTemplateFile = 'movieTemplateFile',
|
||||
bookTemplateFile = 'bookTemplateFile',
|
||||
musicTemplateFile = 'musicTemplateFile',
|
||||
noteTemplateFile = 'noteTemplateFile',
|
||||
gameTemplateFile = 'gameTemplateFile',
|
||||
teleplayTemplateFile = 'teleplayTemplateFile',
|
||||
}
|
||||
|
||||
export enum SupportType {
|
||||
all = "all",
|
||||
movie = 'movie',
|
||||
book = 'book',
|
||||
music = 'music',
|
||||
note = 'note',
|
||||
game = 'game',
|
||||
teleplay = 'teleplay',
|
||||
theater = 'theater',
|
||||
}
|
||||
export const SupportTypeMap:object = {
|
||||
"all": SupportType.all,
|
||||
"movie": SupportType.movie,
|
||||
"book": SupportType.book,
|
||||
"music": SupportType.music,
|
||||
"note": SupportType.note,
|
||||
"game": SupportType.game,
|
||||
"teleplay": SupportType.teleplay,
|
||||
"theater": SupportType.theater,
|
||||
"ALL": SupportType.all,
|
||||
"MOVIE": SupportType.movie,
|
||||
"BOOK": SupportType.book,
|
||||
"MUSIC": SupportType.music,
|
||||
"NOTE": SupportType.note,
|
||||
"GAME": SupportType.game,
|
||||
"TELEPLAY": SupportType.teleplay,
|
||||
"THEATER": SupportType.theater,
|
||||
}
|
||||
|
||||
|
||||
export enum PropertyName {
|
||||
//base
|
||||
id = "id",
|
||||
title = "title",
|
||||
type = "type",
|
||||
score = "score",
|
||||
image = "image",
|
||||
imageUrl = "imageUrl",
|
||||
url = "url",
|
||||
desc = "desc",
|
||||
publisher = "publisher",
|
||||
datePublished = "datePublished",
|
||||
genre = "genre",
|
||||
|
||||
//user
|
||||
tags = "tags",
|
||||
rate = "rate",
|
||||
state = "state",
|
||||
collectionDate = "collectionDate",
|
||||
comment = "comment",
|
||||
|
||||
|
||||
//book
|
||||
author = "author",
|
||||
translator = "translator",
|
||||
isbn = "isbn",
|
||||
originalTitle = "originalTitle",
|
||||
subTitle = "subTitle",
|
||||
totalPage = "totalPage",
|
||||
series = "series",
|
||||
menu = "menu",
|
||||
price = "price",
|
||||
binding = "binding",
|
||||
producer = "producer",
|
||||
|
||||
//movie
|
||||
director = "director",
|
||||
actor = "actor",
|
||||
aggregateRating = "aggregateRating",
|
||||
aliases = "aliases",
|
||||
country = "country",
|
||||
language = "language",
|
||||
time = "time",
|
||||
IMDb = "IMDb",
|
||||
|
||||
//music
|
||||
albumType = "albumType",
|
||||
medium = "medium",
|
||||
records = "records",
|
||||
barcode = "barcode",
|
||||
|
||||
//game
|
||||
platform = "platform",
|
||||
developer = "developer",
|
||||
|
||||
|
||||
//teleplay
|
||||
episode = "episode",
|
||||
|
||||
//theater
|
||||
|
||||
|
||||
//note
|
||||
authorUrl = "authorUrl",
|
||||
content = "content",
|
||||
}
|
||||
|
||||
/**
|
||||
* 名称模式选项
|
||||
*/
|
||||
// @ts-ignore
|
||||
export const SearchTypeRecords: { [key in SupportType]: string } = {
|
||||
[SupportType.all]: i18nHelper.getMessage('ALL'),
|
||||
[SupportType.movie]: i18nHelper.getMessage('MOVIE_AND_TELEPLAY'),
|
||||
[SupportType.book]: i18nHelper.getMessage('BOOK'),
|
||||
[SupportType.music]: i18nHelper.getMessage('MUSIC'),
|
||||
[SupportType.note]: i18nHelper.getMessage('NOTE'),
|
||||
[SupportType.game]: i18nHelper.getMessage('GAME'),
|
||||
[SupportType.theater]: i18nHelper.getMessage('THEATER'),
|
||||
}
|
||||
|
||||
/**
|
||||
* 名称模式选项
|
||||
*/
|
||||
export const PersonNameModeRecords: { [key in PersonNameMode]: string } = {
|
||||
[PersonNameMode.CH_NAME]: i18nHelper.getMessage('121206'),
|
||||
[PersonNameMode.EN_NAME]: i18nHelper.getMessage('121207'),
|
||||
[PersonNameMode.CH_EN_NAME]: i18nHelper.getMessage('121208'),
|
||||
}
|
||||
|
||||
export enum SyncType {
|
||||
movie = 'movie',
|
||||
book = 'book',
|
||||
game = 'game',
|
||||
broadcast = 'broadcast',
|
||||
note = 'note',
|
||||
music = 'music',
|
||||
teleplay = 'teleplay'
|
||||
}
|
||||
|
||||
export const SyncTypeUrlDomain: Map<SyncType, string> = new Map([
|
||||
[SyncType.movie , 'movie'],
|
||||
[SyncType.book , 'book'],
|
||||
[SyncType.broadcast , 'broadcast'],
|
||||
[SyncType.note , 'note'],
|
||||
[SyncType.music , 'music'],
|
||||
[SyncType.teleplay , 'movie'],
|
||||
[SyncType.game, 'games'],
|
||||
]
|
||||
)
|
||||
|
||||
/**
|
||||
* 同步模式选项
|
||||
*/
|
||||
// @ts-ignore
|
||||
export const SyncTypeRecords: { [key in SyncType | string]: string } = {
|
||||
[SyncType.movie]: i18nHelper.getMessage('504103'),
|
||||
[SyncType.teleplay]: i18nHelper.getMessage('504107'),
|
||||
[SyncType.book]: i18nHelper.getMessage('504102'),
|
||||
// [SyncType.broadcast]: i18nHelper.getMessage('504104'),
|
||||
// [SyncType.note]: i18nHelper.getMessage('504105'),
|
||||
[SyncType.music]: i18nHelper.getMessage('504106'),
|
||||
[SyncType.game]: i18nHelper.getMessage('504108'),
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步豆瓣每页的大小
|
||||
*/
|
||||
export const PAGE_SIZE: number = 30;
|
||||
|
||||
/**
|
||||
* 多少条后同步速率变慢,防止403
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* 动作
|
||||
*/
|
||||
export enum Action {
|
||||
SearchAndReplace = 'SearchAndReplace',
|
||||
SearchAndCrate = 'SearchAndCrate',
|
||||
Sync = 'Sync',
|
||||
SearchEditorAndReplace = 'SearchEditorAndReplace'
|
||||
}
|
||||
|
||||
export enum SyncItemStatus {
|
||||
exists = 'exists',
|
||||
replace = 'replace',
|
||||
create = 'create',
|
||||
fail = 'fail',
|
||||
failByDiffType = 'failByDiffType',
|
||||
unHandle = 'unHandle',
|
||||
}
|
||||
|
||||
export enum NavigateType {
|
||||
previous = "previous",
|
||||
next = "next",
|
||||
|
||||
nextNeedLogin = "nextNeedLogin"
|
||||
}
|
||||
|
||||
export const DoubanSearchResultSubjectPreviousPage: DoubanSearchResultSubject = {
|
||||
cast: "",
|
||||
datePublished: undefined,
|
||||
desc: "",
|
||||
genre: [],
|
||||
id: "",
|
||||
image: "",
|
||||
imageUrl: "",
|
||||
publisher: "",
|
||||
score: 0,
|
||||
title: i18nHelper.getMessage("150102"),
|
||||
type: "navigate",
|
||||
url: NavigateType.previous
|
||||
}
|
||||
|
||||
export const DoubanSearchGroupPublishResultSubjectPreviousPage: DoubanSearchResultSubject = {
|
||||
cast: "",
|
||||
datePublished: undefined,
|
||||
desc: "",
|
||||
genre: [],
|
||||
id: "",
|
||||
image: "",
|
||||
imageUrl: "",
|
||||
publisher: "",
|
||||
score: 0,
|
||||
title: i18nHelper.getMessage("150106"),
|
||||
type: "navigate",
|
||||
url: NavigateType.previous
|
||||
}
|
||||
|
||||
export const DoubanSearchGroupPublishResultSubjectNextPage: DoubanSearchResultSubject = {
|
||||
cast: "",
|
||||
datePublished: undefined,
|
||||
desc: "",
|
||||
genre: [],
|
||||
id: "",
|
||||
image: "",
|
||||
imageUrl: "",
|
||||
publisher: "",
|
||||
score: 0,
|
||||
title: i18nHelper.getMessage("150105"),
|
||||
type: "navigate",
|
||||
url: NavigateType.next
|
||||
}
|
||||
|
||||
export const DoubanSearchResultSubjectNextPage: DoubanSearchResultSubject = {
|
||||
cast: "",
|
||||
datePublished: undefined,
|
||||
desc: "",
|
||||
genre: [],
|
||||
id: "",
|
||||
image: "",
|
||||
imageUrl: "",
|
||||
publisher: "",
|
||||
score: 0,
|
||||
title: i18nHelper.getMessage("150103"),
|
||||
type: "navigate",
|
||||
url: NavigateType.next
|
||||
}
|
||||
|
||||
export const DoubanSearchResultSubjectNextPageNeedLogin: DoubanSearchResultSubject = {
|
||||
cast: "",
|
||||
datePublished: undefined,
|
||||
desc: "",
|
||||
genre: [],
|
||||
id: "",
|
||||
image: "",
|
||||
imageUrl: "",
|
||||
publisher: "",
|
||||
score: 0,
|
||||
title: i18nHelper.getMessage("150104"),
|
||||
type: "navigate",
|
||||
url: NavigateType.nextNeedLogin
|
||||
}
|
||||
|
||||
export const SEARCH_ITEM_PAGE_SIZE: number = 20;
|
||||
|
||||
/**
|
||||
* 豆瓣默认请求头
|
||||
* @type {string}
|
||||
**/
|
||||
export const DEFAULT_DOUBAN_HEADERS = StringUtil.parseHeaders(`
|
||||
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
|
||||
Accept-Language: zh-CN,zh;q=0.9
|
||||
Cache-Control: max-age=0
|
||||
Connection: keep-alive
|
||||
Host: www.douban.com
|
||||
Sec-Fetch-Dest: document
|
||||
Sec-Fetch-Mode: navigate
|
||||
Sec-Fetch-Site: none
|
||||
Sec-Fetch-User: ?1
|
||||
Upgrade-Insecure-Requests: 1
|
||||
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
|
||||
sec-ch-ua: "Not/A)Brand";v="99", "Google Chrome";v="115", "Chromium";v="115"
|
||||
sec-ch-ua-mobile: ?0
|
||||
sec-ch-ua-platform: "Windows"
|
||||
`)
|
||||
|
||||
/**
|
||||
* 属性设置
|
||||
*/
|
||||
export const ONLINE_SETTING_DEFAULT: DoubanPluginOnlineSettings = {
|
||||
properties: [
|
||||
{
|
||||
type: SupportType.book,
|
||||
name: PropertyName.comment,
|
||||
selectors: ['#interest_sect_level > div > span:nth-child(7)'
|
||||
]
|
||||
},
|
||||
{
|
||||
type: SupportType.movie,
|
||||
name: PropertyName.comment,
|
||||
selectors: ['#interest_sect_level > div > span:nth-child(8)',
|
||||
'#interest_sect_level > div > span:nth-child(7)',
|
||||
'#interest_sect_level > div > span:nth-child(9)'
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理状态
|
||||
*/
|
||||
export enum SubjectHandledStatus {
|
||||
init = 'init',
|
||||
saved = 'saved',
|
||||
syncTypeDiffAbort = 'syncTypeDiffAbort',
|
||||
}
|
||||
|
||||
export const DEFAULT_SETTINGS_ARRAY_INPUT_SIZE = 2;
|
||||
|
||||
|
||||
export enum DataValueType {
|
||||
date,
|
||||
number,
|
||||
string,
|
||||
person,
|
||||
array,
|
||||
url,
|
||||
path,
|
||||
}
|
||||
|
||||
export enum DataTargetType {
|
||||
fileName,
|
||||
yaml,
|
||||
content,
|
||||
}
|
||||
|
||||
export const EXAMPLE_RATE = 8.5;
|
||||
export const EXAMPLE_RATE_MAX = 10;
|
||||
|
||||
export const EXAMPLE_SUBJECT_MAP: Map<string, DataField> = new Map([
|
||||
["id", new DataField("id", DataValueType.string, DataValueType.string, "2253379")],
|
||||
["title", new DataField("title", DataValueType.string, DataValueType.string, "简爱")],
|
||||
["type", new DataField("type", DataValueType.string, DataValueType.string, "book")],
|
||||
["score", new DataField("score", DataValueType.number, DataValueType.number, EXAMPLE_RATE)],
|
||||
["image", new DataField("image", DataValueType.url, DataValueType.url, "https://img9.doubanio.com/view/subject/s/public/s1070959.jpg")],
|
||||
["imageUrl", new DataField("imageUrl", DataValueType.url, DataValueType.url, "https://img9.doubanio.com/view/subject/s/public/s1070959.jpg")],
|
||||
["url", new DataField("url", DataValueType.url, DataValueType.url, "https://book.douban.com/subject/2253379/")],
|
||||
["desc", new DataField("desc", DataValueType.string, DataValueType.string, "简爱是一部关于爱、关于成长、关于追求自由与尊严的伟大小说。")],
|
||||
["publisher", new DataField("publisher", DataValueType.string, DataValueType.string, "人民文学出版社")],
|
||||
["datePublished", new DataField("datePublished", DataValueType.date, DataValueType.date, "2020-1-1")],
|
||||
["genre", new DataField("genre", DataValueType.array, DataValueType.array, "小说")],
|
||||
["tags", new DataField("tags", DataValueType.array, DataValueType.array, "小说")],
|
||||
["rate", new DataField("rate", DataValueType.number, DataValueType.number, 9.0)],
|
||||
["state", new DataField("state", DataValueType.string, DataValueType.string, "wish")],
|
||||
["collectionDate", new DataField("collectionDate", DataValueType.date, DataValueType.date, "2020-1-1")],
|
||||
["comment", new DataField("comment", DataValueType.string, DataValueType.string, "简爱是一部关于爱、关于成长、关于追求自由与尊严的伟大小说。")],
|
||||
["author", new DataField("author", DataValueType.person, DataValueType.person, "夏洛蒂·勃朗特")],
|
||||
["translator", new DataField("translator", DataValueType.person, DataValueType.person, "李继宏")],
|
||||
]);
|
||||
|
||||
export const MAX_STAR_NUMBER = 100;
|
||||
|
||||
export enum PictureBedType {
|
||||
PicGo = "PicGo"
|
||||
}
|
||||
|
||||
export const PictureBedSetting_PicGo ={
|
||||
url: "http://127.0.0.1:36677/upload"
|
||||
}
|
||||
|
||||
export const PictureBedTypeRecords: { [key in PictureBedType]: string } = {
|
||||
[PictureBedType.PicGo]: PictureBedType.PicGo
|
||||
}
|
||||
|
||||
|
||||
export enum SyncConditionType {
|
||||
/**
|
||||
* 最近新变动
|
||||
*/
|
||||
ALL = "all",
|
||||
// /**
|
||||
// * 最近新变动
|
||||
// */
|
||||
// LAST_UPDATE = "lastUpdate",
|
||||
|
||||
/**
|
||||
* 最近10条
|
||||
*/
|
||||
LAST_THIRTY = "lastThirty",
|
||||
|
||||
/**
|
||||
* 自定义时间
|
||||
*/
|
||||
CUSTOM_TIME = "customTime",
|
||||
|
||||
/**
|
||||
* 自定义条数
|
||||
*/
|
||||
CUSTOM_ITEM = "customItem",
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 名称模式选项
|
||||
*/
|
||||
// @ts-ignore
|
||||
export const SyncConditionTypeRecords: { [key in SyncConditionType|string]: string } = {
|
||||
[SyncConditionType.ALL]: i18nHelper.getMessage('110071'),
|
||||
// [SyncConditionType.LAST_UPDATE]: i18nHelper.getMessage('110072'),
|
||||
[SyncConditionType.LAST_THIRTY]: i18nHelper.getMessage('110075'),
|
||||
[SyncConditionType.CUSTOM_ITEM]: i18nHelper.getMessage('110076'),
|
||||
[SyncConditionType.CUSTOM_TIME]: i18nHelper.getMessage('110074'),
|
||||
|
||||
}
|
||||
|
||||
|
||||
export const DoubanSearchResultSubject_EMPTY: DoubanSearchResultSubject = {
|
||||
id: '',
|
||||
title: i18nHelper.getMessage('150107'),
|
||||
score: null,
|
||||
cast: '',
|
||||
type: 'navigate',
|
||||
desc: '-',
|
||||
url: 'https://www.douban.com',
|
||||
image: "",
|
||||
imageUrl: "",
|
||||
publisher: "",
|
||||
datePublished: undefined,
|
||||
genre: []
|
||||
};
|
||||
|
||||
export const DoubanSearchResultSubject_TIP_EMPTY: DoubanSearchResultSubject = {
|
||||
id: '',
|
||||
title: i18nHelper.getMessage('150108'),
|
||||
score: null,
|
||||
cast: '',
|
||||
type: 'navigate',
|
||||
desc: '-',
|
||||
url: 'https://www.douban.com',
|
||||
image: "",
|
||||
imageUrl: "",
|
||||
publisher: "",
|
||||
datePublished: undefined,
|
||||
genre: []
|
||||
};
|
||||
@ -1,67 +0,0 @@
|
||||
import {DoubanPluginSetting} from "../douban/setting/model/DoubanPluginSetting";
|
||||
import {PersonNameMode, PictureBedSetting_PicGo, PictureBedType, SupportType} from "./Constsant";
|
||||
|
||||
export const DEFAULT_SETTINGS: DoubanPluginSetting = {
|
||||
pictureBedFlag: false,
|
||||
pictureBedSetting: PictureBedSetting_PicGo,
|
||||
pictureBedType: PictureBedType.PicGo,
|
||||
arraySettings: [
|
||||
{
|
||||
"arrayName": "ArrayType1",
|
||||
"arrayStart": "",
|
||||
"arrayElementStart": "[[",
|
||||
"arraySpiltV2": ",",
|
||||
"arrayElementEnd": "]]",
|
||||
"arrayEnd": "",
|
||||
"index": 1
|
||||
}
|
||||
],
|
||||
onlineSettingsFileName: "obsidian_douban_plugin_online_settings.json",
|
||||
onlineSettingsGistId: "35693f9ece9bd6abba98f94e81afde19",
|
||||
movieTemplateFile: ``,
|
||||
bookTemplateFile: ``,
|
||||
musicTemplateFile: ``,
|
||||
noteTemplateFile: ``,
|
||||
gameTemplateFile: ``,
|
||||
teleplayTemplateFile: ``,
|
||||
searchUrl: 'https://www.douban.com/search?q=',
|
||||
dateFormat: "yyyy-MM-DD",
|
||||
timeFormat: "HH:mm:ss",
|
||||
arrayStart: "",
|
||||
arrayElementStart: "\\n - ",
|
||||
arraySpiltV2: "",
|
||||
arrayElementEnd: "",
|
||||
arrayEnd: "",
|
||||
personNameMode: PersonNameMode.CH_NAME,
|
||||
dataFilePath: "",
|
||||
dataFileNamePath: "/{{type}}/{{title}}",
|
||||
statusBar: true,
|
||||
debugMode: false,
|
||||
customProperties: [
|
||||
{name: 'myType', value: 'movie', field: SupportType.movie},
|
||||
{name: 'myType', value: 'book', field: SupportType.book},
|
||||
{name: 'myType', value: 'music', field: SupportType.music},
|
||||
{name: 'myType', value: 'note', field: SupportType.note},
|
||||
{name: 'myType', value: 'game', field: SupportType.game},
|
||||
{name: 'myType', value: 'teleplay', field: SupportType.teleplay},
|
||||
{name: 'myType', value: 'theater', field: SupportType.theater},
|
||||
],
|
||||
loginCookiesContent: '',
|
||||
loginHeadersContent: '',
|
||||
cacheImage: true,
|
||||
cacheHighQuantityImage: true,
|
||||
attachmentPath: 'assets',
|
||||
attachmentFileName: "{{title}}",
|
||||
syncHandledDataArray: [],
|
||||
// syncLastUpdateTime: new Map<string, string>(),
|
||||
scoreSetting: {
|
||||
starFull: '⭐',
|
||||
starEmpty: '☆',
|
||||
displayStarEmpty: false,
|
||||
maxStar: 5,
|
||||
},
|
||||
searchDefaultType: SupportType.all,
|
||||
|
||||
}
|
||||
|
||||
|
||||