Compare commits
298 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 812fc17c5a | |||
|
|
e8a0d8a00c | ||
|
|
318aabb21b | ||
| a8094d7575 | |||
|
|
7ba1a7be0c | ||
|
|
4e8d3f1318 | ||
|
|
c375512903 | ||
|
|
99d4170626 | ||
|
|
297ccd33cf | ||
|
|
a0eccf7370 | ||
| 572907719b | |||
| ffc93a4a13 | |||
| 08749116f3 | |||
| 266cfb3901 | |||
| 7e57846f32 | |||
| 16b9ff581d | |||
| dd1648c20a | |||
| df4c4956f1 | |||
| c09f96d3b8 | |||
| a7b81bd189 | |||
| 9403fef320 | |||
| 001cb5dc3e | |||
| 711744e065 | |||
| 836c9c61b3 | |||
| f0b73c7d8b | |||
| 8556de0501 | |||
| 6481c69d81 | |||
| 29322e0869 | |||
| 431c1f2564 | |||
| 89f43432d2 | |||
| 20b6daf10e | |||
| 208e0d2061 | |||
| 449b96cbd1 | |||
| ee514a8c95 | |||
| 161741b4af | |||
| 382e7c87dd | |||
| 671b28f91a | |||
| 0aa0c15cc5 | |||
| 9fe0d1bfc9 | |||
| ea700e481e | |||
| dc225f30f1 | |||
| a120e450e9 | |||
| c866c8be4c | |||
|
|
132e47f2b2 | ||
|
|
eeedf23e7c | ||
|
|
8f2c5f2117 | ||
|
|
8437aee2e1 | ||
| 3ff2b8f4db | |||
| 8f3bbe99f1 | |||
| 5252ce536c | |||
| d98a24545e | |||
| 232439b64c | |||
| d0ed8cf1f3 | |||
| a5747c2f45 | |||
| 59e0f83db3 | |||
| 3df097e861 | |||
| 2ae545c439 | |||
| 3b50e801a5 | |||
| b5d8636352 | |||
| 441345ebb8 | |||
| 910dbd30d9 | |||
| e1ae4cd88c | |||
| c016bbdc46 | |||
| 290eaaa45b | |||
| 1d74714e6e | |||
| eb25c5be2b | |||
| 7480d773ea | |||
| 661e8e7e2e | |||
|
|
6f6943bb09 | ||
|
|
561e42fe73 | ||
| 5c5b1b6348 | |||
| 48d8693e5c | |||
| 4b0580bc87 | |||
| 8e12632afb | |||
| 08fb988f39 | |||
| 40c8f387c3 | |||
| cf938779dd | |||
| 663528e09b | |||
| 7505c5520e | |||
| ba3fcb896c | |||
| f7562688d8 | |||
| c6b21e96bb | |||
| c1bb8cf05a | |||
| 0db96c31f5 | |||
| 9ccb10c5d4 | |||
| 58ced6cd1f | |||
| 01276030ca | |||
| 6a0cf9dab1 | |||
| 6b047b595c | |||
| 5c3edc909e | |||
| ba5e6a8ee2 | |||
| ba0f75be2a | |||
| f2278b14d9 | |||
| 7539134b05 | |||
| b4f41bcae8 | |||
| b39e0a18a3 | |||
| 446f405a79 | |||
| 232fde720c | |||
| c2ce0c5e0d | |||
| 68b2a57b80 | |||
| 446a37e03b | |||
| 0455b379d6 | |||
| 0a64529a35 | |||
| e06f998206 | |||
| 52c0202da5 | |||
| fb25fdc08e | |||
| ae7c16430d | |||
| de439d2cdc | |||
| 264a91773d | |||
| 5d288bda14 | |||
| ba0014a769 | |||
| f0c1421f5d | |||
| 1b5b9bb0b3 | |||
| 96fe6d6771 | |||
| 7bd4b6b96f | |||
| 5c05bf08a4 | |||
|
|
5dd02b1433 | ||
| 46d61d3e84 | |||
| 058afa8ebf | |||
| e3fecf03c4 | |||
| 7395da937c | |||
| 37266a3772 | |||
| ccabb3e29d | |||
| 4eabfea419 | |||
| 414f078d55 | |||
| d02c54b0c9 | |||
| 6103263c77 | |||
| 91b44beae2 | |||
| 405ae66da8 | |||
| 331ff38cd9 | |||
| 4bf64965bb | |||
| 0dd68ff8cb | |||
| 230733aa49 | |||
| 5c345efa1d | |||
| 21eea367cf | |||
| 9dee83752e | |||
| 938d7f6658 | |||
| 01a386dd6b | |||
| a97b6a7364 | |||
|
|
bcef28c822 | ||
| 44697ac05a | |||
| 198cffaada | |||
| 3def97db92 | |||
| 881f9f36f6 | |||
| 6c52606417 | |||
| 240f71f635 | |||
| 3e22d97e52 | |||
| ba0f29ca20 | |||
| ace218402c | |||
| 32fa165eb8 | |||
| 1119b105ba | |||
| fa29664757 | |||
| 1d17a0afb4 | |||
| 61860de3cd | |||
| d667b4b2a8 | |||
| cb9ffb4925 | |||
| 9d45746dac | |||
| ab86b3450c | |||
| 814ebaad59 | |||
| c1bf659deb | |||
| 13a3a15763 | |||
| 2750f29091 | |||
| 8fbcf118a0 | |||
| 5c9b37e9e6 | |||
| 1d3e30637a | |||
| 980fae30ed | |||
| e19fbc648c | |||
| 29db644ac1 | |||
| a99e34c367 | |||
| ec544b12d2 | |||
| 2b3c310f4c | |||
| afecbcdcd0 | |||
| a00cdc59ed | |||
| 7471edea0f | |||
| f83a0b4c8e | |||
| c9dd998d64 | |||
| 022b1e347f | |||
| 508e4c9303 | |||
| 3b7a2fb3a1 | |||
| c49750b848 | |||
| 037b1f4dbc | |||
| ff37584d63 | |||
| 92e30cf97d | |||
| 689a43cf16 | |||
| 36b35db78d | |||
| 594cd3a40b | |||
| 2a10100ed0 | |||
| 076883aada | |||
| b753f1f244 | |||
| d88a004ed6 | |||
| b3b9ab2c44 | |||
| a455baeb41 | |||
| 33e2b76c9f | |||
| 459eca5d61 | |||
| 86345cdf85 | |||
| cee6a89bd2 | |||
| 39cc5aeb42 | |||
| c0d7cf5972 | |||
| 1190dafbd5 | |||
| 23f145f0b0 | |||
| 1adaecfaeb | |||
| eebe141ef0 | |||
| c1e25c630c | |||
| c61b7c0318 | |||
| fe111276e9 | |||
| 80873784fc | |||
| 01a066f393 | |||
| 0a39541b02 | |||
| ba5b9f2550 | |||
| 99eb83d4b5 | |||
| 23daffa699 | |||
| 7417862eb1 | |||
| cbdefbd049 | |||
| c540932c16 | |||
| 8aec0b7172 | |||
| 5e5c942cce | |||
| 4fd535aea9 | |||
| 2c62b5b44a | |||
| f522bf4a6d | |||
| 1a98def0d5 | |||
| 556788ee75 | |||
| d212be5a75 | |||
| 1f30482542 | |||
| 53ca2ec446 | |||
| f8d453abb2 | |||
| 9507f7fdf2 | |||
| d79f321179 | |||
| b6268635b6 | |||
| 03a0220318 | |||
| 9e633823e4 | |||
| cd9c300cb7 | |||
| 16aacc680b | |||
| 8316dc319c | |||
| a6ba7545a0 | |||
| a3ffdf7411 | |||
| fe7a3e13f0 | |||
| ea80c758ff | |||
| 95147b3ee7 | |||
| 62d140d380 | |||
| 4e9e28c55a | |||
| 8eb87e85b0 | |||
| 44bc498994 | |||
| a10dfe32b7 | |||
| 9278a334c1 | |||
| bb212864c8 | |||
| a8487a6b40 | |||
| c0f4b89f17 | |||
| 06be454d0e | |||
| 3525b1b402 | |||
| 6fd21b7c97 | |||
| b326e1e4e1 | |||
| 92ea02f251 | |||
| 1d4bee6281 | |||
| ecffed6441 | |||
| 8701547f79 | |||
| a97688481d | |||
| f651a851c9 | |||
| 49be403b23 | |||
| 781b2aa1ca | |||
| 0fb3be63f4 | |||
| 61e42418d1 | |||
| 28376fc2a8 | |||
| 1208b84f9c | |||
| d992b297c4 | |||
| fa45c48c4e | |||
| a0e7b70430 | |||
| f207f0fa1a | |||
| ee8a156011 | |||
| 93bae0d62d | |||
| 4fc827bafc | |||
| 5d4828a214 | |||
| 71e92a00f0 | |||
| c4cf7c01ad | |||
| 62bb723b53 | |||
| f87ca2db20 | |||
| 30f98bfeba | |||
| a8acb02e0a | |||
| 6f7118f686 | |||
| 74ab20fc95 | |||
| bf963ec126 | |||
| a1d818af2f | |||
| 38c52f1c20 | |||
| b8a2defbe6 | |||
| 8ceb93ec7f | |||
| 7c989cf78f | |||
| f43f8f1ef2 | |||
| a176ccecb8 | |||
| e4c79a7007 | |||
| 6bfd9188e5 | |||
| c57f5f50cc | |||
| 1762a29eab | |||
| 824296a8a7 | |||
|
|
3440bf266e | ||
| ea1845d9cf | |||
| 7ebf875b40 | |||
| ee2dead393 | |||
| 382d79ec73 | |||
| de97aacf9a |
51
.github/ISSUE_TEMPLATE/异常反馈-bug-report.md
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
---
|
||||
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
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
name: 新功能建议/Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: "[Feature]:"
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
|
||||
71
.github/workflows/pages.yml
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
# 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
Normal file
@ -0,0 +1,97 @@
|
||||
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,3 +20,5 @@ data.json
|
||||
|
||||
# Exclude macOS Finder (System Explorer) View States
|
||||
.DS_Store
|
||||
doc/.vitepress/dist
|
||||
doc/.vitepress/cache
|
||||
|
||||
674
License
Normal file
@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
143
README.en.md
Normal file
@ -0,0 +1,143 @@
|
||||
# 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)
|
||||
204
README.md
@ -1,24 +1,180 @@
|
||||
# Obsidian Douban Plugin
|
||||

|
||||
|
||||
Import Movies, Books, Music Data from Douban in [Obsidian](https://obsidian.md/)
|
||||
|
||||
在[Obsidian](https://obsidian.md/)使用并导入豆瓣中的电影/音乐/以及书籍等, 评分/发布日期/演员表等信息
|
||||
- [Bugs, Issues, & Feature Requests](https://github.com/Wanxp/obsidian-douban/issues)
|
||||
- [Development Roadmap](https://github.com/users/Wanxp/projects/1)
|
||||
|
||||
## How to use
|
||||
### Movie
|
||||
- Search Movie By Input Text/通过输入文本搜索
|
||||

|
||||
|
||||
- Search Movie By File Name/通过文件名搜索
|
||||

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

|
||||
|
||||
|
||||
- Setting Example1/设置案例1
|
||||

|
||||
# 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”,选择搜索并使用
|
||||
- 搜索数据并创建笔记
|
||||
- 通过当前文件名搜索
|
||||
- 通过输入文本搜索
|
||||

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

|
||||
## 设置
|
||||
- 设置豆瓣账号(可选,可使用少部分功能)
|
||||
- 设置导入模板(可选,不设置的情况下使用默认模板)
|
||||
- 设置导入路径(可选,不设置的情况下使用默认路径)
|
||||
|
||||
|
||||
## 支持的字段
|
||||
(若有缺少想导入的字段, 欢迎提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: 出品方 | | | | |
|
||||
|
||||
- 注: myTags, myRating, myRatingStar:⭐ , myState, myComment, myCollectionDate 参数均为在插件中登录后可用
|
||||
|
||||
|
||||
## 如何安装
|
||||
### 从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. 进入你的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. 享受开发吧
|
||||
#### 文档
|
||||
```shell
|
||||
npm run docs:dev
|
||||
```
|
||||
## 支持开发者
|
||||
如果觉得插件对你有帮助,欢迎请我喝杯咖啡,让我有更多的动力去维护和更新插件
|
||||
|
||||

|
||||
|
||||
## 交流社群
|
||||
<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))
|
||||
|
||||
11
ai/other/ACTION_提示词.md
Normal file
@ -0,0 +1,11 @@
|
||||
编写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
Normal file
@ -0,0 +1,15 @@
|
||||
# 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/
|
||||
56
doc/.vitepress/config.mts
Normal file
@ -0,0 +1,56 @@
|
||||
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'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
15
doc/.vitepress/theme/custom.css
Normal file
@ -0,0 +1,15 @@
|
||||
: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);*/
|
||||
}
|
||||
|
||||
5
doc/.vitepress/theme/index.js
Normal file
@ -0,0 +1,5 @@
|
||||
import DefaultTheme from 'vitepress/theme'
|
||||
import './custom.css'
|
||||
|
||||
|
||||
export default DefaultTheme
|
||||
16
doc/10_install.md
Normal file
@ -0,0 +1,16 @@
|
||||
---
|
||||
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插件中心开启当前插件功能
|
||||
6
doc/20_howtouse.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
title: 如何使用
|
||||
layout: default
|
||||
nav_order: 300
|
||||
has_children: true
|
||||
---
|
||||
17
doc/20_howtouse_10_detail.md
Normal file
@ -0,0 +1,17 @@
|
||||
---
|
||||
title: 使用说明
|
||||
nav_order: 300
|
||||
parent: 如何使用
|
||||
---
|
||||
# 如何使用
|
||||
# 搜索
|
||||
使用方式: 输入<kbd>Ctrl</kbd> + <kbd>P</kbd>,输入“豆瓣”或“Douban”,选择搜索并使用
|
||||
- 搜索数据并创建笔记
|
||||
- 通过当前文件名搜索
|
||||
- 通过输入文本搜索
|
||||

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

|
||||
11
doc/20_howtouse_20_setting.md
Normal file
@ -0,0 +1,11 @@
|
||||
---
|
||||
title: 设置
|
||||
nav_order: 350
|
||||
parent: 如何使用
|
||||
---
|
||||
|
||||
# 设置
|
||||
- 设置豆瓣账号(可选,可使用少部分功能)
|
||||
- 设置导入模板(可选,不设置的情况下使用默认模板)
|
||||
- 设置导入路径(可选,不设置的情况下使用默认路径)
|
||||
|
||||
32
doc/20_howtouse_25_setting_login_douban_cookie.md
Normal file
@ -0,0 +1,32 @@
|
||||
---
|
||||
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. 点击确认
|
||||
|
||||
21
doc/20_howtouse_30_picturebed.md
Normal file
@ -0,0 +1,21 @@
|
||||
---
|
||||
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软件设置中的`使用内置剪贴板上传`选项
|
||||
6
doc/30_function.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
title: 功能
|
||||
layout: default
|
||||
nav_order: 400
|
||||
has_children: true
|
||||
---
|
||||
14
doc/30_function_10.md
Normal file
@ -0,0 +1,14 @@
|
||||
---
|
||||
title: 基础功能
|
||||
nav_order: 400
|
||||
parent: 功能
|
||||
---
|
||||
# 功能
|
||||
- ☑️ 导入电影、电视剧、书籍、音乐、游戏、日记
|
||||
- ☑️ 同步个人听过/看过的电影、电视剧、书籍、音乐、游戏
|
||||
- ☑️ 导入个人的评论,评论时间,阅读状态,个人评分
|
||||
- ☑️ 支持保存封面至本地/图床
|
||||
- ⬜ 支持图床自定义
|
||||
- ☑️ 支持自定义参数
|
||||
- ☑️ 支持移动端导入
|
||||
- ⬜ 支持使用AI大模型ChatGPT、Deepseek、Ollama分析导入
|
||||
42
doc/30_function_20_support_variables.md
Normal file
@ -0,0 +1,42 @@
|
||||
---
|
||||
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: 出品方 | | | | |
|
||||
6
doc/60_special_use.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
title: 特殊效果
|
||||
layout: default
|
||||
nav_order: 450
|
||||
has_children: true
|
||||
---
|
||||
12
doc/60_special_use_10.md
Normal file
@ -0,0 +1,12 @@
|
||||
---
|
||||
title: 效果介绍
|
||||
nav_order: 450
|
||||
parent: 特殊效果
|
||||
---
|
||||
|
||||
# 效果
|
||||
1. 结合Timeline插件 __构建个人观影时间线__,请参照[结合timeline插件实现时间线效果](Obsidian-Douban-TimeLine)
|
||||

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

|
||||
21
doc/70_develop.md
Normal file
@ -0,0 +1,21 @@
|
||||
---
|
||||
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. 享受开发吧
|
||||
|
||||
7
doc/80_others.md
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
title: 其它
|
||||
layout: default
|
||||
nav_order: 750
|
||||
has_children: true
|
||||
---
|
||||
|
||||
17
doc/80_others_20_effect.md
Normal file
@ -0,0 +1,17 @@
|
||||
---
|
||||
title: 数据影响
|
||||
nav_order: 800
|
||||
parent: 其它
|
||||
---
|
||||
|
||||
# 数据影响
|
||||
注意: 除了在同步书影音数据时勾选 `替换同名文档` 有可能会修改同路径同文档名的笔记外,其余操作均不会修改已有笔记。
|
||||
|
||||
| 操作 | 条件 | 影响 | 举例 |
|
||||
|---------|------------------|---------------------------|-----------------------------------------------------------------------------------------------|
|
||||
| 导入书影音数据 | 默认条件 | 新建一条名为所选条目的笔记 | 如搜索蝙蝠侠并选中导入,则会创建笔记 《蝙蝠侠》 |
|
||||
| 导入书影音数据 | 已有同名笔记 | 无任何影响,提示已经存在同名笔记,不会修改已有笔记 | 如搜索蝙蝠侠并选中导入,但因存在同路径同名称笔记,则会不会创建笔记 |
|
||||
| 导入书影音数据 | 配置 `笔记名称`值包含路径 | 若没有此路径则会创建对应文件名 | 如搜索蝙蝠侠并选中导入,配置`笔记名称`值为`/data/{{type}}/{{title}}`,则会创建文件夹`data/电影` |
|
||||
| 导入书影音数据 | 配置 `保存图片附件`值为勾选 | 则会在`附件存放位置`指定位置保存封面图片 | 如搜索蝙蝠侠并选中导入,配置`附件存放位置`值为`assets`,则会在`assets`文件夹中保存封面文件`p462657443.jpg` |
|
||||
| 同步书影音数据 | 以上所有 | 以上所有 | 以上所有 |
|
||||
| 同步书影音数据 | `替换同名文档`值为勾选 | 已经存在 **同路径同文档名** ,直接覆盖 | 如已经存在在`data/Movie/蝙蝠侠.md`,配置`笔记名称`值为`/data/{{type}}/{{title}}`, 同步书影音记录时勾选 `替换同名文档`, 则`data/Movie/蝙蝠侠.md`会被替换成最新 |
|
||||
8
doc/80_others_30_thanks.md
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
title: 鸣谢
|
||||
nav_order: 810
|
||||
parent: 其它
|
||||
---
|
||||
# 鸣谢
|
||||
## IDE支持
|
||||
[<image src="img/jb_beam.svg"> </image>](https://www.jetbrains.com/?from=obsidian-douban)
|
||||
12
doc/80_others_disclaimer.md
Normal file
@ -0,0 +1,12 @@
|
||||
---
|
||||
title: 免责声明
|
||||
nav_order: 820
|
||||
parent: 其它
|
||||
---
|
||||
|
||||
# 免责声明
|
||||
1. 建议使用本插件前,一定要至少有一种方式备份你的数据,以防万一。
|
||||
2. 本程序没有爬取任何书影音等内容,只供技术研究使用。没有侵犯书影音作者版权和豆瓣官方利益。如有任何侵权行为,请联系我删除。
|
||||
3. 本程序仅供学习交流使用。
|
||||
4. 虽然极力避免,但还是有可能纰漏,所以因使用插件造成的损失,由使用者本人承担。不同操作会有何种影响,请参照<a href="#impact">影响</a>
|
||||
5. 使用或修改本插件,即视为同意上述免责声明。
|
||||
9
doc/97_issues.md
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
title: 反馈与建议
|
||||
nav_order: 950
|
||||
---
|
||||
|
||||
# 反馈与建议
|
||||
如果你有任何问题或建议,欢迎在提交[Issues](https://github.com/Wanxp/obsidian-douban/issues)
|
||||
|
||||
|
||||
17
doc/99_support.md
Normal file
@ -0,0 +1,17 @@
|
||||
---
|
||||
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
Normal file
@ -0,0 +1,10 @@
|
||||
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'
|
||||
|
||||
87
doc/Gemfile.lock
Normal file
@ -0,0 +1,87 @@
|
||||
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
Normal file
@ -0,0 +1,21 @@
|
||||
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.
|
||||
127
doc/Obsidian-Douban-BlueTopaz.md
Normal file
@ -0,0 +1,127 @@
|
||||
---
|
||||
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}}
|
||||
````
|
||||
|
||||
## 电影、电视剧、音乐、游戏
|
||||
请参照书籍模板
|
||||
|
||||
## 更多
|
||||
此效果来自热心用户的分享,感谢
|
||||
3
doc/Obsidian-Douban-DataView-Jump.md
Normal file
@ -0,0 +1,3 @@
|
||||
## 书架效果
|
||||
点击以下链接跳转至少数派
|
||||
[使用Obsidian打造个人图书馆!](https://sspai.com/post/85574)
|
||||
69
doc/Obsidian-Douban-DataView.md
Normal file
@ -0,0 +1,69 @@
|
||||
## 效果如下
|
||||

|
||||
## 适用人群
|
||||
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)
|
||||
93
doc/Obsidian-Douban-TimeLine.md
Normal file
@ -0,0 +1,93 @@
|
||||
---
|
||||
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)
|
||||
10
doc/_config.yml
Normal file
@ -0,0 +1,10 @@
|
||||
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'
|
||||
BIN
doc/background.png
Normal file
|
After Width: | Height: | Size: 235 KiB |
1
doc/img/jb_beam.svg
Normal file
@ -0,0 +1 @@
|
||||
<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>
|
||||
|
After Width: | Height: | Size: 3.0 KiB |
1
doc/img/obsidian-douban-discord-qr_code.svg
Normal file
|
After Width: | Height: | Size: 117 KiB |
BIN
doc/img/obsidian-douban-discord.png
Normal file
|
After Width: | Height: | Size: 9.8 KiB |
BIN
doc/img/obsidian-douban-qq-2.png
Normal file
|
After Width: | Height: | Size: 40 KiB |
1
doc/img/obsidian-douban-qq-qr_code.svg
Normal file
|
After Width: | Height: | Size: 356 KiB |
BIN
doc/img/obsidian-douban-setting-cookie.png
Normal file
|
After Width: | Height: | Size: 492 KiB |
BIN
doc/img/obsidian-douban-time-preview-example.gif
Normal file
|
After Width: | Height: | Size: 3.2 MiB |
BIN
doc/img/ps/wechat.psd
Normal file
BIN
doc/img/search_and_create_note.gif
Normal file
|
After Width: | Height: | Size: 2.6 MiB |
BIN
doc/img/support_pay_2.png
Normal file
|
After Width: | Height: | Size: 494 KiB |
BIN
doc/img/sync_data_from_douban.gif
Normal file
|
After Width: | Height: | Size: 2.8 MiB |
BIN
doc/img/wanxp-logo.png
Normal file
|
After Width: | Height: | Size: 27 KiB |
BIN
doc/img/wechat_group.png
Normal file
|
After Width: | Height: | Size: 57 KiB |
34
doc/index.md
Normal file
@ -0,0 +1,34 @@
|
||||
---
|
||||
# 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
|
||||
---
|
||||
|
||||
BIN
doc/obsidian-douban-logo.png
Normal file
|
After Width: | Height: | Size: 780 KiB |
|
Before Width: | Height: | Size: 594 KiB |
|
Before Width: | Height: | Size: 2.4 MiB |
|
Before Width: | Height: | Size: 1.6 MiB |
|
Before Width: | Height: | Size: 1.4 MiB |
@ -1,54 +0,0 @@
|
||||
import { i18nHelper } from "lang/helper";
|
||||
import { type } from "os";
|
||||
|
||||
export interface DoubanPluginSettings {
|
||||
movieTemplate:string,
|
||||
dateFormat: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:
|
||||
"---\n" +
|
||||
"doubanId: {{id}}\n" +
|
||||
"title: {{title}}\n" +
|
||||
"type: {{type}}\n" +
|
||||
"score: {{score}}\n" +
|
||||
"datePublished: {{datePublished}}\n" +
|
||||
"director: {{director}}\n" +
|
||||
"actor: {{actor}}\n" +
|
||||
"author: {{author}}\n" +
|
||||
"url: {{url}}\n" +
|
||||
"image: {{image}}\n" +
|
||||
"---\n",
|
||||
searchUrl: 'https://www.douban.com/search?q=',
|
||||
searchHeaders: JSON.stringify(doubanHeadrs),
|
||||
dateFormat: "yyyy_MM_DD",
|
||||
arraySpilt: ", ",
|
||||
personNameMode: PersonNameMode.CH_NAME
|
||||
|
||||
}
|
||||
|
||||
export const personNameModeRecords: {[key in PersonNameMode]: string} = {
|
||||
[PersonNameMode.CH_NAME]: i18nHelper.getMessage("Chinese Name"),
|
||||
[PersonNameMode.EN_NAME]: i18nHelper.getMessage("English Name"),
|
||||
[PersonNameMode.CH_EN_NAME]: i18nHelper.getMessage("Chinese And English Name"),
|
||||
}
|
||||
|
||||
|
||||
@ -1,187 +0,0 @@
|
||||
import { App, PluginSettingTab, Setting } from "obsidian";
|
||||
import { DEFAULT_SETTINGS, PersonNameMode, personNameModeRecords } from "./Douban";
|
||||
|
||||
import DoubanPlugin from "main";
|
||||
import { i18nHelper } from "lang/helper";
|
||||
import { log } from "utils/Logutil";
|
||||
|
||||
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: "Obsidian Douban" });
|
||||
|
||||
new Setting(containerEl).setName(i18nHelper.getMessage('douban search url'))
|
||||
.then((setting) => {
|
||||
setting.addText((textField) => {
|
||||
setting.descEl.appendChild(
|
||||
createFragment((frag) => {
|
||||
frag.appendText(i18nHelper.getMessage('douban search url desc 1'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('douban search url desc 2'));
|
||||
frag.createEl(
|
||||
'a',
|
||||
{
|
||||
text: i18nHelper.getMessage('Douban'),
|
||||
href: 'https://www.douban.com',
|
||||
},
|
||||
(a) => {
|
||||
a.setAttr('target', '_blank');
|
||||
}
|
||||
);
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('douban search url desc 3'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('douban search url desc 4'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('douban search url desc 5'));
|
||||
frag.createEl('br');
|
||||
})
|
||||
);
|
||||
textField.inputEl.addClass("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("movie content template")).then((setting) => {
|
||||
setting.addTextArea((textarea) => {
|
||||
setting.descEl.appendChild(
|
||||
createFragment((frag) => {
|
||||
frag.appendText(i18nHelper.getMessage('movie content template desc 1'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('movie content template desc 2'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('movie content template desc 3'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('movie content template desc 4'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('movie content template desc 5'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('movie content template desc 6'));
|
||||
frag.createEl('br');
|
||||
})
|
||||
);
|
||||
textarea.inputEl.addClass("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("Person Name Language Mode")).then((setting) => {
|
||||
setting.addDropdown((dropdwon) => {
|
||||
setting.descEl.appendChild(
|
||||
createFragment((frag) => {
|
||||
frag.appendText(i18nHelper.getMessage('options:'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('Chinese Name mode, only show Chinese name'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('English Name mode, only show English name'));
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('Chinese English Name mode, show Chinese English name both'));
|
||||
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('Date format')).then((setting) => {
|
||||
setting.addMomentFormat((mf) => {
|
||||
setting.descEl.appendChild(
|
||||
createFragment((frag) => {
|
||||
frag.appendText(
|
||||
i18nHelper.getMessage('This format will be used when available template variables contain date.')
|
||||
);
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('For more syntax, refer to') + ' ');
|
||||
frag.createEl(
|
||||
'a',
|
||||
{
|
||||
text: i18nHelper.getMessage('format reference'),
|
||||
href: 'https://momentjs.com/docs/#/displaying/format/',
|
||||
},
|
||||
(a) => {
|
||||
a.setAttr('target', '_blank');
|
||||
}
|
||||
);
|
||||
frag.createEl('br');
|
||||
frag.appendText(i18nHelper.getMessage('Your current syntax looks like this') + ': ');
|
||||
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("Array Spilt String"))
|
||||
.setDesc(i18nHelper.getMessage(`string to join between array type, such as author, actor`))
|
||||
.addText((textField) => {
|
||||
textField.setPlaceholder(DEFAULT_SETTINGS.arraySpilt)
|
||||
.setValue(this.plugin.settings.arraySpilt)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.arraySpilt = value;
|
||||
await this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
// new Setting(containerEl)
|
||||
// .setName("Douban Request Headers")
|
||||
// .setDesc(`if can not fetch data from douban,\n
|
||||
// please go to douban.com\n and copy headers to this text area `)
|
||||
// .addTextArea((textField) => {
|
||||
// textField
|
||||
// .setPlaceholder(DEFAULT_SETTINGS.searchHeaders)
|
||||
// .setValue(this.plugin.settings.searchHeaders)
|
||||
// .onChange(async (value) => {
|
||||
// this.plugin.settings.searchHeaders = value;
|
||||
// await this.plugin.saveSettings();
|
||||
// });
|
||||
// });
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
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;
|
||||
};
|
||||
};
|
||||
@ -1,93 +0,0 @@
|
||||
import { DoubanPluginSettings, PersonNameMode } from "douban/Douban";
|
||||
import cheerio, { CheerioAPI } from "cheerio";
|
||||
import { get, readStream } from "tiny-network";
|
||||
|
||||
import DoubanPlugin from "main";
|
||||
import DoubanSubject from "douban/model/DoubanSubject";
|
||||
import DoubanSubjectLoadHandler from "./DoubanSubjectLoadHandler";
|
||||
import { Editor } from "obsidian";
|
||||
import HttpUtil from "utils/HttpUtil";
|
||||
import { json } from "stream/consumers";
|
||||
import { log } from "utils/Logutil";
|
||||
|
||||
export default abstract class DoubanAbstractLoadHandler<T extends DoubanSubject> implements DoubanSubjectLoadHandler<T> {
|
||||
|
||||
|
||||
public doubanPlugin:DoubanPlugin;
|
||||
|
||||
constructor(doubanPlugin:DoubanPlugin) {
|
||||
this.doubanPlugin = doubanPlugin;
|
||||
}
|
||||
|
||||
abstract parseText(extract: T, settings:DoubanPluginSettings): string;
|
||||
|
||||
abstract support(extract: DoubanSubject): boolean;
|
||||
|
||||
handle(url:string, editor:Editor):void {
|
||||
Promise.resolve().then(() => get(url + "/", {headers: JSON.parse(this.doubanPlugin.settings.searchHeaders)}))
|
||||
.then(readStream)
|
||||
.then(cheerio.load)
|
||||
.then(this.parseSubjectFromHtml)
|
||||
.then(content => this.toEditor(editor, content))
|
||||
// .then(content => content ? editor.replaceSelection(content) : content)
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
|
||||
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 "";
|
||||
}
|
||||
var resultName = "";
|
||||
switch(settings.personNameMode) {
|
||||
case PersonNameMode.CH_NAME:
|
||||
var regValue = /[\u4e00-\u9fa5]{2,20}/g.exec(name);
|
||||
resultName = regValue?regValue[0]:name;
|
||||
break;
|
||||
case PersonNameMode.EN_NAME:
|
||||
var 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
|
||||
{
|
||||
var 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
|
||||
{
|
||||
var 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;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,64 +0,0 @@
|
||||
import { App, Editor } from "obsidian";
|
||||
|
||||
import DoubanMovieLoadHandler from "./DoubanMovieLoadHandler";
|
||||
import DoubanOtherLoadHandler from "./DoubanOtherLoadHandler";
|
||||
import DoubanPlugin from "main";
|
||||
import { DoubanPluginSettings } from "douban/Douban";
|
||||
import DoubanSubject from "../model/DoubanSubject";
|
||||
import DoubanSubjectLoadHandler from "./DoubanSubjectLoadHandler";
|
||||
|
||||
export class DoubanEtractHandler {
|
||||
|
||||
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),
|
||||
this._doubanSubjectHandlerDefault];
|
||||
|
||||
}
|
||||
|
||||
public handle(searchExtract:DoubanSubject, editor: Editor):void{
|
||||
if(!searchExtract) {
|
||||
return;
|
||||
}
|
||||
var doubanSubjectHandlers:DoubanSubjectLoadHandler<DoubanSubject>[] = this._doubanSubjectHandlers
|
||||
.filter(h => h.support(searchExtract));
|
||||
if(doubanSubjectHandlers && doubanSubjectHandlers.length > 0) {
|
||||
var result = doubanSubjectHandlers.map(h => h.handle(searchExtract.url, editor))
|
||||
if(result && result.length > 0) {
|
||||
return result[0];
|
||||
}
|
||||
}else {
|
||||
this._doubanSubjectHandlerDefault.handle(searchExtract.url, editor);
|
||||
}
|
||||
}
|
||||
|
||||
public parseText(extract:DoubanSubject, settings:DoubanPluginSettings):string {
|
||||
if(!settings) {
|
||||
return "";
|
||||
}
|
||||
var doubanSubjectHandlers:DoubanSubjectLoadHandler<DoubanSubject>[] = this._doubanSubjectHandlers
|
||||
.filter(h => h.support(extract));
|
||||
if(doubanSubjectHandlers && doubanSubjectHandlers.length > 0) {
|
||||
var result = doubanSubjectHandlers.map(h => h.parseText(extract, settings));
|
||||
if(result && result.length > 0) {
|
||||
return result[0];
|
||||
}else {
|
||||
return "";
|
||||
}
|
||||
}else {
|
||||
return this._doubanSubjectHandlerDefault.parseText(extract, settings);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,70 +0,0 @@
|
||||
import { Editor, moment, renderResults } from "obsidian";
|
||||
import cheerio, { CheerioAPI } from 'cheerio';
|
||||
import { get, readStream } from "tiny-network";
|
||||
|
||||
import DoubanAbstractLoadHandler from "./DoubanAbstractLoadHandler";
|
||||
import DoubanMovieSubject from "douban/model/DoubanMovieSubject";
|
||||
import DoubanPlugin from "main";
|
||||
import { DoubanPluginSettings } from "douban/Douban";
|
||||
import DoubanSubject from "douban/model/DoubanSubject";
|
||||
import SchemaOrg from "utils/SchemaOrg";
|
||||
import { log } from "utils/Logutil";
|
||||
|
||||
export default class DoubanMovieLoadHandler extends DoubanAbstractLoadHandler<DoubanMovieSubject> {
|
||||
|
||||
parseText(extract: DoubanMovieSubject, settings:DoubanPluginSettings): string {
|
||||
return settings.movieTemplate ? settings.movieTemplate.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("{{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) : "")
|
||||
.replaceAll("{{datePublished}}", extract.datePublished ? moment(extract.datePublished).format(settings.dateFormat) : "")
|
||||
.replaceAll("{{url}}", extract.url ? extract.url : "")
|
||||
.replaceAll("{{score}}", extract.aggregateRating && extract.aggregateRating.ratingValue ? extract.aggregateRating.ratingValue + "" : "")
|
||||
: undefined; }
|
||||
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 => {
|
||||
var item = data(i).text();
|
||||
item = super.html_decode(item);
|
||||
var obj = JSON.parse(item.replace(/[\r\n\s+]/g, ''));
|
||||
var idPattern = /(\d){5,10}/g;
|
||||
var id = idPattern.exec(obj.url);
|
||||
const result:DoubanMovieSubject = {
|
||||
id: id?id[0]:'',
|
||||
type: 'Movie',
|
||||
title: obj.name,
|
||||
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
|
||||
}
|
||||
return result;
|
||||
})[0];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1,29 +0,0 @@
|
||||
import { Editor, Notice } from "obsidian";
|
||||
|
||||
import { CheerioAPI } from "cheerio";
|
||||
import DoubanAbstractLoadHandler from "./DoubanAbstractLoadHandler";
|
||||
import { DoubanPluginSettings } from "douban/Douban";
|
||||
import DoubanSubject from "douban/model/DoubanSubject";
|
||||
import { i18nHelper } from "lang/helper";
|
||||
import { log } from "utils/Logutil";
|
||||
|
||||
/**
|
||||
* 默认的处理器
|
||||
*/
|
||||
export default class DoubanOtherLoadHandler extends DoubanAbstractLoadHandler<DoubanSubject> {
|
||||
parseText(extract: DoubanSubject, settings:DoubanPluginSettings): string {
|
||||
log.warn(i18nHelper.getMessage('current version not support type'));
|
||||
return "";
|
||||
}
|
||||
support(extract: DoubanSubject): boolean {
|
||||
return false;
|
||||
}
|
||||
parseSubjectFromHtml(data: CheerioAPI): DoubanSubject {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
import { DoubanPluginSettings } from "douban/Douban";
|
||||
import DoubanSubject from "douban/model/DoubanSubject";
|
||||
import { Editor } from "obsidian";
|
||||
|
||||
export default interface DoubanSubjectLoadHandler<T extends DoubanSubject> {
|
||||
|
||||
parseText(extract: T, settings:DoubanPluginSettings): string;
|
||||
|
||||
support(extract:DoubanSubject):boolean;
|
||||
|
||||
handle(url:string, editor: Editor):void;
|
||||
|
||||
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
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;
|
||||
datePublished:Date;
|
||||
image:string
|
||||
}
|
||||
@ -1,7 +0,0 @@
|
||||
export default class DoubanExtract {
|
||||
id: string;
|
||||
type: string;
|
||||
title: string;
|
||||
desc: string;
|
||||
url: string;
|
||||
}
|
||||
@ -1,52 +0,0 @@
|
||||
import { App, Editor, FuzzySuggestModal } from "obsidian";
|
||||
|
||||
import DoubanPlugin from "main";
|
||||
import DoubanSearchResultSubject from "douban/model/DoubanSearchResultSubject";
|
||||
import { log } from "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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,65 +0,0 @@
|
||||
import { App, Editor, Modal, TextComponent } from "obsidian";
|
||||
|
||||
import DoubanPlugin from "../../main";
|
||||
import { i18nHelper } from "lang/helper";
|
||||
import { log } from "utils/Logutil";
|
||||
|
||||
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("h2", { text: i18nHelper.getMessage('Enter Search Term:') });
|
||||
|
||||
const inputs = contentEl.createDiv("inputs");
|
||||
const searchInput = new TextComponent(inputs).onChange((searchTerm) => {
|
||||
this.searchTerm = searchTerm;
|
||||
});
|
||||
searchInput.inputEl.addClass("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('Search'),
|
||||
cls: "mod-cta",
|
||||
attr: {
|
||||
autofocus: true,
|
||||
},
|
||||
});
|
||||
searchButton.addClass("search_button");
|
||||
|
||||
searchButton.addEventListener("click", this.close.bind(this));
|
||||
const cancelButton = controls.createEl("button", { text: i18nHelper.getMessage('Cancel') });
|
||||
cancelButton.addEventListener("click", this.close.bind(this));
|
||||
cancelButton.addClass("search_button");
|
||||
|
||||
}
|
||||
|
||||
|
||||
async onClose() {
|
||||
let { contentEl } = this;
|
||||
|
||||
contentEl.empty();
|
||||
if (this.searchTerm) {
|
||||
await this.plugin.search(this.searchTerm, this.editor);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
import { DoubanPluginSettings, doubanHeadrs } from 'douban/Douban';
|
||||
import { get, readStream } from 'tiny-network';
|
||||
|
||||
import DoubanSearchResultSubject from 'douban/model/DoubanSearchResultSubject';
|
||||
import SearchParserHandler from './SearchParser';
|
||||
import cheerio from 'cheerio';
|
||||
import { ensureStatusCode } from 'douban/ResponseHandle';
|
||||
import { log } from 'utils/Logutil';
|
||||
|
||||
export default class Searcher {
|
||||
static search(searchItem:string, doubanSettings:DoubanPluginSettings):Promise<DoubanSearchResultSubject[]> {
|
||||
// getData();
|
||||
// getData2();
|
||||
// return Promise.resolve();
|
||||
return Promise
|
||||
.resolve()
|
||||
.then(() => get(doubanSettings.searchUrl + searchItem, JSON.parse(doubanSettings.searchHeaders)))
|
||||
.then(ensureStatusCode(200))
|
||||
.then(readStream)
|
||||
.then(cheerio.load)
|
||||
.then(SearchParserHandler.parseSearch)
|
||||
.then(log.trace);
|
||||
};
|
||||
}
|
||||
@ -1,28 +0,0 @@
|
||||
import { CheerioAPI } from "cheerio";
|
||||
import DoubanSearchResultSubject from "douban/model/DoubanSearchResultSubject";
|
||||
|
||||
export default class SearchParserHandler {
|
||||
static parseSearch(dataHtml:CheerioAPI):DoubanSearchResultSubject[] {
|
||||
return dataHtml('.result')
|
||||
.get()
|
||||
.map((i:any) => {
|
||||
const item = dataHtml(i);
|
||||
var idPattern = /(\d){5,10}/g;
|
||||
var urlPattern = /(https%3A%2F%2F)\S+(\d){5,10}/g;
|
||||
var linkValue = item.find("div.content > div > h3 > a").attr("href");
|
||||
var ececResult = idPattern.exec(linkValue);
|
||||
var urlResult = urlPattern.exec(linkValue);
|
||||
var cast = item.find(".subject-cast").text();
|
||||
const result:DoubanSearchResultSubject = {
|
||||
id: ececResult?ececResult[0]:'',
|
||||
title: item.find("div.content > div > h3 > a").text(),
|
||||
score: item.find(".rating_nums").text(),
|
||||
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',
|
||||
};
|
||||
return result;
|
||||
})
|
||||
};
|
||||
}
|
||||
@ -1,52 +1,53 @@
|
||||
import esbuild from "esbuild";
|
||||
import process from "process";
|
||||
import builtins from 'builtin-modules'
|
||||
|
||||
const banner =
|
||||
`/*
|
||||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||||
if you want to view the source, please visit the github repository of this plugin
|
||||
*/
|
||||
`;
|
||||
|
||||
const prod = (process.argv[2] === 'production');
|
||||
|
||||
esbuild.build({
|
||||
banner: {
|
||||
js: banner,
|
||||
},
|
||||
entryPoints: ['main.ts'],
|
||||
bundle: true,
|
||||
external: [
|
||||
'obsidian',
|
||||
'electron',
|
||||
'@codemirror/autocomplete',
|
||||
'@codemirror/closebrackets',
|
||||
'@codemirror/collab',
|
||||
'@codemirror/commands',
|
||||
'@codemirror/comment',
|
||||
'@codemirror/fold',
|
||||
'@codemirror/gutter',
|
||||
'@codemirror/highlight',
|
||||
'@codemirror/history',
|
||||
'@codemirror/language',
|
||||
'@codemirror/lint',
|
||||
'@codemirror/matchbrackets',
|
||||
'@codemirror/panel',
|
||||
'@codemirror/rangeset',
|
||||
'@codemirror/rectangular-selection',
|
||||
'@codemirror/search',
|
||||
'@codemirror/state',
|
||||
'@codemirror/stream-parser',
|
||||
'@codemirror/text',
|
||||
'@codemirror/tooltip',
|
||||
'@codemirror/view',
|
||||
...builtins],
|
||||
format: 'cjs',
|
||||
watch: !prod,
|
||||
target: 'es2016',
|
||||
logLevel: "info",
|
||||
sourcemap: prod ? false : 'inline',
|
||||
treeShaking: true,
|
||||
outfile: 'main.js',
|
||||
}).catch(() => process.exit(1));
|
||||
import esbuild from "esbuild";
|
||||
import process from "process";
|
||||
import builtins from 'builtin-modules'
|
||||
|
||||
const banner =
|
||||
`/*
|
||||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||||
if you want to view the source, please visit the github repository of this plugin
|
||||
*/
|
||||
`;
|
||||
|
||||
const prod = (process.argv[2] === 'production');
|
||||
|
||||
esbuild.build({
|
||||
banner: {
|
||||
js: banner,
|
||||
},
|
||||
entryPoints: ['src/org/wanxp/main.ts'],
|
||||
bundle: true,
|
||||
external: [
|
||||
'obsidian',
|
||||
'electron',
|
||||
'@codemirror/autocomplete',
|
||||
'@codemirror/closebrackets',
|
||||
'@codemirror/collab',
|
||||
'@codemirror/commands',
|
||||
'@codemirror/comment',
|
||||
'@codemirror/fold',
|
||||
'@codemirror/gutter',
|
||||
'@codemirror/highlight',
|
||||
'@codemirror/history',
|
||||
'@codemirror/language',
|
||||
'@codemirror/lint',
|
||||
'@codemirror/matchbrackets',
|
||||
'@codemirror/panel',
|
||||
'@codemirror/rangeset',
|
||||
'@codemirror/rectangular-selection',
|
||||
'@codemirror/searcher',
|
||||
'@codemirror/state',
|
||||
'@codemirror/stream-parser',
|
||||
'@codemirror/text',
|
||||
'@codemirror/tooltip',
|
||||
'@codemirror/view',
|
||||
...builtins],
|
||||
format: 'cjs',
|
||||
watch: !prod,
|
||||
target: 'es2016',
|
||||
logLevel: "info",
|
||||
sourcemap: prod ? false : true,
|
||||
treeShaking: true,
|
||||
outfile: 'main.js',
|
||||
// minify: true
|
||||
}).catch(() => process.exit(1));
|
||||
|
||||
24
jest.config.js
Normal file
@ -0,0 +1,24 @@
|
||||
const { default: tsjPreset } = require('ts-jest/presets');
|
||||
module.exports = {
|
||||
preset: 'ts-jest',
|
||||
rootDir: './',
|
||||
transform: {
|
||||
...tsjPreset.transform
|
||||
},
|
||||
testRegex: '(/test/.*\\.(test|spec))\\.[tj]sx?$',
|
||||
moduleFileExtensions: [
|
||||
"ts",
|
||||
"tsx",
|
||||
"js",
|
||||
"jsx"
|
||||
],
|
||||
moduleNameWrapper: {
|
||||
'^@APP/(.*)$': '<rootDir>/src/douban/$1'
|
||||
},
|
||||
collectCoverageFrom: {
|
||||
"**/baseTs/upperFirst.ts",
|
||||
"**/baseTs/camelCase.ts",
|
||||
"!**/node_modules/**",
|
||||
"!**/vendor/**"
|
||||
}
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
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();
|
||||
@ -1,44 +0,0 @@
|
||||
//简体中文
|
||||
export default {
|
||||
//main.ts
|
||||
'search douban by current file name':'search douban by current file name',
|
||||
'search douban and import to current file':'search douban and import to current file',
|
||||
'Enter Search Term:':`Enter Search Term:`,
|
||||
'Search':`Search`,
|
||||
'Cancel':`Cancel`,
|
||||
//DoubanSettingTab
|
||||
'douban search url': `Douban Search Url`,
|
||||
'douban search url desc 1': `Douban search page request address. `,
|
||||
'douban search url desc 2': `First go to:`,
|
||||
'douban search url desc 3': `Don't enter anything in the search input box, just click Search,`,
|
||||
'douban search url desc 4': `The redirected web page address is the search address,`,
|
||||
'douban search url desc 5': `Just copy the web address to the current input box.`,
|
||||
|
||||
'movie content template': `Movie Content Template`,
|
||||
'movie content template desc 1': `Set markdown template for extract to be inserted.`,
|
||||
'movie content template desc 2': `Available template variables are :`,
|
||||
'movie content template desc 3': `{{id}}, {{type}}, {{title}},`,
|
||||
'movie content template desc 4': `{{score}}, {{datePublished}}, {{director}},`,
|
||||
'movie content template desc 5': `{{author}}, {{autor}}, {{desc}},`,
|
||||
'movie content template desc 6': `{{image}}, {{url}}`,
|
||||
|
||||
'Date format': `Date Format`,
|
||||
'This format will be used when available template variables contain date.':
|
||||
`This format will be used when available template variables contain date.`,
|
||||
'For more syntax, refer to': `For more syntax, refer to`,
|
||||
'Your current syntax looks like this':`Your current syntax looks like this`,
|
||||
'format reference': `format reference`,
|
||||
'Array Spilt String':`Array Spilt String`,
|
||||
'string to join between array type, such as author, actor':`string to join between array type, such as author, actor`,
|
||||
'Douban Request Headers':`Douban Request Headers`,
|
||||
'current version not support type': `This type of import is not supported temporarily, please go to github to submit issues for help`,
|
||||
'Douban': `Douban`,
|
||||
'Person Name Language Mode':'Person Name Language Mode',
|
||||
'options:':"options:",
|
||||
'Chinese Name mode, only show Chinese name':'Chinese Name mode, person name only show Chinese name',
|
||||
'English Name mode, only show English name':'English Name mode, person name only show English name',
|
||||
'Chinese English Name mode, show Chinese English name both':'Chinese English Name mode, show Chinese and English name both',
|
||||
'Chinese Name': 'Chinese Name',
|
||||
'English Name': 'English Name',
|
||||
'Chinese And English Name': 'Chinese And English Name',
|
||||
}
|
||||
@ -1,51 +0,0 @@
|
||||
//简体中文
|
||||
export default {
|
||||
//main.ts
|
||||
'search douban by current file name':'用当前文档名搜索豆瓣并写入当前文档',
|
||||
'search douban and import to current file':'在豆瓣搜索并写入到当前文档',
|
||||
'Enter Search Term:':`输入搜索内容:`,
|
||||
'Search':`搜索`,
|
||||
'Cancel':`取消`,
|
||||
|
||||
//DoubanSettingTab
|
||||
'douban search url': `豆瓣搜索地址`,
|
||||
'douban search url desc 1': `豆瓣搜索页面请求地址, 通常是网页搜索的地址. `,
|
||||
'douban search url desc 2': `先访问:`,
|
||||
'douban search url desc 3': `然后在搜索输入框不输入任何内容,直接点击搜索,`,
|
||||
'douban search url desc 4': `所跳转的网页地址即是搜索地址,`,
|
||||
'douban search url desc 5': `将网页地址复制到当前输入框即可,`,
|
||||
|
||||
'movie content template': `电影文本模板`,
|
||||
'movie content template desc 1': `设置选择电影后导入的文本内容模板,`,
|
||||
'movie content template desc 2': `支持以下参数名称 :`,
|
||||
'movie content template desc 3': `{{id}}, {{type}}, {{title}},`,
|
||||
'movie content template desc 4': `{{score}}, {{datePublished}}, {{director}},`,
|
||||
'movie content template desc 5': `{{author}}, {{autor}}, {{desc}},`,
|
||||
'movie content template desc 6': `{{image}}, {{url}}`,
|
||||
|
||||
'Date format': `参数日期格式`,
|
||||
'This format will be used when available template variables contain date.':
|
||||
`这个格式是给上面获取到的参数进行格式化时显示的内容 .`,
|
||||
'For more syntax, refer to': `详细介绍请参考`,
|
||||
'Your current syntax looks like this':`时间参数时间格式预览`,
|
||||
'format reference': `格式参考`,
|
||||
'Array Spilt String':`数组分割字符串`,
|
||||
'string to join between array type, such as author, actor':`当模板中的变量存在数组, 则需要设定数组元素中的分割符号,比如 演员列表等`,
|
||||
'Douban Request Headers':`豆瓣HTTP请求头`,
|
||||
'Douban Request Headers Desc': `如果豆瓣搜索或者获取数据失败,请尝试修改这个参数,\n
|
||||
参数获取方式为:\n
|
||||
1. 访问http://www.douban.com
|
||||
2. 复制请求头,仅复制以下请求头 `,
|
||||
'current version not support type': `暂时不支持该类型导入,请至github提交issuess获取帮助`,
|
||||
'Douban': `豆瓣网`,
|
||||
|
||||
'Person Name Language Mode':'人名显示模式',
|
||||
'options:':"可选项:",
|
||||
'Chinese Name mode, only show Chinese name':'中文名称模式, 人名只显示中文名',
|
||||
'English Name mode, only show English name':'英文名称模式, 人名只显示英文名',
|
||||
'Chinese English Name mode, show Chinese English name both':'中文和英文名称模式, 人名同时显示中文和英文名',
|
||||
'Chinese Name': '中文名',
|
||||
'English Name': '英文名',
|
||||
'Chinese And English Name': '中文名和英文名',
|
||||
|
||||
}
|
||||
80
main.ts
@ -1,80 +0,0 @@
|
||||
import { DEFAULT_SETTINGS, DoubanPluginSettings } from "./douban/Douban";
|
||||
import { Editor, Plugin } from "obsidian";
|
||||
|
||||
import { DoubanEtractHandler } from "douban/handler/DoubanExtractHandler";
|
||||
import { DoubanFuzzySuggester } from "douban/search/DoubanSearchFuzzySuggestModal";
|
||||
import DoubanMovieSubject from "douban/model/DoubanMovieSubject";
|
||||
import { DoubanSearchModal } from "douban/search/DoubanSearchModal";
|
||||
import { DoubanSettingTab } from "douban/DoubanSettingTab";
|
||||
import DoubanSubject from "douban/model/DoubanSubject";
|
||||
import Searcher from "douban/search/Search";
|
||||
import { i18nHelper } from './lang/helper';
|
||||
import { log } from "utils/Logutil";
|
||||
|
||||
export default class DoubanPlugin extends Plugin {
|
||||
public settings: DoubanPluginSettings;
|
||||
public doubanEtractHandler: DoubanEtractHandler;
|
||||
|
||||
async putToEditor(editor:Editor, extract:DoubanSubject) {
|
||||
if(!editor || !extract) {
|
||||
return;
|
||||
}
|
||||
var content:string = this.doubanEtractHandler.parseText(extract, this.settings)
|
||||
if(content) {
|
||||
editor.replaceSelection(content);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async search(searchTerm:string, editor: Editor) {
|
||||
log.trace("[main] start search:" + searchTerm);
|
||||
const resultList = await Searcher.search(searchTerm, this.settings);
|
||||
log.trace("[main] complete search:" + searchTerm + ",\n result list:" + JSON.stringify(resultList));
|
||||
new DoubanFuzzySuggester(this, editor).showSearchList(resultList);
|
||||
}
|
||||
|
||||
async getDoubanMovieTextForActiveFile(editor: Editor) {
|
||||
const activeFile = await this.app.workspace.getActiveFile();
|
||||
if (activeFile) {
|
||||
const searchTerm = activeFile.basename;
|
||||
if (searchTerm) {
|
||||
await this.search(searchTerm, editor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async geDoubanMovieTextForSearchTerm(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("search douban by current file name"),
|
||||
editorCallback: (editor: Editor) =>
|
||||
this.getDoubanMovieTextForActiveFile(editor),
|
||||
});
|
||||
|
||||
|
||||
this.addCommand({
|
||||
id: "search-douban-and-input-current-file",
|
||||
name: i18nHelper.getMessage("search douban and import to current file"),
|
||||
editorCallback: (editor: Editor) =>
|
||||
this.geDoubanMovieTextForSearchTerm(editor),
|
||||
});
|
||||
|
||||
this.addSettingTab(new DoubanSettingTab(this.app, this));
|
||||
}
|
||||
|
||||
async loadSettings() {
|
||||
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
|
||||
this.doubanEtractHandler = new DoubanEtractHandler(this.app, this);
|
||||
}
|
||||
|
||||
async saveSettings() {
|
||||
await this.saveData(this.settings);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
{
|
||||
"id": "obsidian-douban-plugin",
|
||||
"name": "Douban",
|
||||
"version": "1.0.1",
|
||||
"minAppVersion": "0.12.0",
|
||||
"description": "This is a plugin that can import movies, books or musics info data from Douban for Obsidian .",
|
||||
"author": "Wanxp",
|
||||
"authorUrl": "https://wanxuping.com",
|
||||
"isDesktopOnly": true
|
||||
}
|
||||
{
|
||||
"id": "obsidian-douban-plugin",
|
||||
"name": "Douban",
|
||||
"version": "2.3.2",
|
||||
"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",
|
||||
"authorUrl": "https://obsidian-douban.wanxuping.com",
|
||||
"isDesktopOnly": false
|
||||
}
|
||||
|
||||
909
package-lock.json
generated
@ -1,909 +0,0 @@
|
||||
{
|
||||
"name": "obsidian-sample-plugin",
|
||||
"version": "1.0.1",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@codemirror/rangeset": {
|
||||
"version": "0.19.9",
|
||||
"resolved": "https://registry.npmmirror.com/@codemirror/rangeset/-/rangeset-0.19.9.tgz",
|
||||
"integrity": "sha512-V8YUuOvK+ew87Xem+71nKcqu1SXd5QROMRLMS/ljT5/3MCxtgrRie1Cvild0G/Z2f1fpWxzX78V0U4jjXBorBQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@codemirror/state": "^0.19.0"
|
||||
}
|
||||
},
|
||||
"@codemirror/state": {
|
||||
"version": "0.19.9",
|
||||
"resolved": "https://registry.npmmirror.com/@codemirror/state/-/state-0.19.9.tgz",
|
||||
"integrity": "sha512-psOzDolKTZkx4CgUqhBQ8T8gBc0xN5z4gzed109aF6x7D7umpDRoimacI/O6d9UGuyl4eYuDCZmDFr2Rq7aGOw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@codemirror/text": "^0.19.0"
|
||||
}
|
||||
},
|
||||
"@codemirror/text": {
|
||||
"version": "0.19.6",
|
||||
"resolved": "https://registry.npmmirror.com/@codemirror/text/-/text-0.19.6.tgz",
|
||||
"integrity": "sha512-T9jnREMIygx+TPC1bOuepz18maGq/92q2a+n4qTqObKwvNMg+8cMTslb8yxeEDEq7S3kpgGWxgO1UWbQRij0dA==",
|
||||
"dev": true
|
||||
},
|
||||
"@codemirror/view": {
|
||||
"version": "0.19.48",
|
||||
"resolved": "https://registry.npmmirror.com/@codemirror/view/-/view-0.19.48.tgz",
|
||||
"integrity": "sha512-0eg7D2Nz4S8/caetCTz61rK0tkHI17V/d15Jy0kLOT8dTLGGNJUponDnW28h2B6bERmPlVHKh8MJIr5OCp1nGw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@codemirror/rangeset": "^0.19.5",
|
||||
"@codemirror/state": "^0.19.3",
|
||||
"@codemirror/text": "^0.19.0",
|
||||
"style-mod": "^4.0.0",
|
||||
"w3c-keyname": "^2.2.4"
|
||||
}
|
||||
},
|
||||
"@nodelib/fs.scandir": {
|
||||
"version": "2.1.5",
|
||||
"resolved": "https://registry.npmmirror.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
|
||||
"integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@nodelib/fs.stat": "2.0.5",
|
||||
"run-parallel": "^1.1.9"
|
||||
}
|
||||
},
|
||||
"@nodelib/fs.stat": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmmirror.com/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz",
|
||||
"integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==",
|
||||
"dev": true
|
||||
},
|
||||
"@nodelib/fs.walk": {
|
||||
"version": "1.2.8",
|
||||
"resolved": "https://registry.npmmirror.com/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz",
|
||||
"integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@nodelib/fs.scandir": "2.1.5",
|
||||
"fastq": "^1.6.0"
|
||||
}
|
||||
},
|
||||
"@types/codemirror": {
|
||||
"version": "0.0.108",
|
||||
"resolved": "https://registry.npmmirror.com/@types/codemirror/-/codemirror-0.0.108.tgz",
|
||||
"integrity": "sha512-3FGFcus0P7C2UOGCNUVENqObEb4SFk+S8Dnxq7K6aIsLVs/vDtlangl3PEO0ykaKXyK56swVF6Nho7VsA44uhw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/tern": "*"
|
||||
}
|
||||
},
|
||||
"@types/estree": {
|
||||
"version": "0.0.51",
|
||||
"resolved": "https://registry.npmmirror.com/@types/estree/-/estree-0.0.51.tgz",
|
||||
"integrity": "sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/json-schema": {
|
||||
"version": "7.0.11",
|
||||
"resolved": "https://registry.npmmirror.com/@types/json-schema/-/json-schema-7.0.11.tgz",
|
||||
"integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "16.11.36",
|
||||
"resolved": "https://registry.npmmirror.com/@types/node/-/node-16.11.36.tgz",
|
||||
"integrity": "sha512-FR5QJe+TaoZ2GsMHkjuwoNabr+UrJNRr2HNOo+r/7vhcuntM6Ee/pRPOnRhhL2XE9OOvX9VLEq+BcXl3VjNoWA==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/tern": {
|
||||
"version": "0.23.4",
|
||||
"resolved": "https://registry.npmmirror.com/@types/tern/-/tern-0.23.4.tgz",
|
||||
"integrity": "sha512-JAUw1iXGO1qaWwEOzxTKJZ/5JxVeON9kvGZ/osgZaJImBnyjyn0cjovPsf6FNLmyGY8Vw9DoXZCMlfMkMwHRWg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/estree": "*"
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/eslint-plugin": {
|
||||
"version": "5.25.0",
|
||||
"resolved": "https://registry.npmmirror.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.25.0.tgz",
|
||||
"integrity": "sha512-icYrFnUzvm+LhW0QeJNKkezBu6tJs9p/53dpPLFH8zoM9w1tfaKzVurkPotEpAqQ8Vf8uaFyL5jHd0Vs6Z0ZQg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/scope-manager": "5.25.0",
|
||||
"@typescript-eslint/type-utils": "5.25.0",
|
||||
"@typescript-eslint/utils": "5.25.0",
|
||||
"debug": "^4.3.4",
|
||||
"functional-red-black-tree": "^1.0.1",
|
||||
"ignore": "^5.2.0",
|
||||
"regexpp": "^3.2.0",
|
||||
"semver": "^7.3.7",
|
||||
"tsutils": "^3.21.0"
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/parser": {
|
||||
"version": "5.25.0",
|
||||
"resolved": "https://registry.npmmirror.com/@typescript-eslint/parser/-/parser-5.25.0.tgz",
|
||||
"integrity": "sha512-r3hwrOWYbNKP1nTcIw/aZoH+8bBnh/Lh1iDHoFpyG4DnCpvEdctrSl6LOo19fZbzypjQMHdajolxs6VpYoChgA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/scope-manager": "5.25.0",
|
||||
"@typescript-eslint/types": "5.25.0",
|
||||
"@typescript-eslint/typescript-estree": "5.25.0",
|
||||
"debug": "^4.3.4"
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/scope-manager": {
|
||||
"version": "5.25.0",
|
||||
"resolved": "https://registry.npmmirror.com/@typescript-eslint/scope-manager/-/scope-manager-5.25.0.tgz",
|
||||
"integrity": "sha512-p4SKTFWj+2VpreUZ5xMQsBMDdQ9XdRvODKXN4EksyBjFp2YvQdLkyHqOffakYZPuWJUDNu3jVXtHALDyTv3cww==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/types": "5.25.0",
|
||||
"@typescript-eslint/visitor-keys": "5.25.0"
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/type-utils": {
|
||||
"version": "5.25.0",
|
||||
"resolved": "https://registry.npmmirror.com/@typescript-eslint/type-utils/-/type-utils-5.25.0.tgz",
|
||||
"integrity": "sha512-B6nb3GK3Gv1Rsb2pqalebe/RyQoyG/WDy9yhj8EE0Ikds4Xa8RR28nHz+wlt4tMZk5bnAr0f3oC8TuDAd5CPrw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/utils": "5.25.0",
|
||||
"debug": "^4.3.4",
|
||||
"tsutils": "^3.21.0"
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/types": {
|
||||
"version": "5.25.0",
|
||||
"resolved": "https://registry.npmmirror.com/@typescript-eslint/types/-/types-5.25.0.tgz",
|
||||
"integrity": "sha512-7fWqfxr0KNHj75PFqlGX24gWjdV/FDBABXL5dyvBOWHpACGyveok8Uj4ipPX/1fGU63fBkzSIycEje4XsOxUFA==",
|
||||
"dev": true
|
||||
},
|
||||
"@typescript-eslint/typescript-estree": {
|
||||
"version": "5.25.0",
|
||||
"resolved": "https://registry.npmmirror.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.25.0.tgz",
|
||||
"integrity": "sha512-MrPODKDych/oWs/71LCnuO7NyR681HuBly2uLnX3r5i4ME7q/yBqC4hW33kmxtuauLTM0OuBOhhkFaxCCOjEEw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/types": "5.25.0",
|
||||
"@typescript-eslint/visitor-keys": "5.25.0",
|
||||
"debug": "^4.3.4",
|
||||
"globby": "^11.1.0",
|
||||
"is-glob": "^4.0.3",
|
||||
"semver": "^7.3.7",
|
||||
"tsutils": "^3.21.0"
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/utils": {
|
||||
"version": "5.25.0",
|
||||
"resolved": "https://registry.npmmirror.com/@typescript-eslint/utils/-/utils-5.25.0.tgz",
|
||||
"integrity": "sha512-qNC9bhnz/n9Kba3yI6HQgQdBLuxDoMgdjzdhSInZh6NaDnFpTUlwNGxplUFWfY260Ya0TRPvkg9dd57qxrJI9g==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/json-schema": "^7.0.9",
|
||||
"@typescript-eslint/scope-manager": "5.25.0",
|
||||
"@typescript-eslint/types": "5.25.0",
|
||||
"@typescript-eslint/typescript-estree": "5.25.0",
|
||||
"eslint-scope": "^5.1.1",
|
||||
"eslint-utils": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/visitor-keys": {
|
||||
"version": "5.25.0",
|
||||
"resolved": "https://registry.npmmirror.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.25.0.tgz",
|
||||
"integrity": "sha512-yd26vFgMsC4h2dgX4+LR+GeicSKIfUvZREFLf3DDjZPtqgLx5AJZr6TetMNwFP9hcKreTTeztQYBTNbNoOycwA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/types": "5.25.0",
|
||||
"eslint-visitor-keys": "^3.3.0"
|
||||
}
|
||||
},
|
||||
"array-union": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/array-union/-/array-union-2.1.0.tgz",
|
||||
"integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==",
|
||||
"dev": true
|
||||
},
|
||||
"asynckit": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmmirror.com/asynckit/-/asynckit-0.4.0.tgz",
|
||||
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
|
||||
},
|
||||
"axios": {
|
||||
"version": "0.27.2",
|
||||
"resolved": "https://registry.npmmirror.com/axios/-/axios-0.27.2.tgz",
|
||||
"integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==",
|
||||
"requires": {
|
||||
"follow-redirects": "^1.14.9",
|
||||
"form-data": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"boolbase": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/boolbase/-/boolbase-1.0.0.tgz",
|
||||
"integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww=="
|
||||
},
|
||||
"braces": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmmirror.com/braces/-/braces-3.0.2.tgz",
|
||||
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"fill-range": "^7.0.1"
|
||||
}
|
||||
},
|
||||
"builtin-modules": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmmirror.com/builtin-modules/-/builtin-modules-3.3.0.tgz",
|
||||
"integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==",
|
||||
"dev": true
|
||||
},
|
||||
"cheerio": {
|
||||
"version": "1.0.0-rc.11",
|
||||
"resolved": "https://registry.npmmirror.com/cheerio/-/cheerio-1.0.0-rc.11.tgz",
|
||||
"integrity": "sha512-bQwNaDIBKID5ts/DsdhxrjqFXYfLw4ste+wMKqWA8DyKcS4qwsPP4Bk8ZNaTJjvpiX/qW3BT4sU7d6Bh5i+dag==",
|
||||
"requires": {
|
||||
"cheerio-select": "^2.1.0",
|
||||
"dom-serializer": "^2.0.0",
|
||||
"domhandler": "^5.0.3",
|
||||
"domutils": "^3.0.1",
|
||||
"htmlparser2": "^8.0.1",
|
||||
"parse5": "^7.0.0",
|
||||
"parse5-htmlparser2-tree-adapter": "^7.0.0",
|
||||
"tslib": "^2.4.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"tslib": {
|
||||
"version": "2.4.0",
|
||||
"resolved": "https://registry.npmmirror.com/tslib/-/tslib-2.4.0.tgz",
|
||||
"integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"cheerio-select": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/cheerio-select/-/cheerio-select-2.1.0.tgz",
|
||||
"integrity": "sha512-9v9kG0LvzrlcungtnJtpGNxY+fzECQKhK4EGJX2vByejiMX84MFNQw4UxPJl3bFbTMw+Dfs37XaIkCwTZfLh4g==",
|
||||
"requires": {
|
||||
"boolbase": "^1.0.0",
|
||||
"css-select": "^5.1.0",
|
||||
"css-what": "^6.1.0",
|
||||
"domelementtype": "^2.3.0",
|
||||
"domhandler": "^5.0.3",
|
||||
"domutils": "^3.0.1"
|
||||
}
|
||||
},
|
||||
"combined-stream": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmmirror.com/combined-stream/-/combined-stream-1.0.8.tgz",
|
||||
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
|
||||
"requires": {
|
||||
"delayed-stream": "~1.0.0"
|
||||
}
|
||||
},
|
||||
"css-select": {
|
||||
"version": "5.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/css-select/-/css-select-5.1.0.tgz",
|
||||
"integrity": "sha512-nwoRF1rvRRnnCqqY7updORDsuqKzqYJ28+oSMaJMMgOauh3fvwHqMS7EZpIPqK8GL+g9mKxF1vP/ZjSeNjEVHg==",
|
||||
"requires": {
|
||||
"boolbase": "^1.0.0",
|
||||
"css-what": "^6.1.0",
|
||||
"domhandler": "^5.0.2",
|
||||
"domutils": "^3.0.1",
|
||||
"nth-check": "^2.0.1"
|
||||
}
|
||||
},
|
||||
"css-what": {
|
||||
"version": "6.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/css-what/-/css-what-6.1.0.tgz",
|
||||
"integrity": "sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw=="
|
||||
},
|
||||
"cuint": {
|
||||
"version": "0.2.2",
|
||||
"resolved": "https://registry.npmmirror.com/cuint/-/cuint-0.2.2.tgz",
|
||||
"integrity": "sha512-d4ZVpCW31eWwCMe1YT3ur7mUDnTXbgwyzaL320DrcRT45rfjYxkt5QWLrmOJ+/UEAI2+fQgKe/fCjR8l4TpRgw=="
|
||||
},
|
||||
"debug": {
|
||||
"version": "4.3.4",
|
||||
"resolved": "https://registry.npmmirror.com/debug/-/debug-4.3.4.tgz",
|
||||
"integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ms": "2.1.2"
|
||||
}
|
||||
},
|
||||
"delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ=="
|
||||
},
|
||||
"dir-glob": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/dir-glob/-/dir-glob-3.0.1.tgz",
|
||||
"integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"path-type": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"dom-serializer": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/dom-serializer/-/dom-serializer-2.0.0.tgz",
|
||||
"integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==",
|
||||
"requires": {
|
||||
"domelementtype": "^2.3.0",
|
||||
"domhandler": "^5.0.2",
|
||||
"entities": "^4.2.0"
|
||||
}
|
||||
},
|
||||
"domelementtype": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmmirror.com/domelementtype/-/domelementtype-2.3.0.tgz",
|
||||
"integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw=="
|
||||
},
|
||||
"domhandler": {
|
||||
"version": "5.0.3",
|
||||
"resolved": "https://registry.npmmirror.com/domhandler/-/domhandler-5.0.3.tgz",
|
||||
"integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==",
|
||||
"requires": {
|
||||
"domelementtype": "^2.3.0"
|
||||
}
|
||||
},
|
||||
"domutils": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/domutils/-/domutils-3.0.1.tgz",
|
||||
"integrity": "sha512-z08c1l761iKhDFtfXO04C7kTdPBLi41zwOZl00WS8b5eiaebNpY00HKbztwBq+e3vyqWNwWF3mP9YLUeqIrF+Q==",
|
||||
"requires": {
|
||||
"dom-serializer": "^2.0.0",
|
||||
"domelementtype": "^2.3.0",
|
||||
"domhandler": "^5.0.1"
|
||||
}
|
||||
},
|
||||
"douban-search-crack": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmmirror.com/douban-search-crack/-/douban-search-crack-1.0.6.tgz",
|
||||
"integrity": "sha512-IchjtqsemiJH0x7xo/7/QjEVa0khKMfY0KMtA9GMXXSQRJFPtiedi5Z0htB/xq0Thpo6SsbLXYJIkdVX3n3Qng==",
|
||||
"requires": {
|
||||
"xxhashjs": "^0.2.2"
|
||||
}
|
||||
},
|
||||
"entities": {
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmmirror.com/entities/-/entities-4.3.0.tgz",
|
||||
"integrity": "sha512-/iP1rZrSEJ0DTlPiX+jbzlA3eVkY/e8L8SozroF395fIqE3TYF/Nz7YOMAawta+vLmyJ/hkGNNPcSbMADCCXbg=="
|
||||
},
|
||||
"esbuild": {
|
||||
"version": "0.13.12",
|
||||
"resolved": "https://registry.npmmirror.com/esbuild/-/esbuild-0.13.12.tgz",
|
||||
"integrity": "sha512-vTKKUt+yoz61U/BbrnmlG9XIjwpdIxmHB8DlPR0AAW6OdS+nBQBci6LUHU2q9WbBobMEIQxxDpKbkmOGYvxsow==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"esbuild-android-arm64": "0.13.12",
|
||||
"esbuild-darwin-64": "0.13.12",
|
||||
"esbuild-darwin-arm64": "0.13.12",
|
||||
"esbuild-freebsd-64": "0.13.12",
|
||||
"esbuild-freebsd-arm64": "0.13.12",
|
||||
"esbuild-linux-32": "0.13.12",
|
||||
"esbuild-linux-64": "0.13.12",
|
||||
"esbuild-linux-arm": "0.13.12",
|
||||
"esbuild-linux-arm64": "0.13.12",
|
||||
"esbuild-linux-mips64le": "0.13.12",
|
||||
"esbuild-linux-ppc64le": "0.13.12",
|
||||
"esbuild-netbsd-64": "0.13.12",
|
||||
"esbuild-openbsd-64": "0.13.12",
|
||||
"esbuild-sunos-64": "0.13.12",
|
||||
"esbuild-windows-32": "0.13.12",
|
||||
"esbuild-windows-64": "0.13.12",
|
||||
"esbuild-windows-arm64": "0.13.12"
|
||||
}
|
||||
},
|
||||
"esbuild-android-arm64": {
|
||||
"version": "0.13.12",
|
||||
"resolved": "https://registry.npmmirror.com/esbuild-android-arm64/-/esbuild-android-arm64-0.13.12.tgz",
|
||||
"integrity": "sha512-TSVZVrb4EIXz6KaYjXfTzPyyRpXV5zgYIADXtQsIenjZ78myvDGaPi11o4ZSaHIwFHsuwkB6ne5SZRBwAQ7maw==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-darwin-64": {
|
||||
"version": "0.13.12",
|
||||
"resolved": "https://registry.npmmirror.com/esbuild-darwin-64/-/esbuild-darwin-64-0.13.12.tgz",
|
||||
"integrity": "sha512-c51C+N+UHySoV2lgfWSwwmlnLnL0JWj/LzuZt9Ltk9ub1s2Y8cr6SQV5W3mqVH1egUceew6KZ8GyI4nwu+fhsw==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-darwin-arm64": {
|
||||
"version": "0.13.12",
|
||||
"resolved": "https://registry.npmmirror.com/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.13.12.tgz",
|
||||
"integrity": "sha512-JvAMtshP45Hd8A8wOzjkY1xAnTKTYuP/QUaKp5eUQGX+76GIie3fCdUUr2ZEKdvpSImNqxiZSIMziEiGB5oUmQ==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-freebsd-64": {
|
||||
"version": "0.13.12",
|
||||
"resolved": "https://registry.npmmirror.com/esbuild-freebsd-64/-/esbuild-freebsd-64-0.13.12.tgz",
|
||||
"integrity": "sha512-r6On/Skv9f0ZjTu6PW5o7pdXr8aOgtFOEURJZYf1XAJs0IQ+gW+o1DzXjVkIoT+n1cm3N/t1KRJfX71MPg/ZUA==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-freebsd-arm64": {
|
||||
"version": "0.13.12",
|
||||
"resolved": "https://registry.npmmirror.com/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.13.12.tgz",
|
||||
"integrity": "sha512-F6LmI2Q1gii073kmBE3NOTt/6zLL5zvZsxNLF8PMAwdHc+iBhD1vzfI8uQZMJA1IgXa3ocr3L3DJH9fLGXy6Yw==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-linux-32": {
|
||||
"version": "0.13.12",
|
||||
"resolved": "https://registry.npmmirror.com/esbuild-linux-32/-/esbuild-linux-32-0.13.12.tgz",
|
||||
"integrity": "sha512-U1UZwG3UIwF7/V4tCVAo/nkBV9ag5KJiJTt+gaCmLVWH3bPLX7y+fNlhIWZy8raTMnXhMKfaTvWZ9TtmXzvkuQ==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-linux-64": {
|
||||
"version": "0.13.12",
|
||||
"resolved": "https://registry.npmmirror.com/esbuild-linux-64/-/esbuild-linux-64-0.13.12.tgz",
|
||||
"integrity": "sha512-YpXSwtu2NxN3N4ifJxEdsgd6Q5d8LYqskrAwjmoCT6yQnEHJSF5uWcxv783HWN7lnGpJi9KUtDvYsnMdyGw71Q==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-linux-arm": {
|
||||
"version": "0.13.12",
|
||||
"resolved": "https://registry.npmmirror.com/esbuild-linux-arm/-/esbuild-linux-arm-0.13.12.tgz",
|
||||
"integrity": "sha512-SyiT/JKxU6J+DY2qUiSLZJqCAftIt3uoGejZ0HDnUM2MGJqEGSGh7p1ecVL2gna3PxS4P+j6WAehCwgkBPXNIw==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-linux-arm64": {
|
||||
"version": "0.13.12",
|
||||
"resolved": "https://registry.npmmirror.com/esbuild-linux-arm64/-/esbuild-linux-arm64-0.13.12.tgz",
|
||||
"integrity": "sha512-sgDNb8kb3BVodtAlcFGgwk+43KFCYjnFOaOfJibXnnIojNWuJHpL6aQJ4mumzNWw8Rt1xEtDQyuGK9f+Y24jGA==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-linux-mips64le": {
|
||||
"version": "0.13.12",
|
||||
"resolved": "https://registry.npmmirror.com/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.13.12.tgz",
|
||||
"integrity": "sha512-qQJHlZBG+QwVIA8AbTEtbvF084QgDi4DaUsUnA+EolY1bxrG+UyOuGflM2ZritGhfS/k7THFjJbjH2wIeoKA2g==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-linux-ppc64le": {
|
||||
"version": "0.13.12",
|
||||
"resolved": "https://registry.npmmirror.com/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.13.12.tgz",
|
||||
"integrity": "sha512-2dSnm1ldL7Lppwlo04CGQUpwNn5hGqXI38OzaoPOkRsBRWFBozyGxTFSee/zHFS+Pdh3b28JJbRK3owrrRgWNw==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-netbsd-64": {
|
||||
"version": "0.13.12",
|
||||
"resolved": "https://registry.npmmirror.com/esbuild-netbsd-64/-/esbuild-netbsd-64-0.13.12.tgz",
|
||||
"integrity": "sha512-D4raxr02dcRiQNbxOLzpqBzcJNFAdsDNxjUbKkDMZBkL54Z0vZh4LRndycdZAMcIdizC/l/Yp/ZsBdAFxc5nbA==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-openbsd-64": {
|
||||
"version": "0.13.12",
|
||||
"resolved": "https://registry.npmmirror.com/esbuild-openbsd-64/-/esbuild-openbsd-64-0.13.12.tgz",
|
||||
"integrity": "sha512-KuLCmYMb2kh05QuPJ+va60bKIH5wHL8ypDkmpy47lzwmdxNsuySeCMHuTv5o2Af1RUn5KLO5ZxaZeq4GEY7DaQ==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-sunos-64": {
|
||||
"version": "0.13.12",
|
||||
"resolved": "https://registry.npmmirror.com/esbuild-sunos-64/-/esbuild-sunos-64-0.13.12.tgz",
|
||||
"integrity": "sha512-jBsF+e0woK3miKI8ufGWKG3o3rY9DpHvCVRn5eburMIIE+2c+y3IZ1srsthKyKI6kkXLvV4Cf/E7w56kLipMXw==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-windows-32": {
|
||||
"version": "0.13.12",
|
||||
"resolved": "https://registry.npmmirror.com/esbuild-windows-32/-/esbuild-windows-32-0.13.12.tgz",
|
||||
"integrity": "sha512-L9m4lLFQrFeR7F+eLZXG82SbXZfUhyfu6CexZEil6vm+lc7GDCE0Q8DiNutkpzjv1+RAbIGVva9muItQ7HVTkQ==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-windows-64": {
|
||||
"version": "0.13.12",
|
||||
"resolved": "https://registry.npmmirror.com/esbuild-windows-64/-/esbuild-windows-64-0.13.12.tgz",
|
||||
"integrity": "sha512-k4tX4uJlSbSkfs78W5d9+I9gpd+7N95W7H2bgOMFPsYREVJs31+Q2gLLHlsnlY95zBoPQMIzHooUIsixQIBjaQ==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"esbuild-windows-arm64": {
|
||||
"version": "0.13.12",
|
||||
"resolved": "https://registry.npmmirror.com/esbuild-windows-arm64/-/esbuild-windows-arm64-0.13.12.tgz",
|
||||
"integrity": "sha512-2tTv/BpYRIvuwHpp2M960nG7uvL+d78LFW/ikPItO+2GfK51CswIKSetSpDii+cjz8e9iSPgs+BU4o8nWICBwQ==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"eslint-scope": {
|
||||
"version": "5.1.1",
|
||||
"resolved": "https://registry.npmmirror.com/eslint-scope/-/eslint-scope-5.1.1.tgz",
|
||||
"integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"esrecurse": "^4.3.0",
|
||||
"estraverse": "^4.1.1"
|
||||
}
|
||||
},
|
||||
"eslint-utils": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/eslint-utils/-/eslint-utils-3.0.0.tgz",
|
||||
"integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"eslint-visitor-keys": "^2.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"eslint-visitor-keys": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz",
|
||||
"integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"eslint-visitor-keys": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmmirror.com/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz",
|
||||
"integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==",
|
||||
"dev": true
|
||||
},
|
||||
"esrecurse": {
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmmirror.com/esrecurse/-/esrecurse-4.3.0.tgz",
|
||||
"integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"estraverse": "^5.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"estraverse": {
|
||||
"version": "5.3.0",
|
||||
"resolved": "https://registry.npmmirror.com/estraverse/-/estraverse-5.3.0.tgz",
|
||||
"integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"estraverse": {
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmmirror.com/estraverse/-/estraverse-4.3.0.tgz",
|
||||
"integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==",
|
||||
"dev": true
|
||||
},
|
||||
"fast-glob": {
|
||||
"version": "3.2.11",
|
||||
"resolved": "https://registry.npmmirror.com/fast-glob/-/fast-glob-3.2.11.tgz",
|
||||
"integrity": "sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@nodelib/fs.stat": "^2.0.2",
|
||||
"@nodelib/fs.walk": "^1.2.3",
|
||||
"glob-parent": "^5.1.2",
|
||||
"merge2": "^1.3.0",
|
||||
"micromatch": "^4.0.4"
|
||||
}
|
||||
},
|
||||
"fastq": {
|
||||
"version": "1.13.0",
|
||||
"resolved": "https://registry.npmmirror.com/fastq/-/fastq-1.13.0.tgz",
|
||||
"integrity": "sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"reusify": "^1.0.4"
|
||||
}
|
||||
},
|
||||
"fill-range": {
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/fill-range/-/fill-range-7.0.1.tgz",
|
||||
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"to-regex-range": "^5.0.1"
|
||||
}
|
||||
},
|
||||
"follow-redirects": {
|
||||
"version": "1.15.0",
|
||||
"resolved": "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.15.0.tgz",
|
||||
"integrity": "sha512-aExlJShTV4qOUOL7yF1U5tvLCB0xQuudbf6toyYA0E/acBNw71mvjFTnLaRp50aQaYocMR0a/RMMBIHeZnGyjQ=="
|
||||
},
|
||||
"form-data": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/form-data/-/form-data-4.0.0.tgz",
|
||||
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
|
||||
"requires": {
|
||||
"asynckit": "^0.4.0",
|
||||
"combined-stream": "^1.0.8",
|
||||
"mime-types": "^2.1.12"
|
||||
}
|
||||
},
|
||||
"functional-red-black-tree": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz",
|
||||
"integrity": "sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g==",
|
||||
"dev": true
|
||||
},
|
||||
"glob-parent": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmmirror.com/glob-parent/-/glob-parent-5.1.2.tgz",
|
||||
"integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"is-glob": "^4.0.1"
|
||||
}
|
||||
},
|
||||
"globby": {
|
||||
"version": "11.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/globby/-/globby-11.1.0.tgz",
|
||||
"integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"array-union": "^2.1.0",
|
||||
"dir-glob": "^3.0.1",
|
||||
"fast-glob": "^3.2.9",
|
||||
"ignore": "^5.2.0",
|
||||
"merge2": "^1.4.1",
|
||||
"slash": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"htmlparser2": {
|
||||
"version": "8.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/htmlparser2/-/htmlparser2-8.0.1.tgz",
|
||||
"integrity": "sha512-4lVbmc1diZC7GUJQtRQ5yBAeUCL1exyMwmForWkRLnwyzWBFxN633SALPMGYaWZvKe9j1pRZJpauvmxENSp/EA==",
|
||||
"requires": {
|
||||
"domelementtype": "^2.3.0",
|
||||
"domhandler": "^5.0.2",
|
||||
"domutils": "^3.0.1",
|
||||
"entities": "^4.3.0"
|
||||
}
|
||||
},
|
||||
"ignore": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmmirror.com/ignore/-/ignore-5.2.0.tgz",
|
||||
"integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==",
|
||||
"dev": true
|
||||
},
|
||||
"is-extglob": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmmirror.com/is-extglob/-/is-extglob-2.1.1.tgz",
|
||||
"integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==",
|
||||
"dev": true
|
||||
},
|
||||
"is-glob": {
|
||||
"version": "4.0.3",
|
||||
"resolved": "https://registry.npmmirror.com/is-glob/-/is-glob-4.0.3.tgz",
|
||||
"integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"is-extglob": "^2.1.1"
|
||||
}
|
||||
},
|
||||
"is-number": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/is-number/-/is-number-7.0.0.tgz",
|
||||
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
|
||||
"dev": true
|
||||
},
|
||||
"lru-cache": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/lru-cache/-/lru-cache-6.0.0.tgz",
|
||||
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"yallist": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"merge2": {
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmmirror.com/merge2/-/merge2-1.4.1.tgz",
|
||||
"integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==",
|
||||
"dev": true
|
||||
},
|
||||
"micromatch": {
|
||||
"version": "4.0.5",
|
||||
"resolved": "https://registry.npmmirror.com/micromatch/-/micromatch-4.0.5.tgz",
|
||||
"integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"braces": "^3.0.2",
|
||||
"picomatch": "^2.3.1"
|
||||
}
|
||||
},
|
||||
"mime-db": {
|
||||
"version": "1.52.0",
|
||||
"resolved": "https://registry.npmmirror.com/mime-db/-/mime-db-1.52.0.tgz",
|
||||
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg=="
|
||||
},
|
||||
"mime-types": {
|
||||
"version": "2.1.35",
|
||||
"resolved": "https://registry.npmmirror.com/mime-types/-/mime-types-2.1.35.tgz",
|
||||
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
|
||||
"requires": {
|
||||
"mime-db": "1.52.0"
|
||||
}
|
||||
},
|
||||
"moment": {
|
||||
"version": "2.29.2",
|
||||
"resolved": "https://registry.npmmirror.com/moment/-/moment-2.29.2.tgz",
|
||||
"integrity": "sha512-UgzG4rvxYpN15jgCmVJwac49h9ly9NurikMWGPdVxm8GZD6XjkKPxDTjQQ43gtGgnV3X0cAyWDdP2Wexoquifg==",
|
||||
"dev": true
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmmirror.com/ms/-/ms-2.1.2.tgz",
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
|
||||
"dev": true
|
||||
},
|
||||
"node-fetch": {
|
||||
"version": "2.6.1",
|
||||
"resolved": "https://registry.npmmirror.com/node-fetch/-/node-fetch-2.6.1.tgz",
|
||||
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
|
||||
},
|
||||
"nth-check": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/nth-check/-/nth-check-2.0.1.tgz",
|
||||
"integrity": "sha512-it1vE95zF6dTT9lBsYbxvqh0Soy4SPowchj0UBGj/V6cTPnXXtQOPUbhZ6CmGzAD/rW22LQK6E96pcdJXk4A4w==",
|
||||
"requires": {
|
||||
"boolbase": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"obsidian": {
|
||||
"version": "0.14.8",
|
||||
"resolved": "https://registry.npmmirror.com/obsidian/-/obsidian-0.14.8.tgz",
|
||||
"integrity": "sha512-CQz+B2HSbhGVEBwZBL3rPl29ruOBmEhCbBmW7PIILnnRh6fFFvYy3kZLHVTUidzvRGZnEW/mQ7n9LXeJCp2a/Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@codemirror/state": "^0.19.6",
|
||||
"@codemirror/view": "^0.19.31",
|
||||
"@types/codemirror": "0.0.108",
|
||||
"moment": "2.29.2"
|
||||
}
|
||||
},
|
||||
"parse5": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/parse5/-/parse5-7.0.0.tgz",
|
||||
"integrity": "sha512-y/t8IXSPWTuRZqXc0ajH/UwDj4mnqLEbSttNbThcFhGrZuOyoyvNBO85PBp2jQa55wY9d07PBNjsK8ZP3K5U6g==",
|
||||
"requires": {
|
||||
"entities": "^4.3.0"
|
||||
}
|
||||
},
|
||||
"parse5-htmlparser2-tree-adapter": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-7.0.0.tgz",
|
||||
"integrity": "sha512-B77tOZrqqfUfnVcOrUvfdLbz4pu4RopLD/4vmu3HUPswwTA8OH0EMW9BlWR2B0RCoiZRAHEUu7IxeP1Pd1UU+g==",
|
||||
"requires": {
|
||||
"domhandler": "^5.0.2",
|
||||
"parse5": "^7.0.0"
|
||||
}
|
||||
},
|
||||
"path-type": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/path-type/-/path-type-4.0.0.tgz",
|
||||
"integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==",
|
||||
"dev": true
|
||||
},
|
||||
"picomatch": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmmirror.com/picomatch/-/picomatch-2.3.1.tgz",
|
||||
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
|
||||
"dev": true
|
||||
},
|
||||
"queue-microtask": {
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmmirror.com/queue-microtask/-/queue-microtask-1.2.3.tgz",
|
||||
"integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==",
|
||||
"dev": true
|
||||
},
|
||||
"regexpp": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmmirror.com/regexpp/-/regexpp-3.2.0.tgz",
|
||||
"integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==",
|
||||
"dev": true
|
||||
},
|
||||
"reusify": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmmirror.com/reusify/-/reusify-1.0.4.tgz",
|
||||
"integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==",
|
||||
"dev": true
|
||||
},
|
||||
"run-parallel": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmmirror.com/run-parallel/-/run-parallel-1.2.0.tgz",
|
||||
"integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"queue-microtask": "^1.2.2"
|
||||
}
|
||||
},
|
||||
"schema-dts": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/schema-dts/-/schema-dts-1.1.0.tgz",
|
||||
"integrity": "sha512-vdmbs/5ycj4zyKpZIDqTcy+IZi4s7c38RVAYuDmRi7zgxUT8wRWPMLzg0jr7FjdVunYu9yZ00F3+XcZTTFcTOQ=="
|
||||
},
|
||||
"semver": {
|
||||
"version": "7.3.7",
|
||||
"resolved": "https://registry.npmmirror.com/semver/-/semver-7.3.7.tgz",
|
||||
"integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"lru-cache": "^6.0.0"
|
||||
}
|
||||
},
|
||||
"slash": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/slash/-/slash-3.0.0.tgz",
|
||||
"integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
|
||||
"dev": true
|
||||
},
|
||||
"style-mod": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/style-mod/-/style-mod-4.0.0.tgz",
|
||||
"integrity": "sha512-OPhtyEjyyN9x3nhPsu76f52yUGXiZcgvsrFVtvTkyGRQJ0XK+GPc6ov1z+lRpbeabka+MYEQxOYRnt5nF30aMw==",
|
||||
"dev": true
|
||||
},
|
||||
"tiny-network": {
|
||||
"version": "0.0.6",
|
||||
"resolved": "https://registry.npmmirror.com/tiny-network/-/tiny-network-0.0.6.tgz",
|
||||
"integrity": "sha512-fYNn6nnbKZFch5nd1aWtwVwJG7zJc5dcyypKx1PgJvv1EFr/tUhQPSFx5Tw6lKTVqemxZystG8mkbQuu/P/R5g=="
|
||||
},
|
||||
"to-regex-range": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
||||
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"is-number": "^7.0.0"
|
||||
}
|
||||
},
|
||||
"tslib": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmmirror.com/tslib/-/tslib-2.3.1.tgz",
|
||||
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==",
|
||||
"dev": true
|
||||
},
|
||||
"tsutils": {
|
||||
"version": "3.21.0",
|
||||
"resolved": "https://registry.npmmirror.com/tsutils/-/tsutils-3.21.0.tgz",
|
||||
"integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"tslib": "^1.8.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"tslib": {
|
||||
"version": "1.14.1",
|
||||
"resolved": "https://registry.npmmirror.com/tslib/-/tslib-1.14.1.tgz",
|
||||
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"typescript": {
|
||||
"version": "4.7.2",
|
||||
"resolved": "https://registry.npmmirror.com/typescript/-/typescript-4.7.2.tgz",
|
||||
"integrity": "sha512-Mamb1iX2FDUpcTRzltPxgWMKy3fhg0TN378ylbktPGPK/99KbDtMQ4W1hwgsbPAsG3a0xKa1vmw4VKZQbkvz5A==",
|
||||
"dev": true
|
||||
},
|
||||
"w3c-keyname": {
|
||||
"version": "2.2.4",
|
||||
"resolved": "https://registry.npmmirror.com/w3c-keyname/-/w3c-keyname-2.2.4.tgz",
|
||||
"integrity": "sha512-tOhfEwEzFLJzf6d1ZPkYfGj+FWhIpBux9ppoP3rlclw3Z0BZv3N7b7030Z1kYth+6rDuAsXUFr+d0VE6Ed1ikw==",
|
||||
"dev": true
|
||||
},
|
||||
"xxhashjs": {
|
||||
"version": "0.2.2",
|
||||
"resolved": "https://registry.npmmirror.com/xxhashjs/-/xxhashjs-0.2.2.tgz",
|
||||
"integrity": "sha512-AkTuIuVTET12tpsVIQo+ZU6f/qDmKuRUcjaqR+OIvm+aCBsZ95i7UVY5WJ9TMsSaZ0DA2WxoZ4acu0sPH+OKAw==",
|
||||
"requires": {
|
||||
"cuint": "^0.2.2"
|
||||
}
|
||||
},
|
||||
"yallist": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/yallist/-/yallist-4.0.0.tgz",
|
||||
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
}
|
||||
71
package.json
@ -1,32 +1,39 @@
|
||||
{
|
||||
"name": "obsidian-sample-plugin",
|
||||
"version": "1.0.1",
|
||||
"description": "This is a sample plugin for Obsidian (https://obsidian.md)",
|
||||
"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"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/node": "^16.11.6",
|
||||
"@typescript-eslint/eslint-plugin": "^5.2.0",
|
||||
"@typescript-eslint/parser": "^5.2.0",
|
||||
"builtin-modules": "^3.2.0",
|
||||
"esbuild": "0.13.12",
|
||||
"obsidian": "latest",
|
||||
"tslib": "2.3.1",
|
||||
"typescript": "4.7.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.27.2",
|
||||
"cheerio": "^1.0.0-rc.11",
|
||||
"douban-search-crack": "^1.0.6",
|
||||
"node-fetch": "^2.6.1",
|
||||
"schema-dts": "^1.1.0",
|
||||
"tiny-network": "0.0.6"
|
||||
}
|
||||
}
|
||||
{
|
||||
"name": "obsidian-douban-plugin",
|
||||
"version": "2.3.2",
|
||||
"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"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/jest": "^28.1.4",
|
||||
"@types/node": "^16.11.6",
|
||||
"@typescript-eslint/eslint-plugin": "^5.2.0",
|
||||
"@typescript-eslint/parser": "^5.2.0",
|
||||
"builtin-modules": "^3.2.0",
|
||||
"esbuild": "0.13.12",
|
||||
"jest": "^28.1.2",
|
||||
"obsidian": "latest",
|
||||
"ts-jest": "^28.0.5",
|
||||
"tslib": "2.3.1",
|
||||
"typescript": "^4.7.2",
|
||||
"vitepress": "^1.6.3"
|
||||
},
|
||||
"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"
|
||||
}
|
||||
}
|
||||
|
||||
550
src/org/wanxp/constant/Constsant.ts
Normal file
@ -0,0 +1,550 @@
|
||||
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: []
|
||||
};
|
||||
67
src/org/wanxp/constant/DefaultSettings.ts
Normal file
@ -0,0 +1,67 @@
|
||||
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,
|
||||
|
||||
}
|
||||
|
||||
|
||||
342
src/org/wanxp/constant/DefaultTemplateContent.ts
Normal file
@ -0,0 +1,342 @@
|
||||
import {TemplateKey} from "./Constsant";
|
||||
|
||||
export const DEFAULT_TEMPLATE_CONTENT = {
|
||||
movieTemplateFileContent: `---
|
||||
doubanId: {{id}}
|
||||
title: {{title}}
|
||||
type: {{type}}
|
||||
score: {{score}}
|
||||
scoreStar: {{scoreStar}}
|
||||
originalTitle: {{originalTitle}}
|
||||
genre: {{genre}}
|
||||
datePublished: {{datePublished}}
|
||||
director: {{director}}
|
||||
actor: {{actor}}
|
||||
author: {{author}}
|
||||
tags:
|
||||
- {{type}}
|
||||
url: {{url}}
|
||||
aliases: {{aliases}}
|
||||
country: {{country}}
|
||||
language: {{language}}
|
||||
IMDb: {{IMDb}}
|
||||
time: {{time}}
|
||||
createTime: {{currentDate}} {{currentTime}}
|
||||
desc: {{desc}}
|
||||
---
|
||||
|
||||

|
||||
`,
|
||||
bookTemplateFileContent: `---
|
||||
doubanId: {{id}}
|
||||
title: {{title}}
|
||||
subTitle: {{subTitle}}
|
||||
originalTitle: {{originalTitle}}
|
||||
series: {{series}}
|
||||
type: {{type}}
|
||||
author: {{author}}
|
||||
score: {{score}}
|
||||
scoreStar: {{scoreStar}}
|
||||
datePublished: {{datePublished}}
|
||||
translator: {{translator}}
|
||||
publisher: {{publisher}}
|
||||
producer: {{producer}}
|
||||
isbn: {{isbn}}
|
||||
url: {{url}}
|
||||
totalPage: {{totalPage}}
|
||||
price: {{price}}
|
||||
tags:
|
||||
- {{type}}
|
||||
binding: {{binding}}
|
||||
createTime: {{currentDate}} {{currentTime}}
|
||||
desc: {{desc}}
|
||||
---
|
||||
|
||||

|
||||
|
||||
{{menu}}
|
||||
`,
|
||||
musicTemplateFileContent: `---
|
||||
doubanId: {{id}}
|
||||
title: {{title}}
|
||||
type: {{type}}
|
||||
actor: {{actor}}
|
||||
score: {{score}}
|
||||
scoreStar: {{scoreStar}}
|
||||
genre: {{genre}}
|
||||
medium: {{medium}}
|
||||
albumType: {{albumType}}
|
||||
datePublished: {{datePublished}}
|
||||
publisher: {{publisher}}
|
||||
barcode: {{barcode}}
|
||||
url: {{url}}
|
||||
records: {{records}}
|
||||
tags:
|
||||
- {{type}}
|
||||
createTime: {{currentDate}} {{currentTime}}
|
||||
desc: {{desc}}
|
||||
---
|
||||
|
||||

|
||||
|
||||
---
|
||||
Menu:
|
||||
{{menu}}
|
||||
`,
|
||||
noteTemplateFileContent: `---
|
||||
doubanId: {{id}}
|
||||
title: {{title}}
|
||||
type: {{type}}
|
||||
author: {{author}}
|
||||
authorUrl: {{authorUrl}}
|
||||
dateTimePublished: {{datePublished}} {{timePublished}}
|
||||
url: {{url}}
|
||||
tags:
|
||||
- {{type}}
|
||||
createTime: {{currentDate}} {{currentTime}}
|
||||
desc: {{desc}}
|
||||
---
|
||||
|
||||
{{content}}
|
||||
`,
|
||||
gameTemplateFileContent: `---
|
||||
doubanId: {{id}}
|
||||
title: {{title}}
|
||||
aliases: {{aliases}}
|
||||
type: {{type}}
|
||||
score: {{score}}
|
||||
scoreStar: {{scoreStar}}
|
||||
dateTimePublished: {{datePublished}}
|
||||
publisher: {{publisher}}
|
||||
genre: {{genre}}
|
||||
developer: {{developer}}
|
||||
platform: {{platform}}
|
||||
url: {{url}}
|
||||
tags:
|
||||
- {{type}}
|
||||
createTime: {{currentDate}} {{currentTime}}
|
||||
desc: {{desc}}
|
||||
---
|
||||
|
||||

|
||||
`,teleplayTemplateFileContent: `---
|
||||
doubanId: {{id}}
|
||||
title: {{title}}
|
||||
type: {{type}}
|
||||
score: {{score}}
|
||||
scoreStar: {{scoreStar}}
|
||||
originalTitle: {{originalTitle}}
|
||||
genre: {{genre}}
|
||||
datePublished: {{datePublished}}
|
||||
director: {{director}}
|
||||
actor: {{actor}}
|
||||
author: {{author}}
|
||||
tags:
|
||||
- {{type}}
|
||||
url: {{url}}
|
||||
aliases: {{aliases}}
|
||||
country: {{country}}
|
||||
language: {{language}}
|
||||
IMDb: {{IMDb}}
|
||||
time: {{time}}
|
||||
episode: {{episode}}
|
||||
createTime: {{currentDate}} {{currentTime}}
|
||||
desc: {{desc}}
|
||||
---
|
||||
|
||||

|
||||
`,
|
||||
}
|
||||
|
||||
export const DEFAULT_TEMPLATE_CONTENT_WITH_STATE = {
|
||||
movieTemplateFileContent: `---
|
||||
doubanId: {{id}}
|
||||
title: {{title}}
|
||||
type: {{type}}
|
||||
score: {{score}}
|
||||
scoreStar: {{scoreStar}}
|
||||
myRating: {{myRating}}
|
||||
myRatingStar: {{myRatingStar}}
|
||||
originalTitle: {{originalTitle}}
|
||||
genre: {{genre}}
|
||||
datePublished: {{datePublished}}
|
||||
director: {{director}}
|
||||
actor: {{actor}}
|
||||
author: {{author}}
|
||||
tags: {{myTags}}
|
||||
state: {{myState}}
|
||||
url: {{url}}
|
||||
aliases: {{aliases}}
|
||||
country: {{country}}
|
||||
language: {{language}}
|
||||
IMDb: {{IMDb}}
|
||||
time: {{time}}
|
||||
createTime: {{currentDate}} {{currentTime}}
|
||||
collectionDate: {{myCollectionDate}}
|
||||
desc: {{desc}}
|
||||
---
|
||||
|
||||

|
||||
|
||||
Comment:
|
||||
---
|
||||
{{myComment}}
|
||||
`,
|
||||
bookTemplateFileContent: `---
|
||||
doubanId: {{id}}
|
||||
title: {{title}}
|
||||
subTitle: {{subTitle}}
|
||||
originalTitle: {{originalTitle}}
|
||||
series: {{series}}
|
||||
type: {{type}}
|
||||
author: {{author}}
|
||||
score: {{score}}
|
||||
scoreStar: {{scoreStar}}
|
||||
myRating: {{myRating}}
|
||||
myRatingStar: {{myRatingStar}}
|
||||
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}}
|
||||
---
|
||||
|
||||

|
||||
|
||||
Comment:
|
||||
---
|
||||
{{myComment}}
|
||||
|
||||
{{menu}}
|
||||
`,
|
||||
musicTemplateFileContent: `---
|
||||
doubanId: {{id}}
|
||||
title: {{title}}
|
||||
type: {{type}}
|
||||
actor: {{actor}}
|
||||
score: {{score}}
|
||||
scoreStar: {{scoreStar}}
|
||||
myRating: {{myRating}}
|
||||
myRatingStar: {{myRatingStar}}
|
||||
genre: {{genre}}
|
||||
medium: {{medium}}
|
||||
albumType: {{albumType}}
|
||||
datePublished: {{datePublished}}
|
||||
publisher: {{publisher}}
|
||||
barcode: {{barcode}}
|
||||
url: {{url}}
|
||||
records: {{records}}
|
||||
tags: {{myTags}}
|
||||
state: {{myState}}
|
||||
createTime: {{currentDate}} {{currentTime}}
|
||||
collectionDate: {{myCollectionDate}}
|
||||
desc: {{desc}}
|
||||
---
|
||||
|
||||

|
||||
|
||||
---
|
||||
Menu:
|
||||
{{menu}}
|
||||
|
||||
---
|
||||
Comment:
|
||||
{{myComment}}
|
||||
|
||||
`,
|
||||
noteTemplateFileContent: `---
|
||||
doubanId: {{id}}
|
||||
title: {{title}}
|
||||
type: {{type}}
|
||||
author: {{author}}
|
||||
authorUrl: {{authorUrl}}
|
||||
dateTimePublished: {{datePublished}} {{timePublished}}
|
||||
url: {{url}}
|
||||
tags:
|
||||
- {{type}}
|
||||
createTime: {{currentDate}} {{currentTime}}
|
||||
desc: {{desc}}
|
||||
---
|
||||
|
||||
{{content}}
|
||||
`,
|
||||
gameTemplateFileContent: `---
|
||||
doubanId: {{id}}
|
||||
title: {{title}}
|
||||
aliases: {{aliases}}
|
||||
type: {{type}}
|
||||
score: {{score}}
|
||||
scoreStar: {{scoreStar}}
|
||||
myRating: {{myRating}}
|
||||
myRatingStar: {{myRatingStar}}
|
||||
dateTimePublished: {{datePublished}}
|
||||
publisher: {{publisher}}
|
||||
genre: {{genre}}
|
||||
developer: {{developer}}
|
||||
platform: {{platform}}
|
||||
url: {{url}}
|
||||
tags: {{myTags}}
|
||||
state: {{myState}}
|
||||
createTime: {{currentDate}} {{currentTime}}
|
||||
collectionDate: {{myCollectionDate}}
|
||||
desc: {{desc}}
|
||||
---
|
||||
|
||||

|
||||
|
||||
Comment:
|
||||
---
|
||||
{{myComment}}
|
||||
`,teleplayTemplateFileContent: `---
|
||||
doubanId: {{id}}
|
||||
title: {{title}}
|
||||
type: {{type}}
|
||||
score: {{score}}
|
||||
scoreStar: {{scoreStar}}
|
||||
myRating: {{myRating}}
|
||||
myRatingStar: {{myRatingStar}}
|
||||
originalTitle: {{originalTitle}}
|
||||
genre: {{genre}}
|
||||
datePublished: {{datePublished}}
|
||||
director: {{director}}
|
||||
actor: {{actor}}
|
||||
author: {{author}}
|
||||
tags: {{myTags}}
|
||||
state: {{myState}}
|
||||
url: {{url}}
|
||||
aliases: {{aliases}}
|
||||
country: {{country}}
|
||||
language: {{language}}
|
||||
IMDb: {{IMDb}}
|
||||
time: {{time}}
|
||||
episode: {{episode}}
|
||||
createTime: {{currentDate}} {{currentTime}}
|
||||
collectionDate: {{myCollectionDate}}
|
||||
desc: {{desc}}
|
||||
---
|
||||
|
||||

|
||||
|
||||
Comment:
|
||||
---
|
||||
{{myComment}}
|
||||
`,
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取默认的文档内容
|
||||
* @param key
|
||||
*/
|
||||
export function getDefaultTemplateContent(key: TemplateKey, useStateTemplate: boolean = true): string {
|
||||
// @ts-ignore
|
||||
return useStateTemplate ? DEFAULT_TEMPLATE_CONTENT_WITH_STATE[key + "Content"] : DEFAULT_TEMPLATE_CONTENT[key + "Content"];
|
||||
}
|
||||
16
src/org/wanxp/constant/Douban.ts
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
|
||||
export const doubanHeaders = {
|
||||
"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 doubanSubjectSyncListUrl = function(subjectType:string, userId:string, doType:string, start:number):string {
|
||||
return `https://${subjectType}.douban.com/people/${userId}/${doType}?start=${start}&sort=time&rating=all&filter=all&mode=list`;
|
||||
}
|
||||
|
||||
export const doubanGameSubjectSyncListUrl = function(subjectType:string, userId:string, doType:string, start:number):string {
|
||||
return `https://douban.com/people/${userId}/games?start=${start}&sort=time&rating=all&filter=all&mode=list${doType != 'all' ? '&action='+doType : ''}`;
|
||||
}
|
||||
185
src/org/wanxp/constant/DoubanUserState.ts
Normal file
@ -0,0 +1,185 @@
|
||||
import {i18nHelper} from "../lang/helper";
|
||||
import {SupportType, SyncType} from "./Constsant";
|
||||
|
||||
export enum DoubanSubjectState {
|
||||
not = 'not',
|
||||
wish = 'wish',
|
||||
do = 'do',
|
||||
collect = 'collect',
|
||||
}
|
||||
|
||||
export const DoubanSubjectStateRecords_ALL: { [key in DoubanSubjectState]: string } = {
|
||||
[DoubanSubjectState.not]: i18nHelper.getMessage('500101'),
|
||||
[DoubanSubjectState.wish]: i18nHelper.getMessage('500102'),
|
||||
[DoubanSubjectState.do]: i18nHelper.getMessage('500103'),
|
||||
[DoubanSubjectState.collect]: i18nHelper.getMessage('500104'),
|
||||
}
|
||||
|
||||
export const DoubanSubjectStateRecords_MOVIE: { [key in DoubanSubjectState]: string } = {
|
||||
[DoubanSubjectState.not]: i18nHelper.getMessage('500201'),
|
||||
[DoubanSubjectState.wish]: i18nHelper.getMessage('500202'),
|
||||
[DoubanSubjectState.do]: i18nHelper.getMessage('500203'),
|
||||
[DoubanSubjectState.collect]: i18nHelper.getMessage('500204'),
|
||||
}
|
||||
|
||||
export const DoubanSubjectStateRecords_BOOK: { [key in DoubanSubjectState]: string } = {
|
||||
[DoubanSubjectState.not]: i18nHelper.getMessage('500301'),
|
||||
[DoubanSubjectState.wish]: i18nHelper.getMessage('500302'),
|
||||
[DoubanSubjectState.do]: i18nHelper.getMessage('500303'),
|
||||
[DoubanSubjectState.collect]: i18nHelper.getMessage('500304'),
|
||||
}
|
||||
|
||||
|
||||
export const DoubanSubjectStateRecords_MUSIC: { [key in DoubanSubjectState]: string } = {
|
||||
[DoubanSubjectState.not]: i18nHelper.getMessage('500401'),
|
||||
[DoubanSubjectState.wish]: i18nHelper.getMessage('500402'),
|
||||
[DoubanSubjectState.do]: i18nHelper.getMessage('500403'),
|
||||
[DoubanSubjectState.collect]: i18nHelper.getMessage('500404'),
|
||||
}
|
||||
|
||||
export const DoubanSubjectStateRecords_NOTE: { [key in DoubanSubjectState]: string } = {
|
||||
[DoubanSubjectState.not]: i18nHelper.getMessage('500501'),
|
||||
[DoubanSubjectState.wish]: i18nHelper.getMessage('500502'),
|
||||
[DoubanSubjectState.do]: i18nHelper.getMessage('500503'),
|
||||
[DoubanSubjectState.collect]: i18nHelper.getMessage('500504'),
|
||||
}
|
||||
|
||||
export const DoubanSubjectStateRecords_GAME: { [key in DoubanSubjectState]: string } = {
|
||||
[DoubanSubjectState.not]: i18nHelper.getMessage('500601'),
|
||||
[DoubanSubjectState.wish]: i18nHelper.getMessage('500602'),
|
||||
[DoubanSubjectState.do]: i18nHelper.getMessage('500603'),
|
||||
[DoubanSubjectState.collect]: i18nHelper.getMessage('500604'),
|
||||
}
|
||||
|
||||
export const DoubanSubjectStateRecords_TELEPLAY: { [key in DoubanSubjectState]: string } = {
|
||||
[DoubanSubjectState.not]: i18nHelper.getMessage('500701'),
|
||||
[DoubanSubjectState.wish]: i18nHelper.getMessage('500702'),
|
||||
[DoubanSubjectState.do]: i18nHelper.getMessage('500703'),
|
||||
[DoubanSubjectState.collect]: i18nHelper.getMessage('500704'),
|
||||
}
|
||||
|
||||
export const DoubanSubjectStateRecords_THEATER: { [key in DoubanSubjectState]: string } = {
|
||||
[DoubanSubjectState.not]: i18nHelper.getMessage('500701'),
|
||||
[DoubanSubjectState.wish]: i18nHelper.getMessage('500702'),
|
||||
[DoubanSubjectState.do]: i18nHelper.getMessage('500703'),
|
||||
[DoubanSubjectState.collect]: i18nHelper.getMessage('500704'),
|
||||
}
|
||||
|
||||
export const DoubanSubjectStateRecords: { [key in SupportType]: Record<DoubanSubjectState, string> } = {
|
||||
[SupportType.all]:DoubanSubjectStateRecords_ALL,
|
||||
[SupportType.movie]:DoubanSubjectStateRecords_MOVIE,
|
||||
[SupportType.book]:DoubanSubjectStateRecords_BOOK,
|
||||
[SupportType.music]:DoubanSubjectStateRecords_MUSIC,
|
||||
[SupportType.note]:DoubanSubjectStateRecords_NOTE,
|
||||
[SupportType.game]:DoubanSubjectStateRecords_GAME,
|
||||
[SupportType.teleplay]:DoubanSubjectStateRecords_TELEPLAY,
|
||||
[SupportType.theater]:DoubanSubjectStateRecords_THEATER,
|
||||
|
||||
}
|
||||
|
||||
export const ALL:string = 'ALL';
|
||||
|
||||
// @ts-ignore
|
||||
export const DoubanSubjectStateRecords_MOVIE_SYNC: { [key in DoubanSubjectState]: string } = {
|
||||
// @ts-ignore
|
||||
[ALL]: i18nHelper.getMessage('500004'),
|
||||
[DoubanSubjectState.wish]: i18nHelper.getMessage('500202'),
|
||||
[DoubanSubjectState.do]: i18nHelper.getMessage('500203'),
|
||||
[DoubanSubjectState.collect]: i18nHelper.getMessage('500204'),
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
export const DoubanSubjectStateRecords_TELEPLAY_SYNC: { [key in DoubanSubjectState]: string } = {
|
||||
// @ts-ignore
|
||||
[ALL]: i18nHelper.getMessage('500004'),
|
||||
[DoubanSubjectState.wish]: i18nHelper.getMessage('500202'),
|
||||
[DoubanSubjectState.do]: i18nHelper.getMessage('500203'),
|
||||
[DoubanSubjectState.collect]: i18nHelper.getMessage('500204'),
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
export const DoubanSubjectStateRecords_BOOK_SYNC: { [key in DoubanSubjectState]: string } = {
|
||||
// @ts-ignore
|
||||
[ALL]: i18nHelper.getMessage('500004'),
|
||||
[DoubanSubjectState.wish]: i18nHelper.getMessage('500302'),
|
||||
[DoubanSubjectState.do]: i18nHelper.getMessage('500303'),
|
||||
[DoubanSubjectState.collect]: i18nHelper.getMessage('500304'),
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
export const DoubanSubjectStateRecords_GAME_SYNC: { [key in DoubanSubjectState]: string } = {
|
||||
// @ts-ignore
|
||||
// [ALL]: i18nHelper.getMessage('500004'),
|
||||
[DoubanSubjectState.wish]: i18nHelper.getMessage('500602'),
|
||||
[DoubanSubjectState.do]: i18nHelper.getMessage('500603'),
|
||||
[DoubanSubjectState.collect]: i18nHelper.getMessage('500604'),
|
||||
}
|
||||
|
||||
export const DoubanSubjectStateRecords_BROADCAST_SYNC: { [key :string]: string } = {
|
||||
[ALL]: i18nHelper.getMessage('500004'),
|
||||
}
|
||||
|
||||
export const DoubanSubjectStateRecords_NOTE_SYNC: { [key :string]: string } = {
|
||||
[ALL]: i18nHelper.getMessage('500004'),
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
export const DoubanSubjectStateRecords_MUSIC_SYNC: { [key in DoubanSubjectState]: string } = {
|
||||
// @ts-ignore
|
||||
[ALL]: i18nHelper.getMessage('500004'),
|
||||
[DoubanSubjectState.wish]: i18nHelper.getMessage('500402'),
|
||||
[DoubanSubjectState.do]: i18nHelper.getMessage('500403'),
|
||||
[DoubanSubjectState.collect]: i18nHelper.getMessage('500404'),
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
export const DoubanSubjectStateRecords_SYNC: { [key in SyncType]: Record<DoubanSubjectState, string> } = {
|
||||
[SyncType.movie]:DoubanSubjectStateRecords_MOVIE_SYNC,
|
||||
[SyncType.book]:DoubanSubjectStateRecords_BOOK_SYNC,
|
||||
[SyncType.music]:DoubanSubjectStateRecords_MUSIC_SYNC,
|
||||
// [SyncType.note]:DoubanSubjectStateRecords_NOTE_SYNC,
|
||||
[SyncType.game]:DoubanSubjectStateRecords_GAME_SYNC,
|
||||
[SyncType.teleplay]:DoubanSubjectStateRecords_TELEPLAY_SYNC,
|
||||
// [SyncType.theater]:DoubanSubjectStateRecords_THEATER_SYNC,
|
||||
}
|
||||
|
||||
|
||||
|
||||
export const DoubanSubjectStateRecords_KEY_WORD_TYPE: Map<string, SupportType> = new Map<string, SupportType> (
|
||||
[['我看过这部电视剧', SupportType.teleplay],
|
||||
['我最近看过这部电视剧', SupportType.teleplay],
|
||||
['我想看这部电视剧', SupportType.teleplay],
|
||||
['我在看这部电视剧', SupportType.teleplay],
|
||||
['我最近在看这部电视剧', SupportType.teleplay],
|
||||
|
||||
['我最近看过这部电影', SupportType.movie],
|
||||
['我看过这部电影', SupportType.movie],
|
||||
['我想看这部电影', SupportType.movie],
|
||||
|
||||
['我读过这本书', SupportType.book],
|
||||
['我想读这本书', SupportType.book],
|
||||
['我在读这本书', SupportType.book],
|
||||
['我最近在读这本书', SupportType.book],
|
||||
|
||||
['我最近听过这张唱片', SupportType.music],
|
||||
['我听过这张唱片', SupportType.music],
|
||||
['我想听这张唱片', SupportType.music],
|
||||
['我在听这张唱片', SupportType.music],
|
||||
['我最近在听这张唱片', SupportType.music],
|
||||
|
||||
['我最近玩过这个游戏', SupportType.game],
|
||||
['我玩过这个游戏', SupportType.game],
|
||||
['我想玩这个游戏', SupportType.game],
|
||||
['我在玩这个游戏', SupportType.game],
|
||||
['我最近在玩这个游戏', SupportType.game],
|
||||
|
||||
['我最近看过这部电影', SupportType.movie],
|
||||
['我看过这部电影', SupportType.movie],
|
||||
['我想看这部电影', SupportType.movie],
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,92 @@
|
||||
import {CheerioAPI} from 'cheerio';
|
||||
import DoubanPlugin from "../../../main";
|
||||
import SchemaOrg from "src/org/wanxp/utils/SchemaOrg";
|
||||
import {DataValueType, PropertyName, SupportType} from "../../../constant/Constsant";
|
||||
import {moment} from "obsidian";
|
||||
import {TITLE_ALIASES_SPECIAL_CHAR_REG_G} from "../../../utils/YamlUtil";
|
||||
import {DataField} from "../../../utils/model/DataField";
|
||||
import DoubanAbstractLoadHandler from "../../data/handler/DoubanAbstractLoadHandler";
|
||||
import DoubanTheaterSubject from "../../data/model/DoubanTheaterSubject";
|
||||
import HandleContext from "../../data/model/HandleContext";
|
||||
import DoubanSubject from "../../data/model/DoubanSubject";
|
||||
import {UserStateSubject} from "../../data/model/UserStateSubject";
|
||||
|
||||
export default class DoubanTheaterAiLoadHandler extends DoubanAbstractLoadHandler<DoubanTheaterSubject> {
|
||||
constructor(doubanPlugin: DoubanPlugin) {
|
||||
super(doubanPlugin);
|
||||
}
|
||||
|
||||
getSupportType(): SupportType {
|
||||
return SupportType.theater;
|
||||
}
|
||||
|
||||
getHighQuantityImageUrl(fileName: string): string {
|
||||
return `https://img9.doubanio.com/view/photo/l/public/${fileName}`;
|
||||
}
|
||||
|
||||
getSubjectUrl(id:string):string{
|
||||
return `https://www.douban.com/location/drama/${id}/`;
|
||||
}
|
||||
|
||||
parseVariable(beforeContent: string, variableMap:Map<string, DataField>, extract: DoubanTheaterSubject, context: HandleContext): void {
|
||||
variableMap.set("director", new DataField(
|
||||
"director",
|
||||
DataValueType.array,
|
||||
extract.director,
|
||||
(extract.director || []).map(SchemaOrg.getPersonName).filter(c => c)
|
||||
));
|
||||
|
||||
variableMap.set("actor", new DataField(
|
||||
"actor",
|
||||
DataValueType.array,
|
||||
extract.actor,
|
||||
(extract.actor || []).map(SchemaOrg.getPersonName).filter(c => c)
|
||||
));
|
||||
|
||||
variableMap.set("author", new DataField(
|
||||
"author",
|
||||
DataValueType.array,
|
||||
extract.author,
|
||||
(extract.author || []).map(SchemaOrg.getPersonName).map(name => super.getPersonName(name, context)).filter(c => c)
|
||||
));
|
||||
variableMap.set("aliases", new DataField("aliases", DataValueType.array, extract.aliases,
|
||||
(extract.aliases || []).map(a=>a
|
||||
.trim()
|
||||
// .replace(TITLE_ALIASES_SPECIAL_CHAR_REG_G, '_')
|
||||
// //replase multiple _ to single _
|
||||
// .replace(/_+/g, '_')
|
||||
// .replace(/^_/, '')
|
||||
// .replace(/_$/, '')
|
||||
.replace(/:\s+/g, ':')
|
||||
)));
|
||||
// super.parseAliases(beforeContent, variableMap, extract, context);
|
||||
}
|
||||
|
||||
support(extract: DoubanSubject): boolean {
|
||||
return extract && extract.type && (extract.type.contains("舞台剧") || extract.type.contains("舞剧") || extract.type.contains("Theater") || extract.type.contains("theater"));
|
||||
}
|
||||
|
||||
analysisUser(html: CheerioAPI, context: HandleContext): { data: CheerioAPI, userState: UserStateSubject } {
|
||||
const rate = html('input#n_rating').val();
|
||||
const tagsStr = html('div#interest_sect_level > div.a_stars > span.color_gray').text().trim();
|
||||
const tags = tagsStr ? tagsStr.replace('标签:', '').trim().split(' ') : null;
|
||||
const stateWord = html('#interest_sect_level > h2').text().trim();
|
||||
const collectionDateStr = html('div#interest_sect_level > div.a_stars > span.mr10 > span.collection_date').text().trim();
|
||||
const userState1 = DoubanAbstractLoadHandler.getUserState(stateWord);
|
||||
const component = this.getPropertyValue(html, PropertyName.comment);
|
||||
const userState: UserStateSubject = {
|
||||
tags: tags,
|
||||
rate: rate ? Number(rate) : null,
|
||||
state: userState1,
|
||||
collectionDate: collectionDateStr ? moment(collectionDateStr, 'YYYY-MM-DD').toDate() : null,
|
||||
comment: component
|
||||
}
|
||||
return {data: html, userState: userState};
|
||||
}
|
||||
|
||||
parseSubjectFromHtml(html: CheerioAPI, context: HandleContext): DoubanTheaterSubject {
|
||||
const obj: DoubanTheaterSubject = new DoubanTheaterSubject();
|
||||
obj.id = this.getPropertyValue(html, PropertyName.id);
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
68
src/org/wanxp/douban/component/ConfirmDialogModal.ts
Normal file
@ -0,0 +1,68 @@
|
||||
import {App, ButtonComponent, Modal} from "obsidian";
|
||||
import {i18nHelper} from "../../lang/helper";
|
||||
import {create} from "istanbul-reports";
|
||||
import DoubanPlugin from "../../main";
|
||||
import {logger} from "bs-logger";
|
||||
import {log} from "../../utils/Logutil";
|
||||
|
||||
export class ConfirmDialogModal extends Modal {
|
||||
private promise:Promise<any>;
|
||||
private message:string;
|
||||
private doubanPlugin: DoubanPlugin;
|
||||
|
||||
constructor(doubanPlugin: DoubanPlugin, message:string, promise: Promise<any>) {
|
||||
super(doubanPlugin.app);
|
||||
this.doubanPlugin = doubanPlugin;
|
||||
this.message = message;
|
||||
this.promise = promise;
|
||||
}
|
||||
|
||||
onOpen() {
|
||||
const {contentEl} = this;
|
||||
contentEl.createEl('h3', {text: i18nHelper.getMessage('110152')});
|
||||
contentEl.createEl('p', {text: `${this.message}`});
|
||||
contentEl.createEl('p', {text: i18nHelper.getMessage('125033')});
|
||||
|
||||
const controls = contentEl.createDiv("controls");
|
||||
controls.addClass("obsidian_douban_search_controls")
|
||||
new ButtonComponent(controls)
|
||||
.setButtonText(i18nHelper.getMessage('110152'))
|
||||
.setCta()
|
||||
.onClick(async () => {
|
||||
//临时特殊处理导入文件
|
||||
if (this.message == i18nHelper.getMessage('125046')) {
|
||||
createFileSelectModal(this.doubanPlugin);
|
||||
}else {
|
||||
await this.promise;
|
||||
}
|
||||
this.close();
|
||||
}).setClass( "obsidian_douban_search_button");
|
||||
new ButtonComponent(controls)
|
||||
.setButtonText(i18nHelper.getMessage('110005'))
|
||||
.onClick(() => {
|
||||
this.close();
|
||||
}).setClass( "obsidian_douban_cancel_button");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function createFileSelectModal(doubanPlugin: DoubanPlugin) {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'file';
|
||||
input.accept = '.json';
|
||||
input.multiple = false;
|
||||
input.onchange = async () => {
|
||||
const file = input.files[0];
|
||||
const reader = new FileReader();
|
||||
reader.onload = async () => {
|
||||
const settings:object = JSON.parse(reader.result as string);
|
||||
try {
|
||||
await doubanPlugin.settingsManager.loadAndSaveSettings(settings);
|
||||
}catch (e) {
|
||||
log.error(i18nHelper.getMessage('125043'), e);
|
||||
}
|
||||
log.notice(i18nHelper.getMessage('125044'))
|
||||
};
|
||||
reader.readAsText(file);
|
||||
};
|
||||
input.click();}
|
||||
18
src/org/wanxp/douban/component/DatePickComponent.ts
Normal file
@ -0,0 +1,18 @@
|
||||
/**
|
||||
* 日期选择组件
|
||||
* 继承自 TextComponent
|
||||
*/
|
||||
|
||||
import {TextComponent} from 'obsidian';
|
||||
|
||||
export class DatePickComponent extends TextComponent {
|
||||
constructor(container: HTMLElement, date: Date = new Date()) {
|
||||
super(container);
|
||||
this.inputEl.type = 'date';
|
||||
this.inputEl.value = date.toISOString().substring(0, 10);
|
||||
}
|
||||
|
||||
getValue(): string {
|
||||
return this.inputEl.value;
|
||||
}
|
||||
}
|
||||
83
src/org/wanxp/douban/component/DoubanHumanCheckModel.ts
Normal file
@ -0,0 +1,83 @@
|
||||
import { Notice } from 'obsidian';
|
||||
import { log } from 'src/org/wanxp/utils/Logutil';
|
||||
import {i18nHelper} from "../../lang/helper";
|
||||
import {DoubanSettingTab} from "../setting/DoubanSettingTab";
|
||||
import SettingsManager from "../setting/SettingsManager";
|
||||
import {constructDoubanTokenSettingsUI} from "../setting/LoginSettingsHelper";
|
||||
|
||||
// Credits go to zhaohongxuan's Weread Plugin : https://github.com/zhaohongxuan/obsidian-weread-plugin
|
||||
|
||||
|
||||
export default class DoubanHumanCheckModel {
|
||||
private modal: any;
|
||||
private url:string;
|
||||
constructor(url:string) {
|
||||
this.url = url;
|
||||
const { remote } = require('electron');
|
||||
const { BrowserWindow: RemoteBrowserWindow } = remote;
|
||||
this.modal = new RemoteBrowserWindow({
|
||||
parent: remote.getCurrentWindow(),
|
||||
width: 960,
|
||||
height: 540,
|
||||
show: false
|
||||
});
|
||||
|
||||
this.modal.once('ready-to-show', () => {
|
||||
this.modal.setTitle(i18nHelper.getMessage('100102'));
|
||||
this.modal.show();
|
||||
});
|
||||
|
||||
|
||||
const session = this.modal.webContents.session;
|
||||
const filter = {
|
||||
urls: [this.url]
|
||||
};
|
||||
session.webRequest.onSendHeaders(filter, async (details:any) => {
|
||||
const cookies = details.requestHeaders['Cookie'];
|
||||
const cookieArr = this.parseCookies(cookies);
|
||||
// const wr_name = cookieArr.find((cookie) => cookie.name == 'wr_name').value;
|
||||
if (cookieArr) {
|
||||
this.onClose();
|
||||
} else {
|
||||
this.onReload();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private parseCookies(cookies: any) {
|
||||
return cookies;
|
||||
}
|
||||
|
||||
async load() {
|
||||
try {
|
||||
await this.modal.loadURL(this.url);
|
||||
} catch (error) {
|
||||
log.error(i18nHelper.getMessage('100101'), error)
|
||||
}
|
||||
}
|
||||
|
||||
async loadUrl(url:string) {
|
||||
try {
|
||||
await this.modal.loadURL(url);
|
||||
} catch (error) {
|
||||
log.error(i18nHelper.getMessage('100101'), error)
|
||||
}
|
||||
}
|
||||
|
||||
async loadHtml(html:string) {
|
||||
try {
|
||||
await this.modal.loadURL(`data:text/html;charset=utf-8,${html}`);
|
||||
} catch (error) {
|
||||
log.error(i18nHelper.getMessage('100101'), error)
|
||||
}
|
||||
}
|
||||
|
||||
onClose() {
|
||||
this.modal.close();
|
||||
new Notice(i18nHelper.getMessage('100103'))
|
||||
}
|
||||
|
||||
onReload() {
|
||||
this.modal.reload();
|
||||
}
|
||||
}
|
||||
114
src/org/wanxp/douban/component/DoubanLoginModel.ts
Normal file
@ -0,0 +1,114 @@
|
||||
import { Notice } from 'obsidian';
|
||||
import { log } from 'src/org/wanxp/utils/Logutil';
|
||||
import {i18nHelper} from "../../lang/helper";
|
||||
import {DoubanSettingTab} from "../setting/DoubanSettingTab";
|
||||
import SettingsManager from "../setting/SettingsManager";
|
||||
import {constructDoubanTokenSettingsUI} from "../setting/LoginSettingsHelper";
|
||||
import StringUtil from "../../utils/StringUtil";
|
||||
import {Integer} from "schema-dts";
|
||||
|
||||
// Credits go to zhaohongxuan's Weread Plugin : https://github.com/zhaohongxuan/obsidian-weread-plugin
|
||||
|
||||
|
||||
export default class DoubanLoginModel {
|
||||
private modal: any;
|
||||
private containerEl: HTMLElement;
|
||||
private settingsManager: SettingsManager;
|
||||
constructor(containerEl: HTMLElement, settingsManager: SettingsManager) {
|
||||
this.containerEl = containerEl;
|
||||
this.settingsManager = settingsManager;
|
||||
this.settingsManager.debug(`配置界面:初始化登录界面`)
|
||||
const { remote} = require('electron');
|
||||
|
||||
const { BrowserWindow: RemoteBrowserWindow } = remote;
|
||||
this.modal = new RemoteBrowserWindow({
|
||||
parent: remote.getCurrentWindow(),
|
||||
width: 960,
|
||||
height: 540,
|
||||
show: false
|
||||
});
|
||||
|
||||
this.modal.once('ready-to-show', () => {
|
||||
this.modal.setTitle(i18nHelper.getMessage('100101'));
|
||||
this.modal.show();
|
||||
});
|
||||
this.modal.on('closed', () => {
|
||||
this.showCloseMessage();
|
||||
constructDoubanTokenSettingsUI(this.containerEl, this.settingsManager);
|
||||
});
|
||||
|
||||
this.modal.webContents.on('did-fail-load', (event:Event, errorCode:Integer ) => {
|
||||
// 例如, 当 Ctrl/Cmd are down 被按下,仅开启应用程序菜单键盘快捷键。
|
||||
this.settingsManager.debug('加载失败' + errorCode);
|
||||
})
|
||||
|
||||
this.modal.webContents.on('did-fail-load', (event:Event) => {
|
||||
// 例如, 当 Ctrl/Cmd are down 被按下,仅开启应用程序菜单键盘快捷键。
|
||||
this.settingsManager.debug('加载成功');
|
||||
})
|
||||
|
||||
this.modal.webContents.on('did-navigate', async (_event: any, _url: string, httpResponseCode: number) => {
|
||||
if (httpResponseCode == 403) {
|
||||
// what you want to do
|
||||
this.settingsManager.debug(`配置界面:登录界面,加载页面失败,HttpStatus:${httpResponseCode},URL:${_url}`);
|
||||
await this.modal.loadURL('data:text/html;charset=utf-8;base64,55Sx5LqO5aSa5qyh6aKR57mB6K+35rGC5pWw5o2u77yM6LGG55Oj5b2T5YmN5pqC5pe25LiN5Y+v55SoLiDor7fkuo4xMuWwj+aXtuaIljI05bCP5pe25ZCO5YaN6YeN6K+V77yM5oiW6YeN572u5L2g55qE572R57ucKOWmgumHjeaWsOaLqOWPt+aIluabtOaNoue9kee7nCk=');
|
||||
}else {
|
||||
this.settingsManager.debug(`配置界面:登录界面,加载页面成功,HttpStatus:${httpResponseCode},URL:${_url}`);
|
||||
}
|
||||
});
|
||||
|
||||
const session = this.modal.webContents.session;
|
||||
const filter = {
|
||||
urls: ['https://www.douban.com/']
|
||||
};
|
||||
session.webRequest.onSendHeaders(filter, async (details:any) => {
|
||||
this.settingsManager.debug(`配置界面:登录界面请求头检测:${details.url}`)
|
||||
const headers = details.requestHeaders;
|
||||
if (headers) {
|
||||
this.settingsManager.debug(`配置界面:登录界面请求检测,获取到Cookie`)
|
||||
let user = await settingsManager.plugin.userComponent.loginHeaders(headers);
|
||||
if (user && user.login) {
|
||||
this.settingsManager.debug(`配置界面:登录界面豆瓣登录成功, 信息:id:${StringUtil.confuse(user.id)}:, 用户名:${StringUtil.confuse(user.name)}`)
|
||||
session.clearStorageData(() => {
|
||||
this.settingsManager.debug(`配置界面:登录界面 登录前本地清理缓存成功2`)
|
||||
});
|
||||
this.onClose();
|
||||
return;
|
||||
}
|
||||
this.settingsManager.debug(`配置界面:登录界面豆瓣登录失败, headers未能成功获取用户信息`)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private parseCookies(cookies: any) {
|
||||
return cookies;
|
||||
}
|
||||
|
||||
async doLogin() {
|
||||
try {
|
||||
this.settingsManager.debug(`配置界面:登录界面加载登录页面`)
|
||||
await this.modal.loadURL('https://accounts.douban.com/passport/login');
|
||||
} catch (error) {
|
||||
log.error(i18nHelper.getMessage('100101'), error)
|
||||
}
|
||||
}
|
||||
|
||||
onClose() {
|
||||
this.settingsManager.debug(`配置界面:登录界面关闭, 自动退出登录界面`)
|
||||
// this.modal.destroy();
|
||||
this.modal.close();
|
||||
}
|
||||
|
||||
onReload() {
|
||||
this.settingsManager.debug(`配置界面:登录界面重新加载`)
|
||||
this.modal.reload();
|
||||
}
|
||||
|
||||
private showCloseMessage() {
|
||||
if(this.settingsManager.plugin.userComponent.isLogin()) {
|
||||
this.settingsManager.debug(`配置界面:登录界面关闭, 但未检测到登出, 登录失败`)
|
||||
}else {
|
||||
this.settingsManager.debug(`配置界面:登录界面关闭, 登录成功`)
|
||||
}
|
||||
}
|
||||
}
|
||||
70
src/org/wanxp/douban/component/DoubanLogoutModel.ts
Normal file
@ -0,0 +1,70 @@
|
||||
import {DoubanSettingTab} from "../setting/DoubanSettingTab";
|
||||
import {i18nHelper} from "../../lang/helper";
|
||||
import SettingsManager from "../setting/SettingsManager";
|
||||
import {constructDoubanTokenSettingsUI, constructLoginSettingsUI} from "../setting/LoginSettingsHelper";
|
||||
import {log} from "../../utils/Logutil";
|
||||
|
||||
// Credits go to zhaohongxuan's Weread Plugin : https://github.com/zhaohongxuan/obsidian-weread-plugin
|
||||
|
||||
|
||||
export default class DoubanLogoutModel {
|
||||
private modal: any;
|
||||
private settingsManager: SettingsManager;
|
||||
private containerEl: HTMLElement;
|
||||
constructor(containerEl: HTMLElement, settingsManager: SettingsManager) {
|
||||
this.settingsManager = settingsManager;
|
||||
this.settingsManager.debug(`配置界面:初始化登出界面`)
|
||||
this.containerEl = containerEl;
|
||||
const { remote } = require('electron');
|
||||
const { BrowserWindow: RemoteBrowserWindow } = remote;
|
||||
this.modal = new RemoteBrowserWindow({
|
||||
parent: remote.getCurrentWindow(),
|
||||
width: 960,
|
||||
height: 540,
|
||||
show: false
|
||||
});
|
||||
this.modal.once('ready-to-show', () => {
|
||||
this.modal.setTitle(i18nHelper.getMessage('100101'));
|
||||
this.modal.show();
|
||||
});
|
||||
this.modal.on('closed', () => {
|
||||
this.showCloseMessage();
|
||||
constructDoubanTokenSettingsUI(this.containerEl, this.settingsManager);
|
||||
});
|
||||
const session = this.modal.webContents.session;
|
||||
const filter = {
|
||||
urls: ['https://www.douban.com/',
|
||||
'https://www.douban.com/accounts/logout']
|
||||
};
|
||||
session.webRequest.onSendHeaders(filter, (details:any) => {
|
||||
this.settingsManager.debug(`配置界面:登出界面请求头检测:${details.url}`)
|
||||
const cookies = details.requestHeaders['Cookie'];
|
||||
// const wr_name = cookieArr.find((cookie) => cookie.name == 'wr_name').value;
|
||||
// if (cookies && cookies.indexOf('dbcl2') < 0) {
|
||||
this.settingsManager.debug(`配置界面:登出界面退出登录请求检测成功,准备退出登录`)
|
||||
this.settingsManager.plugin.userComponent.logout();
|
||||
this.settingsManager.debug(`配置界面:登出界面退出登录成功`);
|
||||
this.onClose();
|
||||
// }
|
||||
});
|
||||
}
|
||||
|
||||
async doLogout() {
|
||||
this.settingsManager.debug(`配置界面:登出界面加载登出页面`)
|
||||
await this.modal.loadURL('https://www.douban.com/accounts/logout?source=main&ck=DfFJ');
|
||||
}
|
||||
|
||||
onClose() {
|
||||
this.settingsManager.debug(`配置界面:登出界面关闭, 自动退出登出界面`);
|
||||
// this.modal.destroy();
|
||||
this.modal.close();
|
||||
}
|
||||
|
||||
private showCloseMessage() {
|
||||
if(this.settingsManager.plugin.userComponent.isLogin()) {
|
||||
this.settingsManager.debug(`配置界面:登出界面关闭, 但未检测到登出, 退出登录失败`)
|
||||
}else {
|
||||
this.settingsManager.debug(`配置界面:登出界面关闭, 退出登录成功`)
|
||||
}
|
||||
}
|
||||
}
|
||||
595
src/org/wanxp/douban/component/DoubanSyncModal.ts
Normal file
@ -0,0 +1,595 @@
|
||||
import {
|
||||
App,
|
||||
ButtonComponent, DropdownComponent,
|
||||
Modal, SearchComponent, Setting, TextComponent, ValueComponent,
|
||||
} from "obsidian";
|
||||
|
||||
import DoubanPlugin from "../../main";
|
||||
import {i18nHelper} from "src/org/wanxp/lang/helper";
|
||||
import HandleContext from "../data/model/HandleContext";
|
||||
import {
|
||||
DEFAULT_SETTINGS_ARRAY_INPUT_SIZE,
|
||||
SupportType, SyncConditionType,
|
||||
SyncConditionTypeRecords,
|
||||
SyncType,
|
||||
SyncTypeRecords
|
||||
} from "../../constant/Constsant";
|
||||
import {
|
||||
ALL, DoubanSubjectState, DoubanSubjectStateRecords,
|
||||
DoubanSubjectStateRecords_BOOK_SYNC,
|
||||
DoubanSubjectStateRecords_BROADCAST_SYNC, DoubanSubjectStateRecords_GAME_SYNC,
|
||||
DoubanSubjectStateRecords_MOVIE_SYNC,
|
||||
DoubanSubjectStateRecords_MUSIC_SYNC,
|
||||
DoubanSubjectStateRecords_NOTE_SYNC,
|
||||
DoubanSubjectStateRecords_TELEPLAY_SYNC
|
||||
} from "../../constant/DoubanUserState";
|
||||
import {SyncConfig} from "../sync/model/SyncConfig";
|
||||
import {clearInterval} from "timers";
|
||||
import {FolderSuggest} from "../setting/model/FolderSuggest";
|
||||
import {DEFAULT_SETTINGS} from "../../constant/DefaultSettings";
|
||||
import {createFileSelectionSetting} from "../setting/TemplateSettingHelper";
|
||||
import {FileSuggest} from "../setting/model/FileSuggest";
|
||||
import {getDefaultTemplateContent} from "../../constant/DefaultTemplateContent";
|
||||
import TimeUtil from "../../utils/TimeUtil";
|
||||
import SettingsManager from "../setting/SettingsManager";
|
||||
import {ArraySetting, DEFAULT_SETTINGS_ARRAY_NAME} from "../setting/model/ArraySetting";
|
||||
import {arraySettingDisplay} from "../setting/ArrayDisplayTypeSettingsHelper";
|
||||
import {DatePickComponent} from "./DatePickComponent";
|
||||
import {NumberComponent} from "./NumberComponent";
|
||||
import {log} from "../../utils/Logutil";
|
||||
|
||||
export class DoubanSyncModal extends Modal {
|
||||
plugin: DoubanPlugin;
|
||||
context: HandleContext
|
||||
timer: any;
|
||||
|
||||
constructor(app: App, plugin: DoubanPlugin, context: HandleContext) {
|
||||
super(app);
|
||||
this.plugin = plugin;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
onOpen() {
|
||||
let {contentEl} = this;
|
||||
this.show(contentEl);
|
||||
}
|
||||
|
||||
private show(contentEl: HTMLElement) {
|
||||
contentEl.empty();
|
||||
if (this.plugin.statusHolder.syncing()) {
|
||||
this.showSyncStatus(contentEl);
|
||||
} else {
|
||||
this.showSyncConfig(contentEl);
|
||||
}
|
||||
}
|
||||
|
||||
private showSyncStatus(contentEl: HTMLElement) {
|
||||
const {syncStatus} = this.plugin.statusHolder;
|
||||
const {syncConfig} = syncStatus;
|
||||
contentEl.createEl("h3", {text: i18nHelper.getMessage('500002')});
|
||||
|
||||
this.showConfigPan(contentEl.createDiv('config'), syncConfig, true);
|
||||
|
||||
const sliderDiv = contentEl.createEl('div');
|
||||
sliderDiv.addClass('obsidian_douban_sync_slider');
|
||||
const controls = contentEl.createDiv("controls");
|
||||
|
||||
const stopButton = new ButtonComponent(controls)
|
||||
.setButtonText(i18nHelper.getMessage('110009'))
|
||||
.onClick(async () => {
|
||||
this.close();
|
||||
await this.plugin.statusHolder.stopSync();
|
||||
})
|
||||
|
||||
const backgroundButton = new ButtonComponent(controls)
|
||||
.setButtonText(i18nHelper.getMessage('110010'))
|
||||
.onClick(() => {
|
||||
this.close();
|
||||
});
|
||||
|
||||
this.showProgress(sliderDiv, backgroundButton, stopButton);
|
||||
|
||||
this.timer = setInterval(() => {
|
||||
this.showProgress(sliderDiv,backgroundButton, stopButton);
|
||||
}, 1000);
|
||||
|
||||
backgroundButton.setClass("obsidian_douban_status_button");
|
||||
stopButton.setClass("obsidian_douban_status_button");
|
||||
|
||||
}
|
||||
|
||||
|
||||
private showProgress(sliderDiv: HTMLDivElement, backgroundButton:ButtonComponent, stopButton:ButtonComponent) {
|
||||
sliderDiv.empty();
|
||||
new Setting(sliderDiv);
|
||||
let progress = sliderDiv.createDiv('progress');
|
||||
const {syncStatus} = this.plugin.statusHolder;
|
||||
if (!this.plugin.statusHolder.syncStarted) {
|
||||
progress.innerHTML = `<p>
|
||||
<label for="file">${i18nHelper.getMessage('110033')}</label>
|
||||
<progress class="obsidian_douban_sync_slider" max="${syncStatus.getTotal() == 0 ? 1:syncStatus.getTotal()}" value="${syncStatus.getHasHandle()}"> </progress> <span> ${syncStatus.getHasHandle()}/${syncStatus.getTotal()}:${i18nHelper.getMessage('110036')} </span>
|
||||
</p>
|
||||
<p>
|
||||
<label for="file">${i18nHelper.getMessage('110092')}</label>
|
||||
<span>${i18nHelper.getMessage('110090', syncStatus.getTypeName(), syncStatus.getScopeName(), syncStatus.getAllTotal(), syncStatus.getTotal())}</span>
|
||||
</p>
|
||||
<p>
|
||||
<label for="file">${i18nHelper.getMessage('110091')}</label>
|
||||
<span>${syncStatus.getMessage()}</span>
|
||||
</p>
|
||||
`
|
||||
backgroundButton.setDisabled(true);
|
||||
stopButton.setButtonText(i18nHelper.getMessage('110036'))
|
||||
return;
|
||||
}
|
||||
progress.innerHTML = `<p>
|
||||
<label for="file">${i18nHelper.getMessage('110033')}</label>
|
||||
<progress class="obsidian_douban_sync_slider" max="${syncStatus.getTotal() == 0 ? 1:syncStatus.getTotal()}" value="${syncStatus.getHasHandle()}"> </progress> <span> ${syncStatus.getTotal() == 0 ? i18nHelper.getMessage('110043') : syncStatus.getHasHandle() + '/' + syncStatus.getTotal()}
|
||||
${syncStatus.getHandle() == 0? '...' : i18nHelper.getMessage('110042') + ':' + TimeUtil.estimateTimeMsg(syncStatus.getNeedHandled()-syncStatus.getHandle(), syncStatus.getOverSize())} </span>
|
||||
</p>
|
||||
<p>
|
||||
<label for="file">${i18nHelper.getMessage('110092')}</label>
|
||||
<span>${i18nHelper.getMessage('110090', syncStatus.getTypeName(), syncStatus.getScopeName(), syncStatus.getAllTotal(), syncStatus.getTotal())}</span>
|
||||
</p>
|
||||
<p>
|
||||
<label for="file">${i18nHelper.getMessage('110091')}</label>
|
||||
<span>${syncStatus.getMessage()}</span>
|
||||
</p>
|
||||
`}
|
||||
|
||||
private showSyncConfig(contentEl: HTMLElement) {
|
||||
if (this.timer != null) {
|
||||
clearInterval(this.timer)
|
||||
}
|
||||
contentEl.createEl("h3", {text: i18nHelper.getMessage('500001')});
|
||||
const {settings} = this.plugin;
|
||||
let syncConfig:SyncConfig = {syncType: SyncType.movie, scope: ALL,
|
||||
force: false,
|
||||
dataFilePath: (settings.dataFilePath == '' || settings.dataFilePath == null) ? DEFAULT_SETTINGS.dataFilePath : settings.dataFilePath,
|
||||
dataFileNamePath: (settings.dataFileNamePath == '' || settings.dataFileNamePath == null) ? DEFAULT_SETTINGS.dataFileNamePath : settings.dataFileNamePath,
|
||||
cacheImage: ( settings.cacheImage == null) ? DEFAULT_SETTINGS.cacheImage : settings.cacheImage,
|
||||
cacheHighQuantityImage: ( settings.cacheHighQuantityImage == null) ? DEFAULT_SETTINGS.cacheHighQuantityImage : settings.cacheHighQuantityImage,
|
||||
attachmentPath: (settings.attachmentPath == '' || settings.attachmentPath == null) ? DEFAULT_SETTINGS.attachmentPath : settings.attachmentPath,
|
||||
attachmentFileName: (settings.attachmentFileName == '' || settings.attachmentFileName == null) ? DEFAULT_SETTINGS.attachmentFileName : settings.attachmentFileName,
|
||||
templateFile: (settings.movieTemplateFile == '' || settings.movieTemplateFile == null) ? DEFAULT_SETTINGS.movieTemplateFile : settings.movieTemplateFile,
|
||||
incrementalUpdate: true,
|
||||
syncConditionType: SyncConditionType.ALL,
|
||||
syncConditionDateFromValue: TimeUtil.getLastMonth(),
|
||||
syncConditionDateToValue: new Date(),
|
||||
syncConditionCountFromValue: 1,
|
||||
syncConditionCountToValue: 30
|
||||
};
|
||||
this.showConfigPan(contentEl.createDiv('config'), syncConfig, false);
|
||||
const controls = contentEl.createDiv("controls");
|
||||
const cancelButton = new ButtonComponent(controls)
|
||||
.setButtonText(i18nHelper.getMessage('110005'))
|
||||
.onClick(() => {
|
||||
this.close();
|
||||
});
|
||||
const syncButton = new ButtonComponent(controls)
|
||||
.setButtonText(i18nHelper.getMessage('110007'))
|
||||
.onClick(async () => {
|
||||
if(!await this.plugin.checkLogin(this.context)) {
|
||||
return;
|
||||
}
|
||||
syncButton.setDisabled(true);
|
||||
if(!this.plugin.statusHolder.startSync(syncConfig)) {
|
||||
return;
|
||||
}
|
||||
this.updateContextByConfig(syncConfig);
|
||||
this.show(contentEl);
|
||||
await this.plugin.sync(this.context);
|
||||
})
|
||||
|
||||
|
||||
syncButton.setClass("obsidian_douban_search_button");
|
||||
cancelButton.setClass("obsidian_douban_search_button");
|
||||
|
||||
}
|
||||
|
||||
private updateContextByConfig(syncConfig: SyncConfig) {
|
||||
const { context} = this;
|
||||
context.syncConfig = syncConfig;
|
||||
context.syncActive = true;
|
||||
}
|
||||
|
||||
private showConfigPan(contentEl: HTMLElement, config:SyncConfig, disable:boolean) {
|
||||
new Setting(contentEl);
|
||||
this.showTypeDropdown(contentEl, config, disable);
|
||||
this.showCondition(contentEl, config, disable);
|
||||
// this.showOutputFolderSelections(contentEl, config, disable);
|
||||
// this.showOutiFleName(contentEl, config, disable);
|
||||
// this.showAttachmentsFileConfig(contentEl, config, disable);
|
||||
this.showUpdateAllConfig(contentEl, config, disable);
|
||||
this.showForceUpdateConfig(contentEl, config, disable);
|
||||
}
|
||||
|
||||
async onClose() {
|
||||
let {contentEl} = this;
|
||||
contentEl.empty();
|
||||
if (this.timer != null) {
|
||||
clearInterval(this.timer);
|
||||
}
|
||||
}
|
||||
|
||||
private openScopeDropdown(contentEl:HTMLDivElement, config: SyncConfig, disable:boolean) {
|
||||
switch (config.syncType) {
|
||||
case SyncType.movie:
|
||||
this.showScopeDropdown(contentEl, DoubanSubjectStateRecords_MOVIE_SYNC, config, disable);
|
||||
break;
|
||||
case SyncType.book:
|
||||
this.showScopeDropdown(contentEl, DoubanSubjectStateRecords_BOOK_SYNC, config, disable);
|
||||
break;
|
||||
case SyncType.broadcast:
|
||||
this.showScopeDropdown(contentEl, DoubanSubjectStateRecords_BROADCAST_SYNC, config, disable);
|
||||
break;
|
||||
case SyncType.note:
|
||||
this.showScopeDropdown(contentEl, DoubanSubjectStateRecords_NOTE_SYNC, config, disable);
|
||||
break;
|
||||
case SyncType.music:
|
||||
this.showScopeDropdown(contentEl, DoubanSubjectStateRecords_MUSIC_SYNC, config, disable);
|
||||
break;
|
||||
case SyncType.teleplay:
|
||||
this.showScopeDropdown(contentEl, DoubanSubjectStateRecords_TELEPLAY_SYNC, config, disable);
|
||||
break;
|
||||
case SyncType.game:
|
||||
config.scope = DoubanSubjectState.collect;
|
||||
this.showScopeDropdown(contentEl, DoubanSubjectStateRecords_GAME_SYNC, config, disable);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private showTypeDropdown(containerEl:HTMLElement, config: SyncConfig, disable:boolean) {
|
||||
const settings = new Setting(containerEl);
|
||||
const scopeSelections = containerEl.createDiv("scope-selection");
|
||||
// const templateFile:HTMLDivElement = containerEl.createDiv('template-file-path-selection');
|
||||
settings
|
||||
.setName(i18nHelper.getMessage('110030'))
|
||||
.addDropdown((dropdown) => {
|
||||
dropdown.addOptions(SyncTypeRecords)
|
||||
.setValue(config.syncType)
|
||||
.onChange((value) => {
|
||||
config.syncType = value;
|
||||
config.templateFile = this.getDefaultTemplatePath(value);
|
||||
this.openScopeDropdown(scopeSelections, config, disable);
|
||||
// this.showTemplateFileSelectionSetting(templateFile, config, disable);
|
||||
});
|
||||
}).setDisabled(disable);
|
||||
this.openScopeDropdown(scopeSelections, config, disable);
|
||||
// this.showTemplateFileSelectionSetting(templateFile, config, disable);
|
||||
}
|
||||
|
||||
private getDefaultTemplatePath(value: string) {
|
||||
let result:string = "";
|
||||
const {settings} = this.plugin;
|
||||
switch (value) {
|
||||
case SyncType.movie:
|
||||
result = (settings.movieTemplateFile == '' || settings.movieTemplateFile == null) ? DEFAULT_SETTINGS.movieTemplateFile : settings.movieTemplateFile
|
||||
break;
|
||||
case SyncType.book:
|
||||
result = (settings.bookTemplateFile == '' || settings.bookTemplateFile == null) ? DEFAULT_SETTINGS.bookTemplateFile : settings.bookTemplateFile
|
||||
break;
|
||||
case SyncType.music:
|
||||
result = (settings.musicTemplateFile == '' || settings.musicTemplateFile == null) ? DEFAULT_SETTINGS.musicTemplateFile : settings.musicTemplateFile
|
||||
break;
|
||||
case SyncType.teleplay:
|
||||
result = (settings.teleplayTemplateFile == '' || settings.teleplayTemplateFile == null) ? DEFAULT_SETTINGS.teleplayTemplateFile : settings.teleplayTemplateFile
|
||||
break;
|
||||
case SyncType.game:
|
||||
result = (settings.gameTemplateFile == '' || settings.gameTemplateFile == null) ? DEFAULT_SETTINGS.gameTemplateFile : settings.gameTemplateFile
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private showScopeDropdown(containerEl:HTMLDivElement, scopeSelections: Record<string, string>, config: SyncConfig, disable:boolean) {
|
||||
containerEl.empty();
|
||||
new Setting(containerEl)
|
||||
.setName(i18nHelper.getMessage('110032'))
|
||||
.addDropdown((dropdown) => {
|
||||
dropdown.addOptions(scopeSelections)
|
||||
dropdown.setValue(config.scope)
|
||||
.onChange(async (value: string) => {
|
||||
config.scope = value;
|
||||
});
|
||||
}).setDisabled(disable);
|
||||
}
|
||||
|
||||
private showOutiFleName(containerEl: HTMLElement, config: SyncConfig, disable:boolean) {
|
||||
const dataFilePathSetting = new Setting(containerEl)
|
||||
.setName(i18nHelper.getMessage('121601'))
|
||||
.setDesc(i18nHelper.getMessage('121602'))
|
||||
.addText((textField) => {
|
||||
textField.setPlaceholder(i18nHelper.getMessage('121602'))
|
||||
.setValue(config.dataFileNamePath)
|
||||
.onChange(async (value) => {
|
||||
config.dataFileNamePath = value
|
||||
});
|
||||
})
|
||||
.setDisabled(disable);
|
||||
}
|
||||
|
||||
showOutputFolderSelections(containerEl: HTMLElement, config: SyncConfig, disable:boolean) {
|
||||
new Setting(containerEl)
|
||||
.setName( i18nHelper.getMessage('121501'))
|
||||
.setDesc( i18nHelper.getMessage('121502'))
|
||||
.addSearch(async (search: SearchComponent) => {
|
||||
new FolderSuggest(this.app, search.inputEl);
|
||||
// @ts-ignore
|
||||
search.setValue(config.dataFilePath)
|
||||
// @ts-ignore
|
||||
.setPlaceholder(i18nHelper.getMessage('121503'))
|
||||
.onChange(async (value: string) => {
|
||||
config.dataFilePath = value;
|
||||
});
|
||||
})
|
||||
.setDisabled(disable);
|
||||
}
|
||||
|
||||
showTemplateFileSelectionSetting(containerEl: HTMLElement, config: SyncConfig, disable:boolean) {
|
||||
containerEl.empty();
|
||||
const key:string = this.getKey(config.syncType);
|
||||
// @ts-ignore
|
||||
let setting = new Setting(containerEl)
|
||||
.setName(i18nHelper.getMessage('121101'))
|
||||
.setDesc(i18nHelper.getMessage('121102'))
|
||||
.addSearch(async (search: SearchComponent) => {
|
||||
new FileSuggest(this.app, search.inputEl);
|
||||
// @ts-ignore
|
||||
search.setValue(config.templateFile)
|
||||
// @ts-ignore
|
||||
.onChange(async (value: string) => {
|
||||
config.templateFile = value;
|
||||
});
|
||||
})
|
||||
.setDisabled(disable);
|
||||
|
||||
setting.addExtraButton((button) => {
|
||||
button
|
||||
.setIcon('copy')
|
||||
.setTooltip(i18nHelper.getMessage('121903'))
|
||||
.onClick(async () => {
|
||||
// @ts-ignore
|
||||
navigator.clipboard.writeText(getDefaultTemplateContent(key));
|
||||
});
|
||||
});
|
||||
setting.addExtraButton((button) => {
|
||||
button
|
||||
.setIcon('document')
|
||||
.setTooltip(i18nHelper.getMessage('121901'))
|
||||
.onClick(async () => {
|
||||
// @ts-ignore
|
||||
navigator.clipboard.writeText(getDefaultTemplateContent(key, false))
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private getKey(supportType: string) {
|
||||
return supportType + 'TemplateFile';
|
||||
}
|
||||
|
||||
showForceUpdateConfig(containerEl: HTMLElement, config: SyncConfig, disable:boolean) {
|
||||
new Setting(containerEl)
|
||||
.setName(i18nHelper.getMessage('110031'))
|
||||
.setDesc(i18nHelper.getMessage('500110'))
|
||||
.addToggle((toggleComponent) => {
|
||||
toggleComponent
|
||||
// .setTooltip(i18nHelper.getMessage('121403'))
|
||||
.setValue(config.force)
|
||||
.onChange(async (value) => {
|
||||
config.force = value;
|
||||
});
|
||||
})
|
||||
.setDisabled(disable);
|
||||
}
|
||||
|
||||
|
||||
|
||||
showAttachmentsFileConfig(containerEl: HTMLElement, config: SyncConfig, disable:boolean) {
|
||||
const settings = new Setting(containerEl);
|
||||
let attachmentFileEl = containerEl.createDiv('attachment-file-path-selection');
|
||||
settings.setName(i18nHelper.getMessage('121430'))
|
||||
.setDesc(i18nHelper.getMessage('121431'))
|
||||
.addToggle((toggleComponent) => {
|
||||
toggleComponent
|
||||
// .setTooltip(i18nHelper.getMessage('121403'))
|
||||
.setValue(config.cacheImage)
|
||||
.onChange(async (value) => {
|
||||
config.cacheImage = value;
|
||||
this.showAttachmentPathSelections(value, attachmentFileEl, config, disable);
|
||||
});
|
||||
})
|
||||
.setDisabled(disable);
|
||||
this.showAttachmentPathSelections(config.cacheImage, attachmentFileEl, config, disable);
|
||||
}
|
||||
|
||||
showAttachmentPathSelections(show:boolean, containerEl: HTMLElement, config: SyncConfig, disable:boolean) {
|
||||
containerEl.empty();
|
||||
if (!show) {
|
||||
return;
|
||||
}
|
||||
new Setting(containerEl)
|
||||
.setName( i18nHelper.getMessage('121432'))
|
||||
.setDesc( i18nHelper.getMessage('121433'))
|
||||
.addSearch(async (search: SearchComponent) => {
|
||||
new FolderSuggest(this.plugin.app, search.inputEl);
|
||||
// @ts-ignore
|
||||
search.setValue(config.attachmentPath)
|
||||
// @ts-ignore
|
||||
.setPlaceholder(i18nHelper.getMessage('121434'))
|
||||
.onChange(async (value: string) => {
|
||||
config.attachmentPath = value;
|
||||
});
|
||||
})
|
||||
.setDisabled(disable);
|
||||
new Setting(containerEl)
|
||||
.setName( i18nHelper.getMessage('121452'))
|
||||
.setDesc( i18nHelper.getMessage('121453'))
|
||||
.addSearch(async (search: SearchComponent) => {
|
||||
new FolderSuggest(this.plugin.app, search.inputEl);
|
||||
// @ts-ignore
|
||||
search.setValue(config.attachmentFileName)
|
||||
// @ts-ignore
|
||||
.setPlaceholder(i18nHelper.getMessage('121454'))
|
||||
.onChange(async (value: string) => {
|
||||
config.attachmentFileName = value;
|
||||
});
|
||||
})
|
||||
.setDisabled(disable);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName(i18nHelper.getMessage('121435'))
|
||||
.setDesc(i18nHelper.getMessage('121438'))
|
||||
.addToggle((toggleComponent) => {
|
||||
toggleComponent
|
||||
.setValue(config.cacheHighQuantityImage)
|
||||
.onChange(async (value) => {
|
||||
config.cacheHighQuantityImage = value;
|
||||
});
|
||||
})
|
||||
.setDisabled(disable);
|
||||
}
|
||||
|
||||
showUpdateAllConfig(containerEl: HTMLElement, config: SyncConfig, disable:boolean) {
|
||||
new Setting(containerEl)
|
||||
.setName(i18nHelper.getMessage('110039'))
|
||||
.setDesc(i18nHelper.getMessage('110040'))
|
||||
.addToggle((toggleComponent) => {
|
||||
toggleComponent
|
||||
.setTooltip(i18nHelper.getMessage('110040'))
|
||||
.setValue(config.incrementalUpdate)
|
||||
.onChange(async (value) => {
|
||||
config.incrementalUpdate = value;
|
||||
});
|
||||
})
|
||||
.setDisabled(disable);
|
||||
}
|
||||
|
||||
private showCondition(contentEl: HTMLElement, config: SyncConfig, disable: boolean) {
|
||||
showConditionItem(contentEl.createDiv("sync-douban-condition"), this.plugin.settingsManager, config, disable);
|
||||
}
|
||||
}
|
||||
|
||||
function showConditionItem(containerEl: HTMLElement, manager: SettingsManager, config: SyncConfig, disable: boolean) {
|
||||
containerEl.empty();
|
||||
const condition = new Setting(containerEl).setName(i18nHelper.getMessage('110070'))
|
||||
|
||||
const conditionDesc = condition.descEl.createDiv('sync-douban-condition-desc');
|
||||
new DropdownComponent(conditionDesc).addOptions(SyncConditionTypeRecords)
|
||||
.setValue(config.syncConditionType)
|
||||
.onChange((value) => {
|
||||
config.syncConditionType = value;
|
||||
showConditionItem(containerEl, manager, config, disable);
|
||||
}).setDisabled(disable);
|
||||
showConditionItemInput(conditionDesc, config, disable);
|
||||
}
|
||||
|
||||
function showConditionItemInput(containerEl: HTMLElement, config: SyncConfig, disable: boolean) {
|
||||
if (config.syncConditionType == SyncConditionType.CUSTOM_ITEM) {
|
||||
showCustomInputCount(containerEl, config, disable);
|
||||
}else if (config.syncConditionType == SyncConditionType.CUSTOM_TIME) {
|
||||
showCustomInputTime(containerEl, config, disable);
|
||||
}
|
||||
}
|
||||
|
||||
function showCustomInputCount(containerEl: HTMLElement, config: SyncConfig, disable: boolean) {
|
||||
containerEl.createEl('span', { text: ' ' })
|
||||
containerEl.createEl('span', { text: i18nHelper.getMessage('110077') })
|
||||
containerEl.createEl('span', { text: i18nHelper.getMessage('110078') })
|
||||
const fromField = new TextComponent(containerEl);
|
||||
fromField.setPlaceholder(i18nHelper.getMessage('110080'))
|
||||
.setValue(config.syncConditionCountFromValue + '')
|
||||
.onChange(async (value) => {
|
||||
if (!value) {
|
||||
config.syncConditionCountFromValue = 1;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
config.syncConditionCountFromValue = parseInt(value);
|
||||
}catch (e) {
|
||||
log.notice(i18nHelper.getMessage('112080'))
|
||||
}
|
||||
}).setDisabled(disable);
|
||||
let fromEl = fromField.inputEl;
|
||||
fromEl.addClass('obsidian_douban_settings_input')
|
||||
fromEl.style.width ='20%';
|
||||
containerEl.appendChild(fromEl);
|
||||
const lang = window.localStorage.getItem('language');
|
||||
if (lang == 'zh') {
|
||||
containerEl.createEl('span', {text: i18nHelper.getMessage('110073')})
|
||||
}
|
||||
|
||||
containerEl.createEl('span', { text: i18nHelper.getMessage('110079') })
|
||||
containerEl.createEl('span', { text: i18nHelper.getMessage('110078') })
|
||||
const toField = new TextComponent(containerEl);
|
||||
toField.setPlaceholder(i18nHelper.getMessage('110080'))
|
||||
.setValue(config.syncConditionCountToValue + '')
|
||||
.onChange(async (value) => {
|
||||
if (!value) {
|
||||
config.syncConditionCountToValue = 30;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
config.syncConditionCountToValue = parseInt(value);
|
||||
}catch (e) {
|
||||
log.notice(i18nHelper.getMessage('112080'))
|
||||
}
|
||||
}).setDisabled(disable);
|
||||
let toEl = toField.inputEl;
|
||||
toEl.addClass('obsidian_douban_settings_input')
|
||||
toEl.style.width ='20%';
|
||||
containerEl.appendChild(toEl);
|
||||
if (lang == 'zh') {
|
||||
containerEl.createEl('span', {text: i18nHelper.getMessage('110073')})
|
||||
}
|
||||
containerEl.createEl('span', {text: ' '})
|
||||
const buttopn = new ButtonComponent(containerEl).setIcon('help').setTooltip(i18nHelper.getMessage('110095'))
|
||||
containerEl.appendChild(buttopn.buttonEl);
|
||||
}
|
||||
|
||||
function showCustomInputTime(containerEl: HTMLElement, config: SyncConfig, disable: boolean) {
|
||||
containerEl.createEl('span', { text: i18nHelper.getMessage('110077') })
|
||||
const fromDateField = new TextComponent(containerEl);
|
||||
const fromDateEl = fromDateField.inputEl;
|
||||
fromDateEl.type = 'date';
|
||||
fromDateEl.value = config.syncConditionDateFromValue ? config.syncConditionDateFromValue.toISOString().substring(0, 10) : TimeUtil.getLastMonth().toISOString().substring(0, 10);
|
||||
fromDateField.setPlaceholder(i18nHelper.getMessage('110075'))
|
||||
.setValue(config.syncConditionDateFromValue ? config.syncConditionDateFromValue.toISOString().substring(0, 10) : TimeUtil.getLastMonth().toISOString().substring(0, 10))
|
||||
.onChange(async (value) => {
|
||||
if (!value) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
config.syncConditionDateFromValue = new Date(value);
|
||||
}catch (e) {
|
||||
log.notice(i18nHelper.getMessage('110082'))
|
||||
}
|
||||
}).setDisabled(disable);
|
||||
fromDateEl.addClass('obsidian_douban_settings_input')
|
||||
containerEl.appendChild(fromDateEl);
|
||||
|
||||
containerEl.createEl('span', { text: i18nHelper.getMessage('110079') })
|
||||
const toDateField = new TextComponent(containerEl);
|
||||
let toDateEl = toDateField.inputEl;
|
||||
toDateEl.type = 'date';
|
||||
toDateEl.value = config.syncConditionDateToValue ? config.syncConditionDateToValue.toISOString().substring(0, 10) : new Date().toISOString().substring(0, 10);
|
||||
toDateField.setPlaceholder(i18nHelper.getMessage('110075'))
|
||||
.setValue(config.syncConditionDateToValue ? config.syncConditionDateToValue.toISOString().substring(0, 10) : new Date().toISOString().substring(0, 10))
|
||||
.onChange(async (value) => {
|
||||
if (!value) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
config.syncConditionDateToValue = new Date(value);
|
||||
}catch (e) {
|
||||
log.notice(i18nHelper.getMessage('110082'))
|
||||
}
|
||||
}).setDisabled(disable);
|
||||
toDateEl.addClass('obsidian_douban_settings_input')
|
||||
containerEl.appendChild(toDateEl);
|
||||
new ButtonComponent(containerEl).setIcon('help').setTooltip(i18nHelper.getMessage('110095'))
|
||||
|
||||
}
|
||||
26
src/org/wanxp/douban/component/NumberComponent.ts
Normal file
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* 日期选择组件
|
||||
* 继承自 TextComponent
|
||||
*/
|
||||
|
||||
import {TextComponent} from 'obsidian';
|
||||
|
||||
export class NumberComponent extends TextComponent {
|
||||
constructor(container: HTMLElement, value: number = 0) {
|
||||
super(container);
|
||||
this.inputEl.type = 'date';
|
||||
this.inputEl.value = value.toString();
|
||||
}
|
||||
|
||||
getValue(): string {
|
||||
return this.inputEl.value;
|
||||
}
|
||||
|
||||
//当输入框输入的内容不是数字时,则回退到之前的值
|
||||
// onChanged() {
|
||||
// if (isNaN(Number(this.inputEl.value))) {
|
||||
// this.inputEl.value = this.inputEl.value.slice(0, -1);
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
659
src/org/wanxp/douban/data/handler/DoubanAbstractLoadHandler.ts
Normal file
@ -0,0 +1,659 @@
|
||||
import DoubanPlugin from "../../../main";
|
||||
import DoubanSubject, {DoubanParameterName} from '../model/DoubanSubject';
|
||||
import DoubanSubjectLoadHandler from "./DoubanSubjectLoadHandler";
|
||||
import {moment, Platform, TFile} from "obsidian";
|
||||
import {i18nHelper} from 'src/org/wanxp/lang/helper';
|
||||
import {log} from "src/org/wanxp/utils/Logutil";
|
||||
import {CheerioAPI, load} from "cheerio";
|
||||
import YamlUtil, {TITLE_ALIASES_SPECIAL_CHAR_REG_G} from "../../../utils/YamlUtil";
|
||||
import {
|
||||
BasicConst,
|
||||
DataValueType,
|
||||
PersonNameMode,
|
||||
PropertyName,
|
||||
SearchHandleMode,
|
||||
SupportType,
|
||||
TemplateKey,
|
||||
TemplateTextMode
|
||||
} from "../../../constant/Constsant";
|
||||
import HandleContext from "../model/HandleContext";
|
||||
import HandleResult from "../model/HandleResult";
|
||||
import {getDefaultTemplateContent} from "../../../constant/DefaultTemplateContent";
|
||||
import StringUtil from "../../../utils/StringUtil";
|
||||
import {DEFAULT_SETTINGS} from "../../../constant/DefaultSettings";
|
||||
import {DoubanUserParameter, DoubanUserParameterName, UserStateSubject} from "../model/UserStateSubject";
|
||||
import {
|
||||
DoubanSubjectState,
|
||||
DoubanSubjectStateRecords,
|
||||
DoubanSubjectStateRecords_KEY_WORD_TYPE
|
||||
} from "../../../constant/DoubanUserState";
|
||||
import {Person} from "schema-dts";
|
||||
import HttpUtil from "../../../utils/HttpUtil";
|
||||
import HtmlUtil from "../../../utils/HtmlUtil";
|
||||
import {VariableUtil} from "../../../utils/VariableUtil";
|
||||
import {DataField} from "../../../utils/model/DataField";
|
||||
import NumberUtil from "../../../utils/NumberUtil";
|
||||
import {DoubanHttpUtil} from "../../../utils/DoubanHttpUtil";
|
||||
import {logger} from "bs-logger";
|
||||
|
||||
export default abstract class DoubanAbstractLoadHandler<T extends DoubanSubject> implements DoubanSubjectLoadHandler<T> {
|
||||
|
||||
|
||||
public doubanPlugin: DoubanPlugin;
|
||||
|
||||
constructor(doubanPlugin: DoubanPlugin) {
|
||||
this.doubanPlugin = doubanPlugin;
|
||||
}
|
||||
|
||||
async parse(extract: T, context: HandleContext): Promise<HandleResult> {
|
||||
const template: string = await this.getTemplate(extract, context);
|
||||
const variableMap = this.buildVariableMap(extract, context);
|
||||
this.parseUserInfo(template, variableMap, extract, context);
|
||||
this.parseVariable(template, variableMap, extract, context);
|
||||
await this.saveImage(extract, context, variableMap);
|
||||
|
||||
const frontMatterStart: number = template.indexOf(BasicConst.YAML_FRONT_MATTER_SYMBOL, 0);
|
||||
const frontMatterEnd: number = template.indexOf(BasicConst.YAML_FRONT_MATTER_SYMBOL, frontMatterStart + 1);
|
||||
let frontMatter = '';
|
||||
let frontMatterBefore = '';
|
||||
let frontMatterAfter = '';
|
||||
let result = '';
|
||||
|
||||
if (frontMatterStart > -1 && frontMatterEnd > -1) {
|
||||
frontMatterBefore = template.substring(0, frontMatterStart);
|
||||
frontMatter = template.substring(frontMatterStart, frontMatterEnd + 3);
|
||||
frontMatterAfter = template.substring(frontMatterEnd + 3);
|
||||
if (frontMatterBefore.length > 0) {
|
||||
frontMatterBefore = this.parsePartText(frontMatterBefore, extract, context, variableMap);
|
||||
}
|
||||
if (frontMatterAfter.length > 0) {
|
||||
frontMatterAfter = this.parsePartText(frontMatterAfter, extract, context, variableMap);
|
||||
}
|
||||
if (frontMatter.length > 0) {
|
||||
frontMatter = this.parsePartYml(frontMatter, extract, context, variableMap);
|
||||
}
|
||||
result = frontMatterBefore + frontMatter + frontMatterAfter;
|
||||
} else {
|
||||
result = this.parsePartText(template, extract, context, variableMap);
|
||||
}
|
||||
let filePath = '';
|
||||
if (SearchHandleMode.FOR_CREATE == context.mode) {
|
||||
filePath = this.parsePartPath(this.getFilePath(context), extract, context, variableMap);
|
||||
}
|
||||
let fileName = '';
|
||||
if (SearchHandleMode.FOR_CREATE == context.mode) {
|
||||
fileName = this.parsePartPath(this.getFileName(context), extract, context, variableMap);
|
||||
}
|
||||
return {content: result,filePath: filePath, fileName: fileName, subject:extract};
|
||||
}
|
||||
|
||||
private getFileName(context: HandleContext): string {
|
||||
const {syncConfig} = context;
|
||||
if (syncConfig) {
|
||||
return syncConfig.dataFileNamePath;
|
||||
}
|
||||
const {dataFileNamePath} = context.settings;
|
||||
return dataFileNamePath ? dataFileNamePath : DEFAULT_SETTINGS.dataFileNamePath;
|
||||
}
|
||||
|
||||
private getFilePath(context: HandleContext): string {
|
||||
const {syncConfig} = context;
|
||||
if (syncConfig) {
|
||||
return syncConfig.dataFilePath;
|
||||
}
|
||||
const {dataFilePath} = context.settings;
|
||||
return dataFilePath ? dataFilePath : DEFAULT_SETTINGS.dataFilePath;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
abstract getSupportType(): SupportType;
|
||||
|
||||
abstract parseVariable(beforeContent: string, variableMap:Map<string, DataField>, extract: T, context: HandleContext): void;
|
||||
|
||||
abstract support(extract: DoubanSubject): boolean;
|
||||
|
||||
async handle(id: string, context: HandleContext): Promise<T> {
|
||||
const url:string = this.getSubjectUrl(id);
|
||||
context.plugin.settingsManager.debug(`开始请求地址:${url}`)
|
||||
context.plugin.settingsManager.debug(`(注意:请勿向任何人透露你的Cookie,此处若需要截图请**打码**)请求header:${context.settings.loginHeadersContent}`)
|
||||
return await DoubanHttpUtil.httpRequestGet(url, context.plugin.settingsManager.getHeaders(), context.plugin.settingsManager)
|
||||
.then(load)
|
||||
.then(data => this.analysisUserState(data, context))
|
||||
.then(({data, userState}) => {
|
||||
let guessType = this.getSupportType();
|
||||
if (context.syncActive) {
|
||||
guessType = this.getGuessType(data);
|
||||
}
|
||||
const sub = this.parseSubjectFromHtml(data, context);
|
||||
sub.userState = userState;
|
||||
sub.guessType = guessType;
|
||||
return sub;
|
||||
})
|
||||
.then(content => this.toEditor(context, content))
|
||||
// .then(content => content ? editor.replaceSelection(content) : content)
|
||||
.catch(e => {
|
||||
log.error(i18nHelper.getMessage('130101', e.toString()), e);
|
||||
if (url) {
|
||||
const id = StringUtil.analyzeIdByUrl(url);
|
||||
context.syncStatusHolder?context.syncStatusHolder.syncStatus.fail(id, ''):null;
|
||||
}else {
|
||||
context.syncStatusHolder?context.syncStatusHolder.syncStatus.handled(1):null;
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过判断 data中是否包含关键字符串 “我看过的电视剧” 判断是不是 movie
|
||||
* @param data
|
||||
* @private
|
||||
*/
|
||||
private getGuessType(data: CheerioAPI):SupportType {
|
||||
if (data) {
|
||||
const text = data.html();
|
||||
if (text) {
|
||||
for (const [key, value] of DoubanSubjectStateRecords_KEY_WORD_TYPE) {
|
||||
if (text.indexOf(key) >= 0) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
abstract parseSubjectFromHtml(data: CheerioAPI, context: HandleContext): T | undefined;
|
||||
|
||||
async toEditor(context: HandleContext, extract: T): Promise<T> {
|
||||
await this.doubanPlugin.putToObsidian(context, extract);
|
||||
return extract;
|
||||
}
|
||||
|
||||
getPersonName(name: string, context: HandleContext): string {
|
||||
return this.getPersonNameByMode(name, context.settings.personNameMode);
|
||||
}
|
||||
|
||||
getPersonName2(originalName: string, chineseName: string, context: HandleContext): string {
|
||||
return this.getPersonNameByMode2(originalName, chineseName, context.settings.personNameMode);
|
||||
}
|
||||
|
||||
|
||||
getPersonNameByMode2(originalName: string, chineseName: string, personNameMode: string): string {
|
||||
if (!originalName || !personNameMode) {
|
||||
return "";
|
||||
}
|
||||
let resultName: string;
|
||||
switch (personNameMode) {
|
||||
case PersonNameMode.CH_NAME:
|
||||
resultName = chineseName;
|
||||
break;
|
||||
case PersonNameMode.EN_NAME:
|
||||
resultName = originalName.trim().replace(chineseName, '').trim();
|
||||
if (!resultName) {
|
||||
resultName = originalName;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
resultName = originalName;
|
||||
}
|
||||
return resultName;
|
||||
}
|
||||
|
||||
|
||||
getPersonNameByMode(name: string, personNameMode: string): string {
|
||||
if (!name || !personNameMode) {
|
||||
return "";
|
||||
}
|
||||
let resultName: string;
|
||||
let regValue: RegExpExecArray;
|
||||
switch (personNameMode) {
|
||||
case PersonNameMode.CH_NAME:
|
||||
regValue = /[\u4e00-\u9fa50-9. ·:\u3002|\uff1f|\uff01|\uff0c|\u3001|\uff1b|\uff1a|\u201c|\u201d|\u2018|\u2019|\uff08|\uff09|\u300a|\u300b|\u3008|\u3009|\u3010|\u3011|\u300e|\u300f|\u300c|\u300d|\ufe43|\ufe44|\u3014|\u3015|\u2026|\u2014|\uff5e|\ufe4f|\uffe5()]{2,}/g.exec(name);
|
||||
resultName = regValue ? regValue[0] : name;
|
||||
break;
|
||||
case PersonNameMode.EN_NAME:
|
||||
regValue = /[0-9a-zA-Z.\s-:]{2,}/g.exec(name);
|
||||
resultName = regValue ? regValue[0] : name;
|
||||
break;
|
||||
default:
|
||||
resultName = name;
|
||||
}
|
||||
return resultName.trim();
|
||||
}
|
||||
|
||||
getTitleNameByMode(name: string, personNameMode: string, context: HandleContext): string {
|
||||
if (!name || !personNameMode) {
|
||||
return "";
|
||||
}
|
||||
if (context.listItem) {
|
||||
const newName = context.listItem.title.trim().replaceAll(' ', '');
|
||||
switch (personNameMode) {
|
||||
case PersonNameMode.CH_NAME:
|
||||
return newName;
|
||||
break;
|
||||
case PersonNameMode.EN_NAME:
|
||||
return name.trim().replaceAll(' ', '').replaceAll(newName, '');
|
||||
break;
|
||||
}
|
||||
}
|
||||
return this.getPersonNameByMode(name, personNameMode);
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
private parsePartYml(template: string, extract: T, context: HandleContext, variableMap : Map<string, DataField>): string {
|
||||
return VariableUtil.replaceSubject(variableMap, template, this.getSupportType(), this.doubanPlugin.settingsManager, 'yml_text');
|
||||
}
|
||||
|
||||
private parsePartText(template: string, extract: T, context: HandleContext, variableMap : Map<string, DataField>): string {
|
||||
return VariableUtil.replaceSubject(variableMap, template, this.getSupportType(), this.doubanPlugin.settingsManager, 'text');
|
||||
}
|
||||
|
||||
private parsePartPath(template: string, extract: T, context: HandleContext, variableMap : Map<string, DataField>): string {
|
||||
return VariableUtil.replaceSubject(variableMap, template, this.getSupportType(), this.doubanPlugin.settingsManager, 'path');
|
||||
}
|
||||
|
||||
private buildVariableMap(extract: T, context: HandleContext) {
|
||||
const variableMap: Map<string, DataField> = new Map();
|
||||
for (const [key, value] of Object.entries(extract)) {
|
||||
if (!value) {
|
||||
continue;
|
||||
}
|
||||
const type: DataValueType = VariableUtil.getType(value);
|
||||
if (key == 'score') {
|
||||
variableMap.set(DoubanParameterName.SCORE_STAR, new DataField(
|
||||
DoubanParameterName.SCORE_STAR,
|
||||
DataValueType.string,
|
||||
value,
|
||||
NumberUtil.getRateStar(value, 10, {scoreSetting: context.settings.scoreSetting})
|
||||
));
|
||||
}
|
||||
variableMap.set(key, new DataField(key, type, value, value));
|
||||
}
|
||||
variableMap.set(DoubanParameterName.IMAGE_URL, new DataField(
|
||||
DoubanParameterName.IMAGE_URL,
|
||||
DataValueType.url,
|
||||
extract.imageUrl,
|
||||
extract.imageUrl
|
||||
));
|
||||
variableMap.set(DoubanParameterName.YEAR_PUBLISHED, new DataField(
|
||||
DoubanParameterName.YEAR_PUBLISHED,
|
||||
DataValueType.date,
|
||||
extract.datePublished,
|
||||
extract.datePublished ? moment(extract.datePublished).format('yyyy') : ''
|
||||
));
|
||||
variableMap.set(DoubanParameterName.DATE_PUBLISHED, new DataField(
|
||||
DoubanParameterName.DATE_PUBLISHED,
|
||||
DataValueType.date,
|
||||
extract.datePublished,
|
||||
extract.datePublished ? moment(extract.datePublished).format(context.settings.dateFormat) : ''
|
||||
));
|
||||
variableMap.set(DoubanParameterName.TIME_PUBLISHED, new DataField(
|
||||
DoubanParameterName.TIME_PUBLISHED,
|
||||
DataValueType.date,
|
||||
extract.datePublished,
|
||||
extract.datePublished ? moment(extract.datePublished).format(context.settings.timeFormat) : ''
|
||||
));
|
||||
const currentDate = new Date();
|
||||
variableMap.set(DoubanParameterName.CURRENT_DATE, new DataField(
|
||||
DoubanParameterName.CURRENT_DATE,
|
||||
DataValueType.date,
|
||||
currentDate,
|
||||
moment(currentDate).format(context.settings.dateFormat)
|
||||
));
|
||||
variableMap.set(DoubanParameterName.CURRENT_TIME, new DataField(
|
||||
DoubanParameterName.CURRENT_TIME,
|
||||
DataValueType.date,
|
||||
currentDate,
|
||||
moment(currentDate).format(context.settings.timeFormat)
|
||||
));
|
||||
return variableMap;
|
||||
}
|
||||
|
||||
private parseUserInfo(resultContent: string, variableMap:Map<string, DataField>, extract: T, context: HandleContext) {
|
||||
const userState = extract.userState;
|
||||
if ((resultContent.indexOf(DoubanUserParameter.MY_TAGS) >= 0 ||
|
||||
resultContent.indexOf(DoubanUserParameter.MY_RATING) >= 0 ||
|
||||
resultContent.indexOf(DoubanUserParameter.MY_STATE) >= 0 ||
|
||||
resultContent.indexOf(DoubanUserParameter.MY_COMMENT) >= 0 ||
|
||||
resultContent.indexOf(DoubanUserParameter.MY_COLLECTION_DATE) >= 0 ) && !this.doubanPlugin.userComponent.isLogin()) {
|
||||
log.warn(i18nHelper.getMessage('100113'));
|
||||
return resultContent;
|
||||
}
|
||||
if (!userState) {
|
||||
return resultContent;
|
||||
}
|
||||
let tags: string[] = [];
|
||||
if (userState.tags && userState.tags.length > 0 ) {
|
||||
tags = [extract.type, ...userState.tags.map(tag => tag.trim())];
|
||||
}else {
|
||||
tags = [extract.type];
|
||||
}
|
||||
Object.entries(userState).forEach(([key, value]) => {
|
||||
if (!value) {
|
||||
return;
|
||||
}
|
||||
variableMap.set(key, new DataField(key, VariableUtil.getType(value), value, value));
|
||||
});
|
||||
if (userState.tags && userState.tags.length > 0 ) {
|
||||
variableMap.set(DoubanUserParameterName.MY_TAGS, new DataField(DoubanUserParameterName.MY_TAGS, DataValueType.array, tags, tags));
|
||||
}
|
||||
if (userState.comment) {
|
||||
variableMap.set(DoubanUserParameterName.MY_COMMENT, new DataField(
|
||||
DoubanUserParameterName.MY_COMMENT,
|
||||
DataValueType.string,
|
||||
userState.comment,
|
||||
userState.comment
|
||||
));
|
||||
}
|
||||
if (userState.state) {
|
||||
variableMap.set(DoubanUserParameterName.MY_STATE, new DataField(
|
||||
DoubanUserParameterName.MY_STATE,
|
||||
DataValueType.string,
|
||||
userState.state,
|
||||
this.getUserStateName(userState.state)
|
||||
));
|
||||
}
|
||||
if (userState.rate) {
|
||||
variableMap.set(DoubanUserParameterName.MY_RATING, new DataField(
|
||||
DoubanUserParameterName.MY_RATING,
|
||||
DataValueType.number,
|
||||
userState.rate,
|
||||
userState.rate)
|
||||
);
|
||||
variableMap.set(DoubanUserParameterName.MY_RATING_STAR, new DataField(
|
||||
DoubanUserParameterName.MY_RATING_STAR,
|
||||
DataValueType.string,
|
||||
userState.rate,
|
||||
NumberUtil.getRateStar(userState.rate, 5, {scoreSetting: context.settings.scoreSetting})
|
||||
));
|
||||
}
|
||||
if (userState.collectionDate) {
|
||||
variableMap.set(DoubanUserParameterName.MY_COLLECTION_DATE, new DataField(
|
||||
DoubanUserParameterName.MY_COLLECTION_DATE,
|
||||
DataValueType.date,
|
||||
userState.collectionDate,
|
||||
userState.collectionDate ? moment(userState.collectionDate).format(context.settings.dateFormat) : ''
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private getTemplateKey():TemplateKey {
|
||||
let templateKey: TemplateKey;
|
||||
switch (this.getSupportType()) {
|
||||
case SupportType.movie:
|
||||
templateKey = TemplateKey.movieTemplateFile;
|
||||
break;
|
||||
case SupportType.book:
|
||||
templateKey = TemplateKey.bookTemplateFile;
|
||||
break;
|
||||
case SupportType.music:
|
||||
templateKey = TemplateKey.musicTemplateFile;
|
||||
break;
|
||||
case SupportType.teleplay:
|
||||
templateKey = TemplateKey.teleplayTemplateFile;
|
||||
break;
|
||||
case SupportType.game:
|
||||
templateKey = TemplateKey.gameTemplateFile;
|
||||
break;
|
||||
case SupportType.note:
|
||||
templateKey = TemplateKey.noteTemplateFile;
|
||||
break;
|
||||
default:
|
||||
templateKey = null;
|
||||
|
||||
}
|
||||
return templateKey;
|
||||
}
|
||||
|
||||
private async getTemplate(extract: T, context: HandleContext): Promise<string> {
|
||||
const {syncConfig} = context;
|
||||
if (syncConfig) {
|
||||
if(syncConfig.templateFile) {
|
||||
const val = await this.doubanPlugin.fileHandler.getFileContent(syncConfig.templateFile);
|
||||
if (val) {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
}
|
||||
const tempKey: TemplateKey = this.getTemplateKey();
|
||||
const templatePath: string = context.settings[tempKey];
|
||||
let useUserState:boolean = context.userComponent.isLogin() &&
|
||||
extract.userState &&
|
||||
extract.userState.collectionDate != null &&
|
||||
extract.userState.collectionDate != undefined;
|
||||
|
||||
useUserState = useUserState ? useUserState : false;
|
||||
|
||||
// @ts-ignore
|
||||
if (!templatePath || StringUtil.isBlank(templatePath)) {
|
||||
return getDefaultTemplateContent(tempKey, useUserState);
|
||||
}
|
||||
const defaultContent = getDefaultTemplateContent(tempKey, useUserState);
|
||||
const firstLinkpathDest: TFile = this.doubanPlugin.app.metadataCache.getFirstLinkpathDest(templatePath, '');
|
||||
if (!firstLinkpathDest) {
|
||||
return defaultContent;
|
||||
} else {
|
||||
const val = await this.doubanPlugin.fileHandler.getFileContent(firstLinkpathDest.path);
|
||||
return val ? val : defaultContent;
|
||||
}
|
||||
}
|
||||
|
||||
analysisUserState(html: CheerioAPI, context: HandleContext): {data:CheerioAPI , userState: UserStateSubject} {
|
||||
if (!context.userComponent.isLogin()) {
|
||||
return {data: html, userState: null};
|
||||
}
|
||||
if(!html('.nav-user-account')) {
|
||||
return {data: html, userState: null};
|
||||
}
|
||||
return this. analysisUser(html, context);
|
||||
}
|
||||
|
||||
abstract analysisUser(html: CheerioAPI, context: HandleContext): {data:CheerioAPI , userState: UserStateSubject};
|
||||
|
||||
|
||||
public static getUserState(stateWord:string):DoubanSubjectState {
|
||||
let state:DoubanSubjectState;
|
||||
if(!stateWord) {
|
||||
return null;
|
||||
}
|
||||
if(stateWord.indexOf('想')>=0 ) {
|
||||
state = DoubanSubjectState.wish;
|
||||
}else if(stateWord.indexOf('在')>=0) {
|
||||
state = DoubanSubjectState.do;
|
||||
}else if(stateWord.indexOf('过')>=0) {
|
||||
state = DoubanSubjectState.collect;
|
||||
}else {
|
||||
state = DoubanSubjectState.not;
|
||||
}
|
||||
return state;
|
||||
|
||||
}
|
||||
|
||||
private getUserStateName(state: DoubanSubjectState): string {
|
||||
if (!state) {
|
||||
return '';
|
||||
}
|
||||
const v = DoubanSubjectStateRecords[this.getSupportType()];
|
||||
switch (state) {
|
||||
case DoubanSubjectState.wish:
|
||||
return v.wish;
|
||||
case DoubanSubjectState.do:
|
||||
return v.do;
|
||||
case DoubanSubjectState.collect:
|
||||
return v.collect;
|
||||
case DoubanSubjectState.not:
|
||||
return v.not;
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
private async saveImage(extract: T, context: HandleContext, variableMap : Map<string, DataField>) {
|
||||
const {syncConfig} = context;
|
||||
if (!extract.image || (syncConfig && !syncConfig.cacheImage) || !context.settings.cacheImage) {
|
||||
return;
|
||||
}
|
||||
const image = extract.image;
|
||||
let folder = syncConfig? syncConfig.attachmentPath : context.settings.attachmentPath;
|
||||
if (!folder) {
|
||||
folder = DEFAULT_SETTINGS.attachmentPath;
|
||||
}
|
||||
folder = this.parsePartPath(folder, extract, context, variableMap)
|
||||
let fileName = syncConfig? syncConfig.attachmentFileName : context.settings.attachmentFileName;
|
||||
if (!fileName) {
|
||||
fileName = DEFAULT_SETTINGS.attachmentFileName;
|
||||
}
|
||||
let fileNameSuffix = image ? image.substring(image.lastIndexOf('.')) : '.jpg';
|
||||
if (fileNameSuffix && fileNameSuffix.length > 10) {
|
||||
fileNameSuffix = '.jpg';
|
||||
}
|
||||
fileName = this.parsePartPath(fileName, extract, context, variableMap)
|
||||
fileName = fileName + fileNameSuffix;
|
||||
const imageReferer = (extract.id ? this.getSubjectUrl(extract.id) : '') || extract.url;
|
||||
const referHeaders = HttpUtil.buildImageRequestHeaders(
|
||||
context.plugin.settingsManager.getHeaders() as Record<string, any>,
|
||||
imageReferer
|
||||
);
|
||||
if ((syncConfig ? syncConfig.cacheHighQuantityImage : context.settings.cacheHighQuantityImage) && context.userComponent.isLogin()) {
|
||||
try {
|
||||
const highImageFilename = this.getImageFilename(image);
|
||||
const highImage = this.getHighQuantityImageUrl(highImageFilename);
|
||||
const highImageHeaders = HttpUtil.buildImageRequestHeaders(
|
||||
context.plugin.settingsManager.getHeaders() as Record<string, any>,
|
||||
imageReferer
|
||||
);
|
||||
const resultValue = await this.handleImage(highImage, folder, fileName, context, false, highImageHeaders);
|
||||
if (resultValue && resultValue.success) {
|
||||
extract.image = resultValue.filepath;
|
||||
this.initImageVariableMap(extract, context, variableMap);
|
||||
return;
|
||||
}
|
||||
}catch (e) {
|
||||
console.error(e);
|
||||
console.error('下载高清封面失败,将会使用普通封面')
|
||||
}
|
||||
}
|
||||
const resultValue = await this.handleImage(image, folder, fileName, context, true, referHeaders);
|
||||
if (resultValue && resultValue.success) {
|
||||
extract.image = resultValue.filepath;
|
||||
this.initImageVariableMap(extract, context, variableMap);
|
||||
}
|
||||
}
|
||||
|
||||
private getImageFilename(image: string): string {
|
||||
if (!image) {
|
||||
return '';
|
||||
}
|
||||
const imageUrl = image.split('?').first() || image;
|
||||
return imageUrl.substring(imageUrl.lastIndexOf('/') + 1);
|
||||
}
|
||||
|
||||
private initImageVariableMap(extract: T, context: HandleContext, variableMap : Map<string, DataField>) {
|
||||
variableMap.set(DoubanParameterName.IMAGE_URL, new DataField(
|
||||
DoubanParameterName.IMAGE_URL,
|
||||
DataValueType.url,
|
||||
extract.imageUrl,
|
||||
extract.imageUrl
|
||||
));
|
||||
variableMap.set(DoubanParameterName.IMAGE, new DataField(
|
||||
DoubanParameterName.IMAGE,
|
||||
DataValueType.path,
|
||||
extract.image,
|
||||
extract.image
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
private async handleImage(image: string, folder: string, filename: string, context: HandleContext, showError: boolean, headers?: any) {
|
||||
//只有在桌面版且开启了图片上传才会使用PicGo,并且开启图床功能
|
||||
if (context.settings.pictureBedFlag && Platform.isDesktopApp) {
|
||||
//临时限定只支持PicGo
|
||||
const checked = await context.netFileHandler.downloadDBUploadPicGoByClipboardBefore(context);
|
||||
if (!checked) {
|
||||
//TODO 国际化
|
||||
log.notice('连接PicGo软件失败, 请检查是否已开启PicGo的Server服务 或 检查插件中配置地址是否正确,现使用默认的下载到本地的方式');
|
||||
return await context.netFileHandler.downloadDBFile(image, folder, filename, context, false, headers);
|
||||
}
|
||||
return await context.netFileHandler.downloadDBUploadPicGoByClipboard(image, filename, context, showError, headers);
|
||||
}else {
|
||||
return await context.netFileHandler.downloadDBFile(image, folder, filename, context, false, headers);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
abstract getHighQuantityImageUrl(fileName:string):string;
|
||||
|
||||
abstract getSubjectUrl(id:string):string;
|
||||
|
||||
handlePersonNameByMeta(html: CheerioAPI, movie: DoubanSubject, context: HandleContext,
|
||||
metaProperty:string, objectProperty:string) {
|
||||
if (!movie) {
|
||||
return;
|
||||
}
|
||||
const metaProperties: string[] = html(`head > meta[property='${metaProperty}']`).get()
|
||||
.map((e) => {
|
||||
return html(e).attr('content');
|
||||
});
|
||||
// @ts-ignore
|
||||
const currentArray = movie[objectProperty];
|
||||
if (!Array.isArray(currentArray)) {
|
||||
return;
|
||||
}
|
||||
// @ts-ignore
|
||||
currentArray
|
||||
// @ts-ignore
|
||||
.filter((p:Person) => p.name)
|
||||
// @ts-ignore
|
||||
.map((p:Person) => {
|
||||
// @ts-ignore
|
||||
const persons = metaProperties.filter((a) => p.name.indexOf(a) >= 0);
|
||||
if (persons) {
|
||||
// @ts-ignore
|
||||
p.name = this.getPersonName2(p.name, persons[0], context);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
protected getPropertyValue(html: CheerioAPI, name: PropertyName): string {
|
||||
return HtmlUtil.getHtmlText(html, this.doubanPlugin.settingsManager.getSelector(this.getSupportType(), name));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
164
src/org/wanxp/douban/data/handler/DoubanBookLoadHandler.ts
Normal file
@ -0,0 +1,164 @@
|
||||
import {CheerioAPI} from 'cheerio';
|
||||
import DoubanAbstractLoadHandler from "./DoubanAbstractLoadHandler";
|
||||
import DoubanBookSubject, {DoubanBookParameter} from "../model/DoubanBookSubject";
|
||||
import DoubanPlugin from "../../../main";
|
||||
import DoubanSubject from "../model/DoubanSubject";
|
||||
import {DataValueType, PropertyName, SupportType, TemplateTextMode} from "../../../constant/Constsant";
|
||||
import HandleContext from "../model/HandleContext";
|
||||
import StringUtil from "../../../utils/StringUtil";
|
||||
import {UserStateSubject} from "../model/UserStateSubject";
|
||||
import {moment} from "obsidian";
|
||||
import {DataField} from "../../../utils/model/DataField";
|
||||
|
||||
export default class DoubanBookLoadHandler extends DoubanAbstractLoadHandler<DoubanBookSubject> {
|
||||
|
||||
constructor(doubanPlugin: DoubanPlugin) {
|
||||
super(doubanPlugin);
|
||||
}
|
||||
|
||||
getSupportType(): SupportType {
|
||||
return SupportType.book;
|
||||
}
|
||||
|
||||
getHighQuantityImageUrl(fileName:string):string{
|
||||
return `https://img9.doubanio.com/view/subject/l/public/${fileName}`;
|
||||
}
|
||||
|
||||
getSubjectUrl(id:string):string{
|
||||
return `https://book.douban.com/subject/${id}/`;
|
||||
}
|
||||
|
||||
parseVariable(beforeContent: string, variableMap:Map<string, DataField>, extract: DoubanBookSubject, context: HandleContext): void {
|
||||
variableMap.set(DoubanBookParameter.author, new DataField(DoubanBookParameter.author,
|
||||
DataValueType.array, extract.author, (extract.author || []).map(this.handleSpecialAuthorName)));
|
||||
variableMap.set(DoubanBookParameter.translator, new DataField(DoubanBookParameter.translator,
|
||||
DataValueType.array, extract.translator, (extract.translator || []).map(this.handleSpecialAuthorName)));
|
||||
}
|
||||
|
||||
support(extract: DoubanSubject): boolean {
|
||||
return extract && extract.type && (extract.type.contains("图书") || extract.type.contains("书籍") || extract.type.contains("Book") || extract.type.contains("book"));
|
||||
}
|
||||
|
||||
handleSpecialAuthorName(authorName: string): string {
|
||||
return authorName.replace(/\[/g, '')
|
||||
.replace(']', '/');
|
||||
}
|
||||
|
||||
analysisUser(html: CheerioAPI, context: HandleContext): {data:CheerioAPI , userState: UserStateSubject} {
|
||||
const rate = html('input#n_rating').val();
|
||||
const tagsStr = html('span#rating').next().text().trim();
|
||||
const tags = tagsStr ? tagsStr.replace('标签:', '').trim().split(' ') : null;
|
||||
const stateWord = html('div#interest_sect_level > div.a_stars > span.mr10').text().trim();
|
||||
const collectionDateStr = html('div#interest_sect_level > div.a_stars > span.mr10').next().text().trim();
|
||||
const userState1 = DoubanAbstractLoadHandler.getUserState(stateWord);
|
||||
const comment = this.getComment(html);
|
||||
|
||||
|
||||
const userState: UserStateSubject = {
|
||||
tags: tags,
|
||||
rate: rate?Number(rate):null,
|
||||
state: userState1,
|
||||
collectionDate: collectionDateStr?moment(collectionDateStr, 'YYYY-MM-DD').toDate():null,
|
||||
comment: comment
|
||||
}
|
||||
return {data: html, userState: userState};
|
||||
}
|
||||
|
||||
|
||||
parseSubjectFromHtml(html: CheerioAPI, context: HandleContext): DoubanBookSubject {
|
||||
let desc = html(".intro p").text();
|
||||
if (!desc) {
|
||||
desc = html(html("head > meta[property= 'og:description']").get(0)).attr("content");
|
||||
}
|
||||
const image = html(html("head > meta[property= 'og:image']").get(0)).attr("content");
|
||||
let item = html(html("head > script[type='application/ld+json']").get(0)).text();
|
||||
item = super.html_decode(item);
|
||||
const obj = JSON.parse(item.replace(/[\r\n\t\s+]/g, ''));
|
||||
const title = obj.name;
|
||||
const url = obj.url;
|
||||
const author = obj.author.map((a: any) => a.name);
|
||||
const isbn = obj.isbn;
|
||||
|
||||
|
||||
const score = html(html("#interest_sectl > div > div.rating_self.clearfix > strong[property= 'v:average']").get(0)).text();
|
||||
const detailDom = html(html("#info").get(0));
|
||||
const publish = detailDom.find("span.pl");
|
||||
|
||||
const valueMap = new Map<string, any>();
|
||||
|
||||
publish.map((index, info) => {
|
||||
let key = html(info).text().trim();
|
||||
let value;
|
||||
if (key.indexOf('译者') >= 0) {
|
||||
value = [];
|
||||
html(info.parent).find("a").map((index, a) => {
|
||||
value.push(html(a).text().trim());
|
||||
});
|
||||
} else 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 id = StringUtil.analyzeIdByUrl(url);
|
||||
let menuIdDom = html('#dir_' + id + '_full') ? html('#dir_' + id + '_full') : html('#dir_' + id + '_short');
|
||||
let menu: string[] = menuIdDom ? html(menuIdDom.get(0)).text().trim().split('\n').map(row => row.trim()) : [];
|
||||
menu.length > 0 ? menu.pop() : menu;
|
||||
const result: DoubanBookSubject = {
|
||||
author: author,
|
||||
translator: valueMap.has('translator') ? valueMap.get('translator') : [],
|
||||
image: image,
|
||||
imageUrl: image,
|
||||
datePublished: valueMap.has('datePublished') ? new Date(valueMap.get('datePublished')) : undefined,
|
||||
isbn: isbn,
|
||||
publisher: valueMap.has('publisher') ? valueMap.get('publisher') : "",
|
||||
score: Number(score),
|
||||
originalTitle: valueMap.has('originalTitle') ? valueMap.get('originalTitle') : "",
|
||||
subTitle: valueMap.has('subTitle') ? valueMap.get('subTitle') : "",
|
||||
totalPage: valueMap.has('totalPage') ? Number(valueMap.get('totalPage')) : null,
|
||||
series: valueMap.has('series') ? valueMap.get('series') : "",
|
||||
menu: menu,
|
||||
price: valueMap.has('price') ? Number(valueMap.get('price').replace('元', '')) : null,
|
||||
id: id,
|
||||
type: this.getSupportType(),
|
||||
title: title,
|
||||
desc: desc,
|
||||
url: url,
|
||||
genre: [],
|
||||
binding: valueMap.has('binding') ? valueMap.get('binding') : "",
|
||||
producer: valueMap.has('producer') ? valueMap.get('producer') : "",
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
private getComment(html: CheerioAPI) {
|
||||
let comment = html('span#rating').next().next().next().text().trim();
|
||||
if (comment) {
|
||||
return comment;
|
||||
}
|
||||
return this.getPropertyValue(html, PropertyName.comment);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const BookKeyValueMap: Map<string, string> = new Map(
|
||||
[['作者', 'author'],
|
||||
['出版社:', 'publisher'],
|
||||
['原作名:', 'originalTitle'],
|
||||
['出版年:', 'datePublished'],
|
||||
['页数:', 'totalPage'],
|
||||
['定价:', 'price'],
|
||||
['装帧:', 'binding'],
|
||||
['丛书:', 'series'],
|
||||
['ISBN:', 'isbn'],
|
||||
['译者', 'translator'],
|
||||
['副标题:', 'subTitle'],
|
||||
['出品方:', 'producer'],
|
||||
]
|
||||
);
|
||||
158
src/org/wanxp/douban/data/handler/DoubanGameLoadHandler.ts
Normal file
@ -0,0 +1,158 @@
|
||||
import {CheerioAPI} from 'cheerio';
|
||||
import DoubanAbstractLoadHandler from "./DoubanAbstractLoadHandler";
|
||||
import DoubanPlugin from "../../../main";
|
||||
import DoubanSubject from '../model/DoubanSubject';
|
||||
import DoubanGameSubject from '../model/DoubanGameSubject';
|
||||
import HandleContext from "../model/HandleContext";
|
||||
import {DataValueType, PersonNameMode, SupportType} from "../../../constant/Constsant";
|
||||
import {UserStateSubject} from "../model/UserStateSubject";
|
||||
import {moment} from "obsidian";
|
||||
import {TITLE_ALIASES_SPECIAL_CHAR_REG_G} from "../../../utils/YamlUtil";
|
||||
import {DataField} from "../../../utils/model/DataField";
|
||||
import {b} from "@shikijs/engine-javascript/dist/shared/engine-javascript.BnuFKbIS";
|
||||
|
||||
export default class DoubanGameLoadHandler extends DoubanAbstractLoadHandler<DoubanGameSubject> {
|
||||
|
||||
constructor(doubanPlugin: DoubanPlugin) {
|
||||
super(doubanPlugin);
|
||||
}
|
||||
|
||||
getSupportType(): SupportType {
|
||||
return SupportType.game;
|
||||
}
|
||||
getHighQuantityImageUrl(fileName:string):string{
|
||||
return `https://img9.doubanio.com/lpic/${fileName}`;
|
||||
}
|
||||
|
||||
getSubjectUrl(id:string):string{
|
||||
return `https://www.douban.com/game/${id}/`;
|
||||
}
|
||||
|
||||
parseVariable(beforeContent: string, variableMap:Map<string, DataField>, extract: DoubanGameSubject, context: HandleContext): void {
|
||||
// super.parseAliases(beforeContent, variableMap, extract, context);
|
||||
variableMap.set("aliases", new DataField("aliases", DataValueType.array, extract.aliases,
|
||||
(extract.aliases || []).map(a=>a
|
||||
.trim()
|
||||
// .replace(TITLE_ALIASES_SPECIAL_CHAR_REG_G, '_')
|
||||
// //replase multiple _ to single _
|
||||
// .replace(/_+/g, '_')
|
||||
// .replace(/^_/, '')
|
||||
// .replace(/_$/, '')
|
||||
.replace(/:\s+/g, ':')
|
||||
)));
|
||||
// super.parseAliases(beforeContent, variableMap, extract, context);
|
||||
}
|
||||
|
||||
support(extract: DoubanSubject): boolean {
|
||||
return extract && extract.type && (extract.type.contains("游戏") || extract.type.contains("Game") || extract.type.contains("game"));
|
||||
}
|
||||
|
||||
analysisUser(html: CheerioAPI, context: HandleContext): {data:CheerioAPI , userState: UserStateSubject} {
|
||||
let rate = html('input#n_rating').val();
|
||||
const rating = html('span#rating');
|
||||
const tagsStr = rating.parent().next().text().trim();
|
||||
const tags = tagsStr ? tagsStr.replace('标签:', '').trim().split(' ') : null;
|
||||
const collected = html('div.collection-section > div.collection-rating-stars > div.collection-collected');
|
||||
const stateWord = collected.find('span.collection-result').text().trim();
|
||||
const collectionDateStr = collected.find('span.color_gray').text().trim();
|
||||
const userState1 = DoubanAbstractLoadHandler.getUserState(stateWord);
|
||||
const component = rating.parent().next().next().text().trim();
|
||||
|
||||
const userState: UserStateSubject = {
|
||||
tags: tags,
|
||||
rate: rate?Number(rate):null,
|
||||
state: userState1,
|
||||
collectionDate: collectionDateStr?moment(collectionDateStr, 'YYYY-MM-DD').toDate():null,
|
||||
comment: component
|
||||
}
|
||||
return {data: html, userState: userState};
|
||||
}
|
||||
|
||||
parseSubjectFromHtml(html: CheerioAPI, context: HandleContext): DoubanGameSubject {
|
||||
let title = html(html("#content > h1").get(0)).text();
|
||||
title = this.getPersonNameByMode(title, PersonNameMode.CH_NAME);
|
||||
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.thing-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: this.getSupportType(),
|
||||
title: title,
|
||||
desc: desc,
|
||||
url: url,
|
||||
genre: valueMap.has('genre') ? valueMap.get('genre') : [],
|
||||
image: image,
|
||||
imageUrl: 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'],
|
||||
]
|
||||
);
|
||||
|
||||
227
src/org/wanxp/douban/data/handler/DoubanMovieLoadHandler.ts
Normal file
@ -0,0 +1,227 @@
|
||||
import {CheerioAPI} from 'cheerio';
|
||||
import DoubanAbstractLoadHandler from "./DoubanAbstractLoadHandler";
|
||||
import DoubanPlugin from "../../../main";
|
||||
import SchemaOrg from "src/org/wanxp/utils/SchemaOrg";
|
||||
import DoubanSubject from '../model/DoubanSubject';
|
||||
import DoubanMovieSubject from '../model/DoubanMovieSubject';
|
||||
import StringUtil from "../../../utils/StringUtil";
|
||||
import HandleContext from "../model/HandleContext";
|
||||
import {DataValueType, PersonNameMode, PropertyName, SupportType, TemplateKey} from "../../../constant/Constsant";
|
||||
import {UserStateSubject} from "../model/UserStateSubject";
|
||||
import {moment} from "obsidian";
|
||||
import YamlUtil, {SPECIAL_CHAR_REG, TITLE_ALIASES_SPECIAL_CHAR_REG_G} from "../../../utils/YamlUtil";
|
||||
import {DataField} from "../../../utils/model/DataField";
|
||||
|
||||
export default class DoubanMovieLoadHandler extends DoubanAbstractLoadHandler<DoubanMovieSubject> {
|
||||
|
||||
constructor(doubanPlugin: DoubanPlugin) {
|
||||
super(doubanPlugin);
|
||||
}
|
||||
|
||||
getSupportType(): SupportType {
|
||||
return SupportType.movie;
|
||||
}
|
||||
|
||||
getHighQuantityImageUrl(fileName:string):string{
|
||||
return `https://img9.doubanio.com/view/photo/l/public/${fileName}`;
|
||||
}
|
||||
|
||||
getSubjectUrl(id:string):string{
|
||||
return `https://movie.douban.com/subject/${id}/`;
|
||||
}
|
||||
|
||||
parseVariable(beforeContent: string, variableMap:Map<string, DataField>, extract: DoubanMovieSubject, context: HandleContext): void {
|
||||
variableMap.set("director", new DataField(
|
||||
"director",
|
||||
DataValueType.array,
|
||||
extract.director,
|
||||
(extract.director || []).map(SchemaOrg.getPersonName).filter(c => c)
|
||||
));
|
||||
|
||||
variableMap.set("actor", new DataField(
|
||||
"actor",
|
||||
DataValueType.array,
|
||||
extract.actor,
|
||||
(extract.actor || []).map(SchemaOrg.getPersonName).filter(c => c)
|
||||
));
|
||||
|
||||
variableMap.set("author", new DataField(
|
||||
"author",
|
||||
DataValueType.array,
|
||||
extract.author,
|
||||
(extract.author || []).map(SchemaOrg.getPersonName).map(name => super.getPersonName(name, context)).filter(c => c)
|
||||
));
|
||||
variableMap.set("aliases", new DataField("aliases", DataValueType.array, extract.aliases,
|
||||
(extract.aliases || []).map(a=>a
|
||||
.trim()
|
||||
// .replace(TITLE_ALIASES_SPECIAL_CHAR_REG_G, '_')
|
||||
// //replase multiple _ to single _
|
||||
// .replace(/_+/g, '_')
|
||||
// .replace(/^_/, '')
|
||||
// .replace(/_$/, '')
|
||||
.replace(/:\s+/g, ':')
|
||||
)));
|
||||
// super.parseAliases(beforeContent, variableMap, extract, context);
|
||||
}
|
||||
|
||||
support(extract: DoubanSubject): boolean {
|
||||
return extract && extract.type && (extract.type.contains("电影") || extract.type.contains("Movie") || extract.type.contains("movie"));
|
||||
}
|
||||
|
||||
analysisUser(html: CheerioAPI, context: HandleContext): {data:CheerioAPI , userState: UserStateSubject} {
|
||||
let rate = html('input#n_rating').val();
|
||||
let tagsStr = html('div#interest_sect_level > div.a_stars > span.color_gray').text().trim();
|
||||
let tags = tagsStr ? tagsStr.replace('标签:', '').trim().split(' ') : null;
|
||||
let stateWord = html('div#interest_sect_level > div.a_stars > span.mr10').text().trim();
|
||||
let collectionDateStr = html('div#interest_sect_level > div.a_stars > span.mr10 > span.collection_date').text().trim();
|
||||
let userState1 = DoubanAbstractLoadHandler.getUserState(stateWord);
|
||||
let component = this.getComment(html, context);
|
||||
|
||||
|
||||
const userState: UserStateSubject = {
|
||||
tags: tags,
|
||||
rate: rate?Number(rate):null,
|
||||
state: userState1,
|
||||
collectionDate: collectionDateStr?moment(collectionDateStr, 'YYYY-MM-DD').toDate():null,
|
||||
comment: component
|
||||
}
|
||||
return {data: html, userState: userState};
|
||||
}
|
||||
|
||||
|
||||
private getComment(html: CheerioAPI, context: HandleContext) {
|
||||
const component = html('div#interest_sect_level > div.a_stars > span.color_gray').next().next().text().trim();
|
||||
if (component) {
|
||||
return component;
|
||||
}
|
||||
return this.getPropertyValue(html, PropertyName.comment);
|
||||
}
|
||||
|
||||
parseSubjectFromHtml(html: CheerioAPI, context: HandleContext): DoubanMovieSubject {
|
||||
let movie: DoubanMovieSubject | undefined = html('script')
|
||||
.get()
|
||||
.filter(scd => "application/ld+json" == html(scd).attr("type"))
|
||||
.map(i => {
|
||||
let item = html(i).text();
|
||||
item = super.html_decode(item);
|
||||
const obj = JSON.parse(item.replace(/[\r\n\t]+/g, ''));
|
||||
const idPattern = /(\d){5,10}/g;
|
||||
const id = idPattern.exec(obj.url);
|
||||
const name = obj.name;
|
||||
const title = super.getTitleNameByMode(name, PersonNameMode.CH_NAME, context) ?? name;
|
||||
const originalTitle = super.getTitleNameByMode(name, PersonNameMode.EN_NAME, context) ?? name;
|
||||
|
||||
const result: DoubanMovieSubject = {
|
||||
id: id ? id[0] : '',
|
||||
title: title,
|
||||
type: this.getSupportType(),
|
||||
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,
|
||||
imageUrl: obj.image,
|
||||
genre: obj.genre || [],
|
||||
publisher: '',
|
||||
aliases: [""],
|
||||
language: [""],
|
||||
country: [],
|
||||
time: null,
|
||||
IMDb: null,
|
||||
}
|
||||
return result;
|
||||
})[0];
|
||||
|
||||
// Fallback: if JSON-LD parsing failed (e.g., anti-bot page), extract from meta tags
|
||||
if (!movie) {
|
||||
const title = html(html("head > meta[property='og:title']").get(0)).attr("content") || '';
|
||||
const image = html(html("head > meta[property='og:image']").get(0)).attr("content") || '';
|
||||
const urlMeta = html(html("head > meta[property='og:url']").get(0)).attr("content") || '';
|
||||
const desc = html(html("head > meta[property='og:description']").get(0)).attr("content") || '';
|
||||
|
||||
// Extract ID from URL
|
||||
const idPattern = /(\d){5,10}/g;
|
||||
const idMatch = idPattern.exec(urlMeta);
|
||||
const id = idMatch ? idMatch[0] : '';
|
||||
|
||||
// Extract score from HTML
|
||||
const scoreText = html("#interest_sectl strong[property='v:average']").text();
|
||||
const score = scoreText ? parseFloat(scoreText) : undefined;
|
||||
|
||||
movie = {
|
||||
id,
|
||||
title,
|
||||
type: this.getSupportType(),
|
||||
score,
|
||||
originalTitle: title,
|
||||
desc,
|
||||
url: urlMeta || (id ? `https://movie.douban.com/subject/${id}/` : ''),
|
||||
director: [],
|
||||
author: [],
|
||||
actor: [],
|
||||
aggregateRating: undefined,
|
||||
datePublished: undefined,
|
||||
image,
|
||||
imageUrl: image,
|
||||
genre: [],
|
||||
publisher: '',
|
||||
aliases: [],
|
||||
language: [],
|
||||
country: [],
|
||||
time: null,
|
||||
IMDb: null,
|
||||
};
|
||||
}
|
||||
|
||||
this.handlePersonNameByMeta(html, movie, context, 'video:actor', 'actor');
|
||||
this.handlePersonNameByMeta(html, movie, context, 'video:director', 'director');
|
||||
|
||||
const desc: string = html("span[property='v:summary']").text();
|
||||
if (desc) {
|
||||
movie.desc = desc;
|
||||
}
|
||||
|
||||
const detailDom = html(html("#info").get(0));
|
||||
const publish = detailDom.find("span.pl");
|
||||
|
||||
const valueMap = new Map<string, any>();
|
||||
|
||||
publish.map((index, info) => {
|
||||
const key = html(info).text().trim();
|
||||
let value;
|
||||
if (key.indexOf('又名') >= 0 || key.indexOf('语言') >= 0 || key.indexOf('制片国家') >= 0) {
|
||||
// value = html(info.next.next).text().trim();
|
||||
const vas = html(info.next).text().trim();
|
||||
value = vas.split("/").map((v) => v.trim());
|
||||
} else if (key.indexOf('片长') >= 0) {
|
||||
value = html(info.next.next).text().trim()
|
||||
} else {
|
||||
value = html(info.next).text().trim();
|
||||
}
|
||||
valueMap.set(MovieKeyValueMap.get(key), value);
|
||||
})
|
||||
|
||||
movie.country = valueMap.has('country') ? valueMap.get('country') : [];
|
||||
movie.language = valueMap.has('language') ? valueMap.get('language') : [];
|
||||
movie.time = valueMap.has('time') ? valueMap.get('time') : "";
|
||||
movie.aliases = valueMap.has('aliases') ? valueMap.get('aliases') : [];
|
||||
movie.IMDb = valueMap.has('IMDb') ? valueMap.get('IMDb') : "";
|
||||
return movie;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
const MovieKeyValueMap: Map<string, string> = new Map(
|
||||
[['制片国家/地区:', 'country'],
|
||||
['语言:', 'language'],
|
||||
['片长:', 'time'],
|
||||
['又名:', 'aliases'],
|
||||
['IMDb:', 'IMDb']
|
||||
]
|
||||
);
|
||||
130
src/org/wanxp/douban/data/handler/DoubanMusicLoadHandler.ts
Normal file
@ -0,0 +1,130 @@
|
||||
import {CheerioAPI} from 'cheerio';
|
||||
import DoubanAbstractLoadHandler from "./DoubanAbstractLoadHandler";
|
||||
import DoubanMusicSubject from '../model/DoubanMusicSubject';
|
||||
import DoubanPlugin from "../../../main";
|
||||
import DoubanSubject from '../model/DoubanSubject';
|
||||
import HandleContext from "../model/HandleContext";
|
||||
import {SupportType} from "../../../constant/Constsant";
|
||||
import {UserStateSubject} from "../model/UserStateSubject";
|
||||
import {moment} from "obsidian";
|
||||
import {DataField} from "../../../utils/model/DataField";
|
||||
|
||||
export default class DoubanMusicLoadHandler extends DoubanAbstractLoadHandler<DoubanMusicSubject> {
|
||||
|
||||
constructor(doubanPlugin: DoubanPlugin) {
|
||||
super(doubanPlugin);
|
||||
}
|
||||
|
||||
getSupportType(): SupportType {
|
||||
return SupportType.music;
|
||||
}
|
||||
|
||||
getHighQuantityImageUrl(fileName:string):string{
|
||||
return `https://img1.doubanio.com/view/subject/m/public/${fileName}`;
|
||||
}
|
||||
|
||||
getSubjectUrl(id:string):string{
|
||||
return `https://music.douban.com/subject/${id}/`;
|
||||
}
|
||||
|
||||
parseVariable(beforeContent: string, variableMap:Map<string, DataField>, extract: DoubanMusicSubject, context: HandleContext): void {
|
||||
}
|
||||
|
||||
support(extract: DoubanSubject): boolean {
|
||||
return extract && extract.type && (extract.type.contains("音乐") || extract.type.contains("Music") || extract.type.contains("music"));
|
||||
}
|
||||
|
||||
analysisUser(html: CheerioAPI, context: HandleContext): {data:CheerioAPI , userState: UserStateSubject} {
|
||||
const rate = html('input#n_rating').val();
|
||||
const tagsStr = html('span#rating').next().next().text().trim();
|
||||
const tags = tagsStr ? tagsStr.replace('标签:', '').trim().split(' ') : null;
|
||||
const stateWord = html('div#interest_sect_level > div.a_stars > span.mr10').text().trim();
|
||||
const collectionDateStr = html('div#interest_sect_level > div.a_stars > span.mr10').next().text().trim();
|
||||
const userState1 = DoubanAbstractLoadHandler.getUserState(stateWord);
|
||||
const component = html('span#rating').next().next().next().next().text().trim();
|
||||
|
||||
const userState: UserStateSubject = {
|
||||
tags: tags,
|
||||
rate: rate?Number(rate):null,
|
||||
state: userState1,
|
||||
collectionDate: collectionDateStr?moment(collectionDateStr, 'YYYY-MM-DD').toDate():null,
|
||||
comment: component
|
||||
}
|
||||
return {data: html, userState: userState};
|
||||
}
|
||||
|
||||
parseSubjectFromHtml(html: CheerioAPI, context: HandleContext): DoubanMusicSubject {
|
||||
const title = html(html("head > meta[property= 'og:title']").get(0)).attr("content");
|
||||
let desc:string = html("span.all.hidden").text();
|
||||
if (!desc) {
|
||||
desc = html("span[property='v:summary']").text();
|
||||
}
|
||||
if (!desc) {
|
||||
desc = html(html("head > meta[property= 'og:description']").get(0)).attr("content");
|
||||
}
|
||||
|
||||
const url = html(html("head > meta[property= 'og:url']").get(0)).attr("content");
|
||||
const image = html(html("head > meta[property= 'og:image']").get(0)).attr("content");
|
||||
const score = html(html("#interest_sectl > div > div.rating_self.clearfix > strong[property= 'v:average']").get(0)).text();
|
||||
const detailDom = html(html("#info").get(0));
|
||||
const publish = detailDom.find("span.pl");
|
||||
|
||||
const 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();
|
||||
const 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);
|
||||
})
|
||||
|
||||
const idPattern = /(\d){5,10}/g;
|
||||
const id = idPattern.exec(url);
|
||||
|
||||
const trackItems = html('.track-list .track-items li');
|
||||
const tracks = Array.from(trackItems).map(item => html(item).text().trim());
|
||||
|
||||
const result: DoubanMusicSubject = {
|
||||
image: image,
|
||||
imageUrl: image,
|
||||
datePublished: valueMap.has('datePublished') ? new Date(valueMap.get('datePublished')) : undefined,
|
||||
publisher: valueMap.has('publisher') ? valueMap.get('publisher') : "",
|
||||
score: Number(score),
|
||||
records: valueMap.has('records') ? Number(valueMap.get('records')) : null,
|
||||
id: id ? id[0] : "",
|
||||
type: this.getSupportType(),
|
||||
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') : "",
|
||||
menu: tracks
|
||||
};
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
const MusicKeyValueMap: Map<string, string> = new Map(
|
||||
[['表演者:', 'actor'],
|
||||
['流派:', 'genre'],
|
||||
['发行时间:', 'datePublished'],
|
||||
['专辑类型:', 'albumType'],
|
||||
['介质:', 'medium'],
|
||||
['出版者:', 'publisher'],
|
||||
['唱片数:', 'records'],
|
||||
['条形码:', 'barcode']]
|
||||
);
|
||||