mirror of
https://github.com/Wanxp/obsidian-douban.git
synced 2026-04-05 01:28:46 +08:00
fix: cover image do not show error
This commit is contained in:
parent
3e22d97e52
commit
240f71f635
11
README.md
11
README.md
@ -145,15 +145,16 @@
|
|||||||
|
|
||||||
|
|
||||||
## 免责声明
|
## 免责声明
|
||||||
1. 本程序没有爬取任何书影音等内容,只供技术研究使用。没有侵犯书影音作者版权和豆瓣官方利益。如有任何侵权行为,请联系我删除。
|
1. 建议使用本插件前,一定要至少有一种方式备份你的数据,以防万一。
|
||||||
2. 本程序仅供学习交流使用。
|
2. 本程序没有爬取任何书影音等内容,只供技术研究使用。没有侵犯书影音作者版权和豆瓣官方利益。如有任何侵权行为,请联系我删除。
|
||||||
3. 虽然极力避免,但还是有可能纰漏,所以因使用插件造成的损失,由使用者本人承担。不同操作会有何种影响,请参照<a href="#impact">影响</a>
|
3. 本程序仅供学习交流使用。
|
||||||
4. 使用或修改本插件,即视为同意上述免责声明。
|
4. 虽然极力避免,但还是有可能纰漏,所以因使用插件造成的损失,由使用者本人承担。不同操作会有何种影响,请参照<a href="#impact">影响</a>
|
||||||
|
5. 使用或修改本插件,即视为同意上述免责声明。
|
||||||
## <span id="impact" >影响</span>
|
## <span id="impact" >影响</span>
|
||||||
注意: 除了在同步书影音数据时勾选 `替换同名文档` 有可能会修改同路径同文档名的笔记外,其余操作均不会修改已有笔记。
|
注意: 除了在同步书影音数据时勾选 `替换同名文档` 有可能会修改同路径同文档名的笔记外,其余操作均不会修改已有笔记。
|
||||||
|
|
||||||
| 操作 | 条件 | 影响 | 举例 |
|
| 操作 | 条件 | 影响 | 举例 |
|
||||||
|---------|-----------------|---------------------------|-----------------------------------------------------------------------------------------------|
|
|---------|------------------|---------------------------|-----------------------------------------------------------------------------------------------|
|
||||||
| 导入书影音数据 | 默认条件 | 新建一条名为所选条目的笔记 | 如搜索蝙蝠侠并选中导入,则会创建笔记 《蝙蝠侠》 |
|
| 导入书影音数据 | 默认条件 | 新建一条名为所选条目的笔记 | 如搜索蝙蝠侠并选中导入,则会创建笔记 《蝙蝠侠》 |
|
||||||
| 导入书影音数据 | 已有同名笔记 | 无任何影响,提示已经存在同名笔记,不会修改已有笔记 | 如搜索蝙蝠侠并选中导入,但因存在同路径同名称笔记,则会不会创建笔记 |
|
| 导入书影音数据 | 已有同名笔记 | 无任何影响,提示已经存在同名笔记,不会修改已有笔记 | 如搜索蝙蝠侠并选中导入,但因存在同路径同名称笔记,则会不会创建笔记 |
|
||||||
| 导入书影音数据 | 配置 `笔记名称`值包含路径 | 若没有此路径则会创建对应文件名 | 如搜索蝙蝠侠并选中导入,配置`笔记名称`值为`/data/{{type}}/{{title}}`,则会创建文件夹`data/电影` |
|
| 导入书影音数据 | 配置 `笔记名称`值包含路径 | 若没有此路径则会创建对应文件名 | 如搜索蝙蝠侠并选中导入,配置`笔记名称`值为`/data/{{type}}/{{title}}`,则会创建文件夹`data/电影` |
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"id": "obsidian-douban-plugin",
|
"id": "obsidian-douban-plugin",
|
||||||
"name": "Douban",
|
"name": "Douban",
|
||||||
"version": "1.8.7",
|
"version": "1.8.8",
|
||||||
"minAppVersion": "0.12.0",
|
"minAppVersion": "0.12.0",
|
||||||
"description": "This is a plugin that can import movies/books/musics/notes/games info data from Douban for Obsidian .",
|
"description": "This is a plugin that can import movies/books/musics/notes/games info data from Douban for Obsidian .",
|
||||||
"author": "Wanxp",
|
"author": "Wanxp",
|
||||||
|
|||||||
2469
package-lock.json
generated
2469
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "obsidian-douban-plugin",
|
"name": "obsidian-douban-plugin",
|
||||||
"version": "1.8.7",
|
"version": "1.8.8",
|
||||||
"description": "This is a plugin for Obsidian (https://obsidian.md) that can import data from Douban (https://www.douban.com/).",
|
"description": "This is a plugin for Obsidian (https://obsidian.md) that can import data from Douban (https://www.douban.com/).",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@ -461,13 +461,14 @@ export default abstract class DoubanAbstractLoadHandler<T extends DoubanSubject>
|
|||||||
if (!folder) {
|
if (!folder) {
|
||||||
folder = DEFAULT_SETTINGS.attachmentPath;
|
folder = DEFAULT_SETTINGS.attachmentPath;
|
||||||
}
|
}
|
||||||
|
const referHeaders = {'referer': image};
|
||||||
if ((syncConfig ? syncConfig.cacheHighQuantityImage : context.settings.cacheHighQuantityImage) && context.userComponent.isLogin()) {
|
if ((syncConfig ? syncConfig.cacheHighQuantityImage : context.settings.cacheHighQuantityImage) && context.userComponent.isLogin()) {
|
||||||
try {
|
try {
|
||||||
const fileNameSpilt = filename.split('.');
|
const fileNameSpilt = filename.split('.');
|
||||||
const highFilename = fileNameSpilt.first() + '.jpg';
|
const highFilename = fileNameSpilt.first() + '.jpg';
|
||||||
|
|
||||||
const highImage = this.getHighQuantityImageUrl(highFilename);
|
const highImage = this.getHighQuantityImageUrl(highFilename);
|
||||||
const resultValue = await context.netFileHandler.downloadFile(highImage, folder, highFilename, context, false);
|
const resultValue = await context.netFileHandler.downloadFile(highImage, folder, highFilename, context, false, referHeaders);
|
||||||
if (resultValue && resultValue.success) {
|
if (resultValue && resultValue.success) {
|
||||||
extract.image = resultValue.filepath;
|
extract.image = resultValue.filepath;
|
||||||
return;
|
return;
|
||||||
@ -477,7 +478,7 @@ export default abstract class DoubanAbstractLoadHandler<T extends DoubanSubject>
|
|||||||
console.error('下载高清封面失败,将会使用普通封面')
|
console.error('下载高清封面失败,将会使用普通封面')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const resultValue = await context.netFileHandler.downloadFile(image, folder, filename, context, true);
|
const resultValue = await context.netFileHandler.downloadFile(image, folder, filename, context, true, referHeaders);
|
||||||
if (resultValue && resultValue.success) {
|
if (resultValue && resultValue.success) {
|
||||||
extract.image = resultValue.filepath;
|
extract.image = resultValue.filepath;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -181,7 +181,6 @@ export function constructLoginCookieSettingsUI(containerEl: HTMLElement, parentC
|
|||||||
return button
|
return button
|
||||||
.setIcon('check')
|
.setIcon('check')
|
||||||
.onClick(async () => {
|
.onClick(async () => {
|
||||||
button.setDisabled(true);
|
|
||||||
manager.debug(`配置界面:确认输入Cookie`);
|
manager.debug(`配置界面:确认输入Cookie`);
|
||||||
const user:User = await manager.plugin.userComponent.loginCookie(manager.getCookieTemp())
|
const user:User = await manager.plugin.userComponent.loginCookie(manager.getCookieTemp())
|
||||||
if (!user || !user.id) {
|
if (!user || !user.id) {
|
||||||
|
|||||||
@ -197,7 +197,7 @@ PS: This file could be delete if you want to.
|
|||||||
'121402': `Display status bar when import data ?`,
|
'121402': `Display status bar when import data ?`,
|
||||||
|
|
||||||
'121430': `Save Attachment File`,
|
'121430': `Save Attachment File`,
|
||||||
'121431': `Save attachment file to local disk, such as image ?`,
|
'121431': `Save attachment file to local disk, such as image ? If you do not enable this feature, it will not show cover image in note`,
|
||||||
'121432': `Attachment folder`,
|
'121432': `Attachment folder`,
|
||||||
'121433': `Attachment file created from Obsidian-Douban will be placed in this folder, If blank, they will be placed in the default location for this vault.`,
|
'121433': `Attachment file created from Obsidian-Douban will be placed in this folder, If blank, they will be placed in the default location for this vault.`,
|
||||||
'121434': `assets`,
|
'121434': `assets`,
|
||||||
|
|||||||
@ -209,12 +209,12 @@ export default {
|
|||||||
'121402': `当在导入数据时, 是否需要在状态栏显示处理状态? `,
|
'121402': `当在导入数据时, 是否需要在状态栏显示处理状态? `,
|
||||||
|
|
||||||
'121430': `保存图片附件`,
|
'121430': `保存图片附件`,
|
||||||
'121431': `导入数据会同步保存图片附件到本地文件夹, 如电影封面,书籍封面 `,
|
'121431': `导入数据会同步保存图片附件到本地文件夹, 如电影封面,书籍封面。如果需要显示封面,请保持开启该功能。`,
|
||||||
'121432': `附件存放位置`,
|
'121432': `附件存放位置`,
|
||||||
'121433': `保存的附件将会存放至该文件夹中. 如果为空, 笔记将会存放到默认位置(assets) `,
|
'121433': `保存的附件将会存放至该文件夹中. 如果为空, 笔记将会存放到默认位置(assets) `,
|
||||||
'121434': `assets`,
|
'121434': `assets`,
|
||||||
'121435': `保存高清封面`,
|
'121435': `保存高清封面`,
|
||||||
'121436': `高清封面图片质量更高清晰度更好,并且需要您在此插件登录豆瓣才能生效,若未登录则默认使用低精度版本封面`,
|
'121436': `高清封面图片质量更高清晰度更好, 需要您在此插件 登录豆瓣 才能生效, 若未登录则默认使用低精度版本封面`,
|
||||||
'121437': `登录后此功能才会生效`,
|
'121437': `登录后此功能才会生效`,
|
||||||
'121438': `高清封面图片质量更高, 清晰度更好, 但占用空间会比普通清晰度封面更多`,
|
'121438': `高清封面图片质量更高, 清晰度更好, 但占用空间会比普通清晰度封面更多`,
|
||||||
|
|
||||||
|
|||||||
@ -12,12 +12,20 @@ export default class NetFileHandler {
|
|||||||
this.fileHandler = fileHandler;
|
this.fileHandler = fileHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
async downloadFile(url: string, folder:string, filename: string, context:HandleContext, showError:boolean): Promise<{ success: boolean, error:string, filepath: string }> {
|
async downloadFile(url: string, folder:string, filename: string, context:HandleContext, showError:boolean, headers?:any): Promise<{ success: boolean, error:string, filepath: string }> {
|
||||||
|
const headersCookie = {Cookie: context.settings.loginCookiesContent}
|
||||||
|
const headersInner = {};
|
||||||
|
if(headers) {
|
||||||
|
Object.assign(headersInner, headers, headersCookie);
|
||||||
|
}else {
|
||||||
|
Object.assign(headersInner, headersCookie);
|
||||||
|
}
|
||||||
|
|
||||||
const requestUrlParam: RequestUrlParam = {
|
const requestUrlParam: RequestUrlParam = {
|
||||||
url: url,
|
url: url,
|
||||||
method: "GET",
|
method: "GET",
|
||||||
throw: true,
|
throw: true,
|
||||||
headers: {Cookie: context.settings.loginCookiesContent}
|
headers: headersInner
|
||||||
};
|
};
|
||||||
const filePath:string = FileUtil.join(folder, filename);
|
const filePath:string = FileUtil.join(folder, filename);
|
||||||
return requestUrl(requestUrlParam)
|
return requestUrl(requestUrlParam)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user