mirror of
https://github.com/Wanxp/obsidian-douban.git
synced 2026-04-05 01:28:46 +08:00
fix login notice
This commit is contained in:
parent
ae7c16430d
commit
fb25fdc08e
@ -1,13 +1,13 @@
|
||||
//简体中文
|
||||
export default {
|
||||
//main.ts
|
||||
'110001': 'searcher douban by current file name',
|
||||
'110002': 'searcher douban and import to current file',
|
||||
'110001': 'search douban by current file name',
|
||||
'110002': 'search douban and import to current file',
|
||||
'110003': `Enter Search Term:`,
|
||||
'110004': `Search`,
|
||||
'110005': `Cancel`,
|
||||
'110006': `sync douban personal book-movie-music to Obsidian`,
|
||||
'110101': 'searcher douban and create file',
|
||||
'110101': 'search douban and create file',
|
||||
'110201': `{0} already exists`,
|
||||
'110202': `{0} template can not read`,
|
||||
'110103': 'sync personal data from douban',
|
||||
|
||||
@ -3,8 +3,8 @@ import { i18nHelper } from "../lang/helper";
|
||||
import SettingsManager from "../douban/setting/SettingsManager";
|
||||
import { request, RequestUrlParam } from "obsidian";
|
||||
import DoubanHumanCheckModel from "../douban/component/DoubanHumanCheckModel";
|
||||
import {LoginUtil} from "./LoginUtil";
|
||||
|
||||
import StringUtil from './StringUtil'
|
||||
const {https} = require("follow-redirects");
|
||||
|
||||
export default class HttpUtil {
|
||||
@ -38,11 +38,14 @@ export default class HttpUtil {
|
||||
})
|
||||
|
||||
response.on("end", function () {
|
||||
let data = Buffer.concat(chunks, size)
|
||||
let html = data.toString()
|
||||
const data = Buffer.concat(chunks, size)
|
||||
const html = data.toString()
|
||||
if (settingsManager) {
|
||||
settingsManager.debug(`Obsidian-Douban:从网络获取网页完成:\nhtml:\n${html}`);
|
||||
}
|
||||
if (LoginUtil.contentNeedLogin(html)) {
|
||||
rejects(new Error(i18nHelper.getMessage('140304')));
|
||||
}
|
||||
resolve(html)
|
||||
})
|
||||
})
|
||||
@ -58,14 +61,14 @@ export default class HttpUtil {
|
||||
// Cookie: 'll="108296"; bid=xHRJLeWBrjQ; _pk_id.100001.8cb4=f8f83e81ec224a1a.1691572669.; __utmv=30149280.13103; __yadk_uid=ce95W7OsgT0iKFceWgbMSUdw1oOqxNTk; __gads=ID=62585f60f3f637d0-2234f63fc6e200a5:T=1691572672:RT=1691572672:S=ALNI_MaIqTxSWHsfpnX9nAmMHcPQEsaezg; __gpi=UID=00000c29a9f98e5b:T=1691572672:RT=1691572672:S=ALNI_MbLAq8XNoKrRPKNqGCMdgXSPZvidw; ap_v=0,6.0; __utma=30149280.135860784.1691572641.1691572641.1694509646.2; __utmc=30149280; __utmz=30149280.1694509646.2.2.utmcsr=baidu|utmccn=(organic)|utmcmd=organic; _pk_ref.100001.8cb4=%5B%22%22%2C%22%22%2C1694509648%2C%22https%3A%2F%2Fmovie.douban.com%2Ftv%2F%22%5D; _pk_ses.100001.8cb4=1; __utmt=1; dbcl2="131038721:LUssju34QFw"; ck=dCQj; push_noty_num=0; push_doumail_num=0; __utmb=30149280.3.10.1694509646'
|
||||
public static httpRequestGetJson(url: string, headers: any, settingsManager?: SettingsManager): Promise<any> {
|
||||
const {['Accept-Encoding']: acceptEncoding, ...headersInner} = headers;
|
||||
let options = {
|
||||
const options = {
|
||||
headers: headersInner
|
||||
}
|
||||
settingsManager.debug(`Obsidian-Douban:从网络获取json开始:\nurl:${url}\nheaders:${JSON.stringify(headers)}`);
|
||||
return new Promise((resolve, rejects) => {
|
||||
https.get(url, { ...options }, function (response: any) {
|
||||
let chunks: any = [],
|
||||
size = 0;
|
||||
const chunks: any = [];
|
||||
let size = 0;
|
||||
if (response.status == 403) {
|
||||
rejects(new Error(i18nHelper.getMessage('130106')));
|
||||
}
|
||||
@ -75,11 +78,14 @@ export default class HttpUtil {
|
||||
})
|
||||
|
||||
response.on("end", function () {
|
||||
let data = Buffer.concat(chunks, size)
|
||||
let html = data.toString()
|
||||
const data = Buffer.concat(chunks, size)
|
||||
const html = data.toString()
|
||||
if (settingsManager) {
|
||||
settingsManager.debug(`Obsidian-Douban:从网络获取网页完成:\nhtml:\n${html}`);
|
||||
}
|
||||
if (LoginUtil.contentNeedLogin(html)) {
|
||||
rejects(new Error(i18nHelper.getMessage('140304')));
|
||||
}
|
||||
resolve(html)
|
||||
})
|
||||
})
|
||||
|
||||
6
src/org/wanxp/utils/LoginUtil.ts
Normal file
6
src/org/wanxp/utils/LoginUtil.ts
Normal file
@ -0,0 +1,6 @@
|
||||
export class LoginUtil {
|
||||
|
||||
static contentNeedLogin(content:string):boolean {
|
||||
return content && content.indexOf("你要的东西不在这, 到别处看看吧。") > -1;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user