fix movie/teleplay actor and director name wrong

This commit is contained in:
wanxp 2022-12-03 17:57:47 +08:00
parent 508e4c9303
commit 022b1e347f
3 changed files with 20 additions and 14 deletions

@ -102,9 +102,9 @@ export default abstract class DoubanAbstractLoadHandler<T extends DoubanSubject>
handleContentArray(array: any[], context: HandleContext, textMode: TemplateTextMode): string { handleContentArray(array: any[], context: HandleContext, textMode: TemplateTextMode): string {
let result; let result;
switch (textMode) { switch (textMode) {
case TemplateTextMode.YAML: // case TemplateTextMode.YAML:
result = array.map(YamlUtil.handleText).join(', '); // result = array.map(YamlUtil.handleText).join(', ');
break; // break;
default: default:
result = array.join(context.settings.arraySpilt); result = array.join(context.settings.arraySpilt);
} }
@ -463,7 +463,7 @@ export default abstract class DoubanAbstractLoadHandler<T extends DoubanSubject>
const fileNameSpilt = filename.split('.'); const fileNameSpilt = filename.split('.');
const highImage = `https://img9.doubanio.com/view/photo/raw/public/${fileNameSpilt.first()}.jpg` const highImage = `https://img9.doubanio.com/view/photo/raw/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); const {success, filepath} = await context.netFileHandler.downloadFile(highImage, folder, highFilename, context, false);
if (success) { if (success) {
extract.image = filepath; extract.image = filepath;
return; return;
@ -473,7 +473,7 @@ export default abstract class DoubanAbstractLoadHandler<T extends DoubanSubject>
console.error('下载高清封面失败,将会使用普通封面') console.error('下载高清封面失败,将会使用普通封面')
} }
} }
const {success, filepath} = await context.netFileHandler.downloadFile(image, folder, filename, context); const {success, filepath} = await context.netFileHandler.downloadFile(image, folder, filename, context, true);
if (success) { if (success) {
extract.image = filepath; extract.image = filepath;
} }

@ -12,7 +12,7 @@ export default class NetFileHandler {
this.fileHandler = fileHandler; this.fileHandler = fileHandler;
} }
async downloadFile(url: string, folder:string, filename: string, context:HandleContext): Promise<{ success: boolean, error:string, filepath: string }> { async downloadFile(url: string, folder:string, filename: string, context:HandleContext, showError:boolean): Promise<{ success: boolean, error:string, filepath: string }> {
const requestUrlParam: RequestUrlParam = { const requestUrlParam: RequestUrlParam = {
url: url, url: url,
method: "GET", method: "GET",
@ -26,11 +26,17 @@ export default class NetFileHandler {
}).then(() => { }).then(() => {
return {success: true, error: '', filepath: filePath}; return {success: true, error: '', filepath: filePath};
}) })
.catch(e => log .catch(e => {
if (showError) {
return log
.error( .error(
i18nHelper.getMessage('130101') i18nHelper.getMessage('130101')
.replace('{0}', e.toString()) .replace('{0}', e.toString())
, e)); , e);
}else {
console.error(e);
}
});
; ;
} }
} }

@ -15,15 +15,15 @@ export default class YamlUtil {
} }
public static handleText(text: string) { public static handleText(text: string) {
return YamlUtil.hasSpecialChar(text) ? YamlUtil.handleSpecialChar(text) return YamlUtil.hasSpecialChar(text) ? YamlUtil.handleSpecialChar(text.replaceAll('"', '\\"'))
.replaceAll('\n', '。') .replaceAll('\n', '。')
.replaceAll('。。', '。') : text; .replaceAll('。。', '。') : text;
} }
} }
export const SPECIAL_CHAR_REG = /[{}\[\]&*#?|\-<>=!%@:`,\n]/; export const SPECIAL_CHAR_REG = /[{}\[\]&*#?|\-<>=!%@:"`,\n]/;
export const TITLE_ALIASES_SPECIAL_CHAR_REG_G = /[{}\[\]&*#?|\-<>=!%@:`, \n]/g; export const TITLE_ALIASES_SPECIAL_CHAR_REG_G = /[{}\[\]&*#?|\-<>=!%@:"`, \n]/g;
const SPECIAL_CHAR_REG_REPLACE: Map<string, string> = new Map([ const SPECIAL_CHAR_REG_REPLACE: Map<string, string> = new Map([
['{', '\\{'], ['{', '\\{'],