add function: save attachment files

This commit is contained in:
wanxp 2022-11-11 20:25:10 +08:00
parent 1a98def0d5
commit f522bf4a6d
8 changed files with 32 additions and 27 deletions

@ -20,7 +20,7 @@
</p>
Import Movie, Book, Music, Teleplay, Note, Game even Broadcast Data from Douban in [Obsidian](https://obsidian.md/)
在[Obsidian](https://obsidian.md/)使用并导入豆瓣中的电影/书籍/音乐/电视剧/日记/游戏甚至是广播, 包含评分/发布日期/演员表等信息
在[Obsidian](https://obsidian.md/)使用并导入豆瓣中的电影/书籍/音乐/电视剧/日记/游戏甚至是广播, 包含评分/发布日期/演员表等信息, 登录后还有个人阅读状态等信息
![background](./doc/background.png)
---
@ -30,6 +30,19 @@ If you want some features or have any questions about this plugin, create issues
- [Bugs, Issues, & Feature Requests](https://github.com/Wanxp/obsidian-douban/issues)
- [Development Roadmap](https://github.com/users/Wanxp/projects/1)
## Target/功能
- [x] Import Movie/导入电影
- [x] Import Teleplay/导入电视剧
- [x] Import Book/导入书籍
- [x] Import Music/导入音乐
- [x] Import Note/导入日记
- [x] Import Game/导入游戏
- [x] Personal Comment/导入个人的评论,评论时间,阅读状态,个人评分
- [x] Attachment Files/支持保存封面至本地
- [x] Custom Variables/支持自定义参数
- [ ] Broadcast/广播
## Support Field/支持的字段
(若有缺少想导入的字段, 欢迎提issues反馈)
@ -60,6 +73,8 @@ If you want some features or have any questions about this plugin, create issues
| 扩展7 | | | binding:装帧 | | | | |
| 扩展8 | | | producer: 出品方 | | | | |
## How to use
### Search
- Search Data And Create Note
@ -84,14 +99,8 @@ If you want some features or have any questions about this plugin, create issues
![Setting Example2](./doc/setting_en.gif)
## Target
- [x] Movie/电影
- [x] Teleplay/电视剧
- [x] Book/书籍
- [x] Music/音乐
- [x] Note/日记
- [x] Game/游戏
- [ ] Broadcast/广播
## How to install
### From Obsidian
@ -142,7 +151,6 @@ If you want some features or have any questions about this plugin, create issues
7. 享受开发吧
## 免责声明
本程序没有爬取任何书影音等内容,只供技术研究使用。没有侵犯书影音作者版权和豆瓣官方利益。如有任何侵权行为,请联系我删除。
1. 本程序没有爬取任何书影音等内容,只供技术研究使用。没有侵犯书影音作者版权和豆瓣官方利益。如有任何侵权行为,请联系我删除。
## Thanks

@ -128,7 +128,7 @@ doubanId: {{id}}
title: {{title}}
type: {{type}}
score: {{score}}
myRate: {{myRate}}
myRating: {{myRating}}
originalTitle: {{originalTitle}}
genre: {{genre}}
datePublished: {{datePublished}}
@ -158,7 +158,7 @@ series: {{series}}
type: {{type}}
author: {{author}}
score: {{score}}
myRate: {{myRate}}
myRating: {{myRating}}
datePublished: {{datePublished}}
translator: {{translator}}
publisher: {{publisher}}
@ -189,7 +189,7 @@ title: {{title}}
type: {{type}}
actor: {{actor}}
score: {{score}}
myRate: {{myRate}}
myRating: {{myRating}}
genre: {{genre}}
medium: {{medium}}
albumType: {{albumType}}
@ -228,7 +228,7 @@ title: {{title}}
aliases: {{aliases}}
type: {{type}}
score: {{score}}
myRate: {{myRate}}
myRating: {{myRating}}
dateTimePublished: {{datePublished}}
publisher: {{publisher}}
genre: {{genre}}
@ -252,7 +252,7 @@ doubanId: {{id}}
title: {{title}}
type: {{type}}
score: {{score}}
myRate: {{myRate}}
myRating: {{myRating}}
originalTitle: {{originalTitle}}
genre: {{genre}}
datePublished: {{datePublished}}

@ -15,7 +15,6 @@ export default class DoubanLoginModel {
constructor(containerEl: HTMLElement, settingsManager: SettingsManager) {
this.containerEl = containerEl;
this.settingsManager = settingsManager;
log.info('初始化登录页面');
const { remote } = require('electron');
const { BrowserWindow: RemoteBrowserWindow } = remote;

@ -133,7 +133,6 @@ export default abstract class DoubanAbstractLoadHandler<T extends DoubanSubject>
handle(url: string, context: HandleContext): void {
let headers = JSON.parse(this.doubanPlugin.settings.searchHeaders);
headers.Cookie = this.doubanPlugin.settings.loginCookiesContent;
console.log(JSON.stringify(headers))
const requestUrlParam: RequestUrlParam = {
url: url,
method: "GET",
@ -141,7 +140,6 @@ export default abstract class DoubanAbstractLoadHandler<T extends DoubanSubject>
throw: true
};
request(requestUrlParam)
.then((response) => {console.log(response.toString());return response})
.then(load)
.then(this.analysisUserState)
.then(({data, userState}) => {
@ -242,7 +240,7 @@ export default abstract class DoubanAbstractLoadHandler<T extends DoubanSubject>
private parseUserInfo(resultContent: string, extract: T, context: HandleContext, textMode: TemplateTextMode) {
const userState = extract.userState;
if ((resultContent.indexOf(DoubanUserParameter.MY_TAGS) >= 0 ||
resultContent.indexOf(DoubanUserParameter.MY_RATE) >= 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()) {
@ -253,7 +251,7 @@ export default abstract class DoubanAbstractLoadHandler<T extends DoubanSubject>
return resultContent;
}
return resultContent.replaceAll(DoubanUserParameter.MY_TAGS, this.handleSpecialContent(userState.tags, textMode, context))
.replaceAll(DoubanUserParameter.MY_RATE, this.handleSpecialContent(userState.rate, textMode))
.replaceAll(DoubanUserParameter.MY_RATING, this.handleSpecialContent(userState.rate, textMode))
.replaceAll(DoubanUserParameter.MY_STATE, this.getUserStateName(userState.state))
.replaceAll(DoubanUserParameter.MY_COMMENT, this.handleSpecialContent(userState.comment, textMode))
.replaceAll(DoubanUserParameter.MY_COLLECTION_DATE, moment(new Date()).format(context.settings.dateFormat))

@ -10,7 +10,7 @@ export interface UserStateSubject {
export const DoubanUserParameter = {
MY_TAGS: '{{myTags}}',
MY_RATE: '{{myRate}}',
MY_RATING: '{{myRating}}',
MY_STATE: '{{myState}}',
MY_COMMENT: '{{myComment}}',
MY_COLLECTION_DATE: '{{myCollectionDate}}',

@ -45,7 +45,7 @@ export function createFileSelectionSetting({name, desc, placeholder, key, manage
});
setting.addExtraButton((button) => {
button
.setIcon('document')
.setIcon('copy')
.setTooltip(i18nHelper.getMessage('121903'))
.onClick(async () => {
// @ts-ignore
@ -54,7 +54,7 @@ export function createFileSelectionSetting({name, desc, placeholder, key, manage
});
setting.addExtraButton((button) => {
button
.setIcon('copy')
.setIcon('document')
.setTooltip(i18nHelper.getMessage('121901'))
.onClick(async () => {
// @ts-ignore

@ -260,7 +260,7 @@ ${i18nHelper.getMessage('122004')}
${i18nHelper.getMessage('160225')}
<br>
<strong>myTags</strong> ${i18nHelper.getMessage('160226')}<br>
<strong>myRate</strong> ${i18nHelper.getMessage('160227')}<br>
<strong>myRating</strong> ${i18nHelper.getMessage('160227')}<br>
<strong>myState</strong> ${i18nHelper.getMessage('160228')}<br>
<strong>myComment</strong> ${i18nHelper.getMessage('160229')}<br>
<strong>myCollectionDate</strong> ${i18nHelper.getMessage('160230')}<br>

@ -154,8 +154,8 @@ export default {
'121701': `选择模板文件`,
'121901': `复制'基础'模板内容`,
'121903': `复制'有状态信息'的模板内容. 有状态信息指:模板中有登录后可以用的参数,如myRate(我的评分)`,
'121901': `复制基础模板内容`,
'121903': `复制含有我的评分的模板内容. 模板中有登录后可以用的参数,如我的评分, 我的阅读状态`,
'130101': `获取数据失败,{0}`,