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