mirror of
https://github.com/Wanxp/obsidian-douban.git
synced 2026-04-04 16:48:44 +08:00
add function: import high quantity image from douban
This commit is contained in:
parent
c9dd998d64
commit
f83a0b4c8e
@ -114,6 +114,7 @@ ${syncStatus.getHandle() == 0? '...' : i18nHelper.getMessage('110042') + ':' + T
|
|||||||
dataFilePath: (settings.dataFilePath == '' || settings.dataFilePath == null) ? DEFAULT_SETTINGS.dataFilePath : settings.dataFilePath,
|
dataFilePath: (settings.dataFilePath == '' || settings.dataFilePath == null) ? DEFAULT_SETTINGS.dataFilePath : settings.dataFilePath,
|
||||||
dataFileNamePath: (settings.dataFileNamePath == '' || settings.dataFileNamePath == null) ? DEFAULT_SETTINGS.dataFileNamePath : settings.dataFileNamePath,
|
dataFileNamePath: (settings.dataFileNamePath == '' || settings.dataFileNamePath == null) ? DEFAULT_SETTINGS.dataFileNamePath : settings.dataFileNamePath,
|
||||||
cacheImage: ( settings.cacheImage == null) ? DEFAULT_SETTINGS.cacheImage : settings.cacheImage,
|
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,
|
attachmentPath: (settings.attachmentPath == '' || settings.attachmentPath == null) ? DEFAULT_SETTINGS.attachmentPath : settings.attachmentPath,
|
||||||
templateFile: (settings.movieTemplateFile == '' || settings.movieTemplateFile == null) ? DEFAULT_SETTINGS.movieTemplateFile : settings.movieTemplateFile,
|
templateFile: (settings.movieTemplateFile == '' || settings.movieTemplateFile == null) ? DEFAULT_SETTINGS.movieTemplateFile : settings.movieTemplateFile,
|
||||||
incrementalUpdate: true,
|
incrementalUpdate: true,
|
||||||
@ -370,6 +371,18 @@ ${syncStatus.getHandle() == 0? '...' : i18nHelper.getMessage('110042') + ':' + T
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
.setDisabled(disable);
|
.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) {
|
showUpdateAllConfig(containerEl: HTMLElement, config: SyncConfig, disable:boolean) {
|
||||||
|
|||||||
@ -458,14 +458,15 @@ export default abstract class DoubanAbstractLoadHandler<T extends DoubanSubject>
|
|||||||
if (!folder) {
|
if (!folder) {
|
||||||
folder = DEFAULT_SETTINGS.attachmentPath;
|
folder = DEFAULT_SETTINGS.attachmentPath;
|
||||||
}
|
}
|
||||||
if (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 highImage = `https://img9.doubanio.com/view/photo/l/public/${fileNameSpilt.first()}.jpg`
|
|
||||||
const highFilename = fileNameSpilt.first() + '.jpg';
|
const highFilename = fileNameSpilt.first() + '.jpg';
|
||||||
const {success, filepath} = await context.netFileHandler.downloadFile(highImage, folder, highFilename, context, false);
|
|
||||||
if (success) {
|
const highImage = this.getHighQuantityImageUrl(highFilename);
|
||||||
extract.image = filepath;
|
const resultValue = await context.netFileHandler.downloadFile(highImage, folder, highFilename, context, false);
|
||||||
|
if (resultValue && resultValue.success) {
|
||||||
|
extract.image = resultValue.filepath;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}catch (e) {
|
}catch (e) {
|
||||||
@ -473,12 +474,14 @@ export default abstract class DoubanAbstractLoadHandler<T extends DoubanSubject>
|
|||||||
console.error('下载高清封面失败,将会使用普通封面')
|
console.error('下载高清封面失败,将会使用普通封面')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const {success, filepath} = await context.netFileHandler.downloadFile(image, folder, filename, context, true);
|
const resultValue = await context.netFileHandler.downloadFile(image, folder, filename, context, true);
|
||||||
if (success) {
|
if (resultValue && resultValue.success) {
|
||||||
extract.image = filepath;
|
extract.image = resultValue.filepath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abstract getHighQuantityImageUrl(fileName:string):string;
|
||||||
|
|
||||||
private async humanCheck(html:any, url:string):Promise<any> {
|
private async humanCheck(html:any, url:string):Promise<any> {
|
||||||
if (html && html.indexOf("<title>禁止访问</title>") != -1) {
|
if (html && html.indexOf("<title>禁止访问</title>") != -1) {
|
||||||
const loginModel = new DoubanHumanCheckModel(url);
|
const loginModel = new DoubanHumanCheckModel(url);
|
||||||
|
|||||||
@ -19,6 +19,10 @@ export default class DoubanBookLoadHandler extends DoubanAbstractLoadHandler<Dou
|
|||||||
return SupportType.BOOK;
|
return SupportType.BOOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getHighQuantityImageUrl(fileName:string):string{
|
||||||
|
return `https://img9.doubanio.com/view/subject/l/public/${fileName}`;
|
||||||
|
}
|
||||||
|
|
||||||
parseText(beforeContent: string, extract: DoubanBookSubject, context: HandleContext, textMode: TemplateTextMode): string {
|
parseText(beforeContent: string, extract: DoubanBookSubject, context: HandleContext, textMode: TemplateTextMode): string {
|
||||||
return beforeContent
|
return beforeContent
|
||||||
.replaceAll(DoubanBookParameter.author,
|
.replaceAll(DoubanBookParameter.author,
|
||||||
|
|||||||
@ -18,6 +18,9 @@ export default class DoubanGameLoadHandler extends DoubanAbstractLoadHandler<Dou
|
|||||||
getSupportType(): SupportType {
|
getSupportType(): SupportType {
|
||||||
return SupportType.GAME;
|
return SupportType.GAME;
|
||||||
}
|
}
|
||||||
|
getHighQuantityImageUrl(fileName:string):string{
|
||||||
|
return `https://img9.doubanio.com/lpic/${fileName}`;
|
||||||
|
}
|
||||||
|
|
||||||
parseText(beforeContent: string, extract: DoubanGameSubject, context: HandleContext): string {
|
parseText(beforeContent: string, extract: DoubanGameSubject, context: HandleContext): string {
|
||||||
const {settings} = context;
|
const {settings} = context;
|
||||||
|
|||||||
@ -22,6 +22,10 @@ export default class DoubanMovieLoadHandler extends DoubanAbstractLoadHandler<Do
|
|||||||
return SupportType.MOVIE;
|
return SupportType.MOVIE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getHighQuantityImageUrl(fileName:string):string{
|
||||||
|
return `https://img9.doubanio.com/view/photo/l/public/${fileName}`;
|
||||||
|
}
|
||||||
|
|
||||||
parseText(beforeContent: string, extract: DoubanMovieSubject, context: HandleContext): string {
|
parseText(beforeContent: string, extract: DoubanMovieSubject, context: HandleContext): string {
|
||||||
const {settings} = context;
|
const {settings} = context;
|
||||||
return beforeContent
|
return beforeContent
|
||||||
|
|||||||
@ -18,6 +18,10 @@ export default class DoubanMusicLoadHandler extends DoubanAbstractLoadHandler<Do
|
|||||||
return SupportType.MUSIC;
|
return SupportType.MUSIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getHighQuantityImageUrl(fileName:string):string{
|
||||||
|
return `https://img1.doubanio.com/view/subject/m/public/${fileName}`;
|
||||||
|
}
|
||||||
|
|
||||||
parseText(beforeContent: string, extract: DoubanMusicSubject, context: HandleContext): string {
|
parseText(beforeContent: string, extract: DoubanMusicSubject, context: HandleContext): string {
|
||||||
const {settings} = context;
|
const {settings} = context;
|
||||||
return beforeContent
|
return beforeContent
|
||||||
|
|||||||
@ -19,6 +19,10 @@ export default class DoubanNoteLoadHandler extends DoubanAbstractLoadHandler<Dou
|
|||||||
return SupportType.NOTE;
|
return SupportType.NOTE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getHighQuantityImageUrl(fileName:string):string{
|
||||||
|
return ``;
|
||||||
|
}
|
||||||
|
|
||||||
parseText(beforeContent: string, extract: DoubanNoteSubject, context: HandleContext): string {
|
parseText(beforeContent: string, extract: DoubanNoteSubject, context: HandleContext): string {
|
||||||
return beforeContent
|
return beforeContent
|
||||||
.replaceAll("{{authorUrl}}", extract.authorUrl ? extract.authorUrl : "")
|
.replaceAll("{{authorUrl}}", extract.authorUrl ? extract.authorUrl : "")
|
||||||
|
|||||||
@ -24,6 +24,10 @@ export default class DoubanOtherLoadHandler extends DoubanAbstractLoadHandler<Do
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getHighQuantityImageUrl(fileName:string):string{
|
||||||
|
return `https://img9.doubanio.com/view/photo/l/public/${fileName}`;
|
||||||
|
}
|
||||||
|
|
||||||
parseSubjectFromHtml(data: CheerioAPI, context: HandleContext): DoubanSubject {
|
parseSubjectFromHtml(data: CheerioAPI, context: HandleContext): DoubanSubject {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,6 +43,10 @@ export class DoubanTeleplayLoadHandler extends DoubanAbstractLoadHandler<DoubanT
|
|||||||
support(extract: DoubanSubject): boolean {
|
support(extract: DoubanSubject): boolean {
|
||||||
return extract && extract.type && (extract.type.contains("电视剧") || extract.type.contains("Teleplay") || extract.type.contains("teleplay"));
|
return extract && extract.type && (extract.type.contains("电视剧") || extract.type.contains("Teleplay") || extract.type.contains("teleplay"));
|
||||||
}
|
}
|
||||||
|
getHighQuantityImageUrl(fileName:string):string{
|
||||||
|
return `https://img9.doubanio.com/view/photo/l/public/${fileName}`;
|
||||||
|
}
|
||||||
|
|
||||||
analysisUser(html: CheerioAPI, context: HandleContext): {data:CheerioAPI , userState: UserStateSubject} {
|
analysisUser(html: CheerioAPI, context: HandleContext): {data:CheerioAPI , userState: UserStateSubject} {
|
||||||
let rate = html('input#n_rating').val();
|
let rate = html('input#n_rating').val();
|
||||||
const rating = html('span#rating');
|
const rating = html('span#rating');
|
||||||
|
|||||||
@ -10,6 +10,9 @@ import { UserStateSubject } from '../../data/model/UserStateSubject';
|
|||||||
|
|
||||||
//TODO will support in future version
|
//TODO will support in future version
|
||||||
class DoubanPageBroadcastLoadHandler extends DoubanAbstractLoadHandler<DoubanPageBroadcastSubject> {
|
class DoubanPageBroadcastLoadHandler extends DoubanAbstractLoadHandler<DoubanPageBroadcastSubject> {
|
||||||
|
getHighQuantityImageUrl(fileName: string): string {
|
||||||
|
throw new Error('Method not implemented.');
|
||||||
|
}
|
||||||
|
|
||||||
constructor(doubanPlugin: DoubanPlugin) {
|
constructor(doubanPlugin: DoubanPlugin) {
|
||||||
super(doubanPlugin);
|
super(doubanPlugin);
|
||||||
|
|||||||
@ -5,6 +5,8 @@ export interface SyncConfig {
|
|||||||
dataFilePath: string;
|
dataFilePath: string;
|
||||||
dataFileNamePath: string;
|
dataFileNamePath: string;
|
||||||
cacheImage:boolean;
|
cacheImage:boolean;
|
||||||
|
|
||||||
|
cacheHighQuantityImage:boolean;
|
||||||
attachmentPath: string;
|
attachmentPath: string;
|
||||||
templateFile: string;
|
templateFile: string;
|
||||||
incrementalUpdate: boolean;
|
incrementalUpdate: boolean;
|
||||||
|
|||||||
@ -197,7 +197,7 @@ PS: This file could be delete if you want to.
|
|||||||
'121435': `Save High Definition Cover`,
|
'121435': `Save High Definition Cover`,
|
||||||
'121436': `High Definition Cover looks better but it will take more space, and you must login douban in this plugin`,
|
'121436': `High Definition Cover looks better but it will take more space, and you must login douban in this plugin`,
|
||||||
'121437': `Please login first, Then this function could be enable`,
|
'121437': `Please login first, Then this function could be enable`,
|
||||||
|
'121438': `High Definition Cover looks better but it will take more space`,
|
||||||
|
|
||||||
|
|
||||||
'121501': `Note folder`,
|
'121501': `Note folder`,
|
||||||
|
|||||||
@ -39,7 +39,7 @@ export default {
|
|||||||
'110040': `仅同步上面'笔记存放位置'目录中最近新增/同步失败/未同步的部分,不同步已同步的内容.若关闭则会全量同步.增量同步会更快,适合之前同步中途失败停止或最近有豆瓣新增了内容,全量同步适合修改了模板或修改了存放路径情况下进行.`,
|
'110040': `仅同步上面'笔记存放位置'目录中最近新增/同步失败/未同步的部分,不同步已同步的内容.若关闭则会全量同步.增量同步会更快,适合之前同步中途失败停止或最近有豆瓣新增了内容,全量同步适合修改了模板或修改了存放路径情况下进行.`,
|
||||||
'110041': `使用增量`,
|
'110041': `使用增量`,
|
||||||
'110042': `预计处理时间`,
|
'110042': `预计处理时间`,
|
||||||
'110043': `同步目录加载中`,
|
'110043': `正在获取需要同步的列表, 请稍后`,
|
||||||
|
|
||||||
'110050': `类型`,
|
'110050': `类型`,
|
||||||
'110051': `数量`,
|
'110051': `数量`,
|
||||||
@ -209,7 +209,7 @@ export default {
|
|||||||
'121435': `保存高清封面`,
|
'121435': `保存高清封面`,
|
||||||
'121436': `高清封面图片质量更高清晰度更好,并且需要您在此插件登录豆瓣才能生效,若未登录则默认使用低精度版本封面`,
|
'121436': `高清封面图片质量更高清晰度更好,并且需要您在此插件登录豆瓣才能生效,若未登录则默认使用低精度版本封面`,
|
||||||
'121437': `登录后此功能才会生效`,
|
'121437': `登录后此功能才会生效`,
|
||||||
|
'121438': `高清封面图片质量更高, 清晰度更好, 但占用空间会比普通清晰度封面更多`,
|
||||||
|
|
||||||
'121501': `笔记存放位置`,
|
'121501': `笔记存放位置`,
|
||||||
'121502': `创建的笔记将会存放至该文件夹中. 如果为空, 笔记将会存放到Obsidian的默认位置`,
|
'121502': `创建的笔记将会存放至该文件夹中. 如果为空, 笔记将会存放到Obsidian的默认位置`,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user