Skip to content

Commit

Permalink
fix: mixEffect does not change extend name correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
drunkg00se committed Aug 16, 2024
1 parent 5a00af3 commit ed31e63
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/lib/converter/adapter/png.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export function mixPngEffect(
logger.timeEnd(convertMeta.id);

if (!e.data) {
return reject(new Error('Mix Effect convert Failed' + convertMeta.id));
return reject(new Error('Mix Effect convert Failed ' + convertMeta.id));
}

resolve(e.data as EffectReturn);
Expand Down
26 changes: 19 additions & 7 deletions src/sites/pixiv/downloadConfigBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,26 +313,38 @@ export class PixivDownloadConfig extends DownloadConfigBuilder<PixivSource> {

// src 默认为p0地址,downloadPage为0时不需更改
const imgSrc = downloadPage ? this.getImgSrc(downloadPage) : src;
const pathPattern = supportSubPath
? this.getFullpathPattern()
: this.getFilenamePattern() + '.' + extendName;

const path = this.buildPattern(pathPattern, downloadPage ? downloadPage : 0);
const filename = path.slice(path.lastIndexOf('/') + 1);

let path: string;
let hooks: ReturnType<(typeof downloaderHooks)['getHooks']>;
let source: PixivSource;

if (config.get('mixEffect') && btn) {
const effectExt = this.getMixEffectFormat();
const pathPatternNoExt = supportSubPath
? this.getFullpathPattern().slice(0, -4)
: this.getFilenamePattern();

const pathPattern = pathPatternNoExt + '.' + effectExt;

path = this.buildPattern(pathPattern, downloadPage ? downloadPage : 0);
const filename = path.slice(path.lastIndexOf('/') + 1);

hooks = downloaderHooks.getHooks({ ...this.meta, pageCount: 1 }, 'mixEffect', btn);
source = {
...this.meta,
pageCount: 1,
extendName: this.getMixEffectFormat(),
extendName: effectExt,
filename,
order: downloadPage ?? 0
};
} else {
const pathPattern = supportSubPath
? this.getFullpathPattern()
: this.getFilenamePattern() + '.' + extendName;

path = this.buildPattern(pathPattern, downloadPage ? downloadPage : 0);
const filename = path.slice(path.lastIndexOf('/') + 1);

hooks = downloaderHooks.getHooks({ ...this.meta, pageCount: 1 }, 'download', btn);
source = {
...this.meta,
Expand Down

0 comments on commit ed31e63

Please sign in to comment.