pixivflow 2.10.24 → 2.10.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/SchedulerCommand.d.ts.map +1 -1
- package/dist/commands/SchedulerCommand.js +11 -78
- package/dist/commands/SchedulerCommand.js.map +1 -1
- package/dist/commands/SchedulerRunOnceCommand.d.ts +24 -0
- package/dist/commands/SchedulerRunOnceCommand.d.ts.map +1 -0
- package/dist/commands/SchedulerRunOnceCommand.js +68 -0
- package/dist/commands/SchedulerRunOnceCommand.js.map +1 -0
- package/dist/commands/index.d.ts +2 -1
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +4 -1
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/scheduler-runtime.d.ts +28 -0
- package/dist/commands/scheduler-runtime.d.ts.map +1 -0
- package/dist/commands/scheduler-runtime.js +93 -0
- package/dist/commands/scheduler-runtime.js.map +1 -0
- package/dist/package.json +1 -1
- package/dist/webui/package.json +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchedulerCommand.d.ts","sourceRoot":"","sources":["../../src/commands/SchedulerCommand.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"SchedulerCommand.d.ts","sourceRoot":"","sources":["../../src/commands/SchedulerCommand.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAKrE;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,WAAW;IAC/C,QAAQ,CAAC,IAAI,eAAe;IAC5B,QAAQ,CAAC,WAAW,oDAAoD;IACxE,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAS;IACnC,QAAQ,CAAC,QAAQ;;;;MAIf;IAEI,OAAO,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;IAyDjF,OAAO,CAAC,uBAAuB;IAQ/B,QAAQ,IAAI,MAAM;CAYnB"}
|
|
@@ -7,22 +7,15 @@ exports.SchedulerCommand = void 0;
|
|
|
7
7
|
const Command_1 = require("./Command");
|
|
8
8
|
const metadata_1 = require("./metadata");
|
|
9
9
|
const config_1 = require("../config");
|
|
10
|
-
const Database_1 = require("../storage/Database");
|
|
11
|
-
const AuthClient_1 = require("../pixiv/AuthClient");
|
|
12
|
-
const PixivClient_1 = require("../pixiv/PixivClient");
|
|
13
|
-
const FileService_1 = require("../download/FileService");
|
|
14
|
-
const DownloadManager_1 = require("../download/DownloadManager");
|
|
15
|
-
const token_maintenance_1 = require("../utils/token-maintenance");
|
|
16
10
|
const MultiScheduleManager_1 = require("../scheduler/MultiScheduleManager");
|
|
17
|
-
const
|
|
18
|
-
const placeholders_1 = require("../config/placeholders");
|
|
11
|
+
const scheduler_runtime_1 = require("./scheduler-runtime");
|
|
19
12
|
/**
|
|
20
13
|
* Scheduler command - Start scheduler (default if enabled in config)
|
|
21
14
|
*/
|
|
22
15
|
class SchedulerCommand extends Command_1.BaseCommand {
|
|
23
16
|
name = 'scheduler';
|
|
24
17
|
description = 'Start scheduler (default if enabled in config)';
|
|
25
|
-
aliases = ['
|
|
18
|
+
aliases = ['s'];
|
|
26
19
|
metadata = {
|
|
27
20
|
category: metadata_1.CommandCategory.DOWNLOAD,
|
|
28
21
|
requiresAuth: true,
|
|
@@ -31,64 +24,8 @@ class SchedulerCommand extends Command_1.BaseCommand {
|
|
|
31
24
|
async execute(context, args) {
|
|
32
25
|
try {
|
|
33
26
|
const configPath = (0, config_1.getConfigPath)(args.options.config);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const config = (0, config_1.loadConfig)(configPath, false, false);
|
|
37
|
-
const database = new Database_1.Database(config.storage.databasePath);
|
|
38
|
-
database.migrate();
|
|
39
|
-
const auth = new AuthClient_1.PixivAuth(config.pixiv, config.network, database, configPath);
|
|
40
|
-
const pixivClient = new PixivClient_1.PixivClient(auth, config);
|
|
41
|
-
const fileService = new FileService_1.FileService(config.storage);
|
|
42
|
-
await fileService.initialise();
|
|
43
|
-
// Start token maintenance service for automatic token refresh
|
|
44
|
-
const tokenMaintenance = (0, token_maintenance_1.createTokenMaintenanceService)(auth, config.pixiv, config.network, config);
|
|
45
|
-
if (tokenMaintenance) {
|
|
46
|
-
tokenMaintenance.start();
|
|
47
|
-
}
|
|
48
|
-
let activeDownloadManager = null;
|
|
49
|
-
const immutableFingerprint = this.getImmutableFingerprint(config);
|
|
50
|
-
const runJob = async (snapshot, schedule) => {
|
|
51
|
-
const runtimeConfig = (0, placeholders_1.processConfigPlaceholders)(snapshot);
|
|
52
|
-
const targets = (0, schedules_1.selectScheduleTargets)(runtimeConfig.targets, schedule);
|
|
53
|
-
const scopedConfig = { ...runtimeConfig, targets };
|
|
54
|
-
if (targets.length === 0) {
|
|
55
|
-
context.logger.warn('Scheduled plan has no selected targets; skipping', {
|
|
56
|
-
scheduleId: schedule.id,
|
|
57
|
-
targetIds: schedule.targetIds,
|
|
58
|
-
});
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
const downloadManager = new DownloadManager_1.DownloadManager(scopedConfig, pixivClient, database, fileService);
|
|
62
|
-
activeDownloadManager = downloadManager;
|
|
63
|
-
await downloadManager.initialise();
|
|
64
|
-
// Apply initial delay if configured
|
|
65
|
-
if (runtimeConfig.initialDelay && runtimeConfig.initialDelay > 0) {
|
|
66
|
-
context.logger.info(`Waiting ${runtimeConfig.initialDelay}ms before starting download...`, {
|
|
67
|
-
scheduleId: schedule.id,
|
|
68
|
-
});
|
|
69
|
-
await new Promise(resolve => setTimeout(resolve, runtimeConfig.initialDelay));
|
|
70
|
-
}
|
|
71
|
-
context.logger.info('='.repeat(60));
|
|
72
|
-
context.logger.info('Starting scheduled Pixiv download plan', {
|
|
73
|
-
scheduleId: schedule.id,
|
|
74
|
-
targets: targets.map(target => target.id ?? target.tag ?? target.filterTag ?? target.type),
|
|
75
|
-
});
|
|
76
|
-
context.logger.info('='.repeat(60));
|
|
77
|
-
const startTime = Date.now();
|
|
78
|
-
try {
|
|
79
|
-
await downloadManager.runAllTargets();
|
|
80
|
-
}
|
|
81
|
-
finally {
|
|
82
|
-
if (activeDownloadManager === downloadManager)
|
|
83
|
-
activeDownloadManager = null;
|
|
84
|
-
}
|
|
85
|
-
const duration = Math.round((Date.now() - startTime) / 1000);
|
|
86
|
-
context.logger.info('='.repeat(60));
|
|
87
|
-
context.logger.info(`Scheduled download plan finished (took ${duration}s)`, {
|
|
88
|
-
scheduleId: schedule.id,
|
|
89
|
-
});
|
|
90
|
-
context.logger.info('='.repeat(60));
|
|
91
|
-
};
|
|
27
|
+
const runtime = await (0, scheduler_runtime_1.createSchedulerRuntime)(args.options.config);
|
|
28
|
+
const immutableFingerprint = this.getImmutableFingerprint(runtime.config);
|
|
92
29
|
const manager = new MultiScheduleManager_1.MultiScheduleManager({
|
|
93
30
|
configPath,
|
|
94
31
|
loadConfig: () => {
|
|
@@ -98,23 +35,19 @@ class SchedulerCommand extends Command_1.BaseCommand {
|
|
|
98
35
|
}
|
|
99
36
|
return next;
|
|
100
37
|
},
|
|
101
|
-
execute: runJob,
|
|
102
|
-
database,
|
|
38
|
+
execute: runtime.runJob,
|
|
39
|
+
database: runtime.database,
|
|
103
40
|
telemetry: {
|
|
104
|
-
beginRun: () => database.getOverviewStats().totalDownloads,
|
|
105
|
-
endRun: () => database.getOverviewStats().totalDownloads,
|
|
106
|
-
requestCancel: (reason) =>
|
|
41
|
+
beginRun: () => runtime.database.getOverviewStats().totalDownloads,
|
|
42
|
+
endRun: () => runtime.database.getOverviewStats().totalDownloads,
|
|
43
|
+
requestCancel: (reason) => runtime.cancelActive(reason),
|
|
107
44
|
},
|
|
108
45
|
});
|
|
109
|
-
const status = manager.start(config);
|
|
46
|
+
const status = manager.start(runtime.config);
|
|
110
47
|
const cleanup = () => {
|
|
111
48
|
context.logger.info('Shutting down PixivFlow');
|
|
112
49
|
manager.stop();
|
|
113
|
-
|
|
114
|
-
if (tokenMaintenance) {
|
|
115
|
-
tokenMaintenance.stop();
|
|
116
|
-
}
|
|
117
|
-
database.close();
|
|
50
|
+
runtime.close();
|
|
118
51
|
process.exit(0);
|
|
119
52
|
};
|
|
120
53
|
process.on('SIGINT', cleanup);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchedulerCommand.js","sourceRoot":"","sources":["../../src/commands/SchedulerCommand.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,uCAAwC;AACxC,yCAA6C;AAE7C,
|
|
1
|
+
{"version":3,"file":"SchedulerCommand.js","sourceRoot":"","sources":["../../src/commands/SchedulerCommand.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,uCAAwC;AACxC,yCAA6C;AAE7C,sCAAwE;AACxE,4EAAyE;AACzE,2DAA6D;AAE7D;;GAEG;AACH,MAAa,gBAAiB,SAAQ,qBAAW;IACtC,IAAI,GAAG,WAAW,CAAC;IACnB,WAAW,GAAG,gDAAgD,CAAC;IAC/D,OAAO,GAAa,CAAC,GAAG,CAAC,CAAC;IAC1B,QAAQ,GAAG;QAClB,QAAQ,EAAE,0BAAe,CAAC,QAAQ;QAClC,YAAY,EAAE,IAAI;QAClB,WAAW,EAAE,IAAI;KAClB,CAAC;IAEF,KAAK,CAAC,OAAO,CAAC,OAAuB,EAAE,IAAiB;QACtD,IAAI,CAAC;YACH,MAAM,UAAU,GAAG,IAAA,sBAAa,EAAC,IAAI,CAAC,OAAO,CAAC,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
|
1
|
+
/**
|
|
2
|
+
* Scheduler run-once command
|
|
3
|
+
*
|
|
4
|
+
* Runs every enabled schedule's download plan exactly once, then exits.
|
|
5
|
+
* This is the backend for the review-group "重抓/换一张" refetch button:
|
|
6
|
+
* a second scheduler daemon would never exit (and would double-fire cron),
|
|
7
|
+
* so refetch needs a bounded one-shot invocation instead.
|
|
8
|
+
*/
|
|
9
|
+
import { BaseCommand } from './Command';
|
|
10
|
+
import { CommandCategory } from './metadata';
|
|
11
|
+
import { CommandContext, CommandArgs, CommandResult } from './types';
|
|
12
|
+
export declare class SchedulerRunOnceCommand extends BaseCommand {
|
|
13
|
+
readonly name = "run-once";
|
|
14
|
+
readonly description = "Run all enabled schedules once immediately, then exit";
|
|
15
|
+
readonly aliases: string[];
|
|
16
|
+
readonly metadata: {
|
|
17
|
+
category: CommandCategory;
|
|
18
|
+
requiresAuth: boolean;
|
|
19
|
+
longRunning: boolean;
|
|
20
|
+
};
|
|
21
|
+
execute(context: CommandContext, args: CommandArgs): Promise<CommandResult>;
|
|
22
|
+
getUsage(): string;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=SchedulerRunOnceCommand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchedulerRunOnceCommand.d.ts","sourceRoot":"","sources":["../../src/commands/SchedulerRunOnceCommand.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAIrE,qBAAa,uBAAwB,SAAQ,WAAW;IACtD,QAAQ,CAAC,IAAI,cAAc;IAC3B,QAAQ,CAAC,WAAW,2DAA2D;IAC/E,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAsB;IAChD,QAAQ,CAAC,QAAQ;;;;MAIf;IAEI,OAAO,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;IAkCjF,QAAQ,IAAI,MAAM;CAWnB"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Scheduler run-once command
|
|
4
|
+
*
|
|
5
|
+
* Runs every enabled schedule's download plan exactly once, then exits.
|
|
6
|
+
* This is the backend for the review-group "重抓/换一张" refetch button:
|
|
7
|
+
* a second scheduler daemon would never exit (and would double-fire cron),
|
|
8
|
+
* so refetch needs a bounded one-shot invocation instead.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.SchedulerRunOnceCommand = void 0;
|
|
12
|
+
const Command_1 = require("./Command");
|
|
13
|
+
const metadata_1 = require("./metadata");
|
|
14
|
+
const schedules_1 = require("../scheduler/schedules");
|
|
15
|
+
const scheduler_runtime_1 = require("./scheduler-runtime");
|
|
16
|
+
class SchedulerRunOnceCommand extends Command_1.BaseCommand {
|
|
17
|
+
name = 'run-once';
|
|
18
|
+
description = 'Run all enabled schedules once immediately, then exit';
|
|
19
|
+
aliases = ['refetch', 'now'];
|
|
20
|
+
metadata = {
|
|
21
|
+
category: metadata_1.CommandCategory.DOWNLOAD,
|
|
22
|
+
requiresAuth: true,
|
|
23
|
+
longRunning: false,
|
|
24
|
+
};
|
|
25
|
+
async execute(context, args) {
|
|
26
|
+
const runtime = await (0, scheduler_runtime_1.createSchedulerRuntime)(args.options.config);
|
|
27
|
+
try {
|
|
28
|
+
const plans = (0, schedules_1.resolveSchedules)(runtime.config).filter((plan) => plan.enabled);
|
|
29
|
+
if (plans.length === 0) {
|
|
30
|
+
context.logger.warn('No enabled schedules; nothing to run');
|
|
31
|
+
return this.success('No enabled schedules to run');
|
|
32
|
+
}
|
|
33
|
+
context.logger.info('Running all enabled schedules once', {
|
|
34
|
+
schedules: plans.map((plan) => plan.id),
|
|
35
|
+
});
|
|
36
|
+
// Sequential: plans share one database and delivery outbox, and the
|
|
37
|
+
// scheduler daemon's per-plan concurrency is not needed for a refetch.
|
|
38
|
+
for (const plan of plans) {
|
|
39
|
+
await runtime.runJob(runtime.config, plan);
|
|
40
|
+
}
|
|
41
|
+
return this.success('Scheduled plans completed', {
|
|
42
|
+
schedules: plans.map((plan) => plan.id),
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
context.logger.error('Fatal error while running schedules once', {
|
|
47
|
+
error: error instanceof Error ? error.stack ?? error.message : String(error),
|
|
48
|
+
});
|
|
49
|
+
return this.failure(error instanceof Error ? error.message : String(error), { error });
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
runtime.close();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
getUsage() {
|
|
56
|
+
return `run-once
|
|
57
|
+
|
|
58
|
+
Run every enabled schedule's download plan once immediately, then exit.
|
|
59
|
+
Already-downloaded works are skipped and the next candidate is selected,
|
|
60
|
+
matching a normal scheduled run. Exits on completion (bounded process).
|
|
61
|
+
|
|
62
|
+
Examples:
|
|
63
|
+
pixivflow run-once # Run all schedules once
|
|
64
|
+
pixivflow run-once --config /path/config.json`;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.SchedulerRunOnceCommand = SchedulerRunOnceCommand;
|
|
68
|
+
//# sourceMappingURL=SchedulerRunOnceCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchedulerRunOnceCommand.js","sourceRoot":"","sources":["../../src/commands/SchedulerRunOnceCommand.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAEH,uCAAwC;AACxC,yCAA6C;AAE7C,sDAA0D;AAC1D,2DAA6D;AAE7D,MAAa,uBAAwB,SAAQ,qBAAW;IAC7C,IAAI,GAAG,UAAU,CAAC;IAClB,WAAW,GAAG,uDAAuD,CAAC;IACtE,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M,CAAC,KAAK,CAAC,0CAA0C,EAAE;gBAC/D,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAC7E,CAAC,CAAC;YACH,OAAO,IAAI,CAAC,OAAO,CACjB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EACtD,EAAE,KAAK,EAAE,CACV,CAAC;QACJ,CAAC;gBAAS,CAAC;YACT,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,CAAC;IACH,CAAC;IAED,QAAQ;QACN,OAAO;;;;;;;;gDAQqC,CAAC;IAC/C,CAAC;CACF;AAvDD,0DAuDC"}
|
package/dist/commands/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { RefreshCommand } from './RefreshCommand';
|
|
|
9
9
|
import { DownloadCommand } from './DownloadCommand';
|
|
10
10
|
import { RandomDownloadCommand } from './RandomDownloadCommand';
|
|
11
11
|
import { SchedulerCommand } from './SchedulerCommand';
|
|
12
|
+
import { SchedulerRunOnceCommand } from './SchedulerRunOnceCommand';
|
|
12
13
|
import { MigrateConfigCommand } from './MigrateConfigCommand';
|
|
13
14
|
import { NormalizeCommand } from './NormalizeCommand';
|
|
14
15
|
import { WebUICommand } from './WebUICommand';
|
|
@@ -31,5 +32,5 @@ export declare function registerAllCommands(registry: CommandRegistry): void;
|
|
|
31
32
|
/**
|
|
32
33
|
* Export all command classes
|
|
33
34
|
*/
|
|
34
|
-
export { HelpCommand, LoginCommand, LoginHeadlessCommand, RefreshCommand, DownloadCommand, RandomDownloadCommand, SchedulerCommand, MigrateConfigCommand, NormalizeCommand, WebUICommand, HealthCommand, StatusCommand, LogsCommand, ConfigCommand, BackupCommand, MaintainCommand, MonitorCommand, SetupCommand, DirsCommand, VersionCommand, TagsCommand, TopicCommand, };
|
|
35
|
+
export { HelpCommand, LoginCommand, LoginHeadlessCommand, RefreshCommand, DownloadCommand, RandomDownloadCommand, SchedulerCommand, SchedulerRunOnceCommand, MigrateConfigCommand, NormalizeCommand, WebUICommand, HealthCommand, StatusCommand, LogsCommand, ConfigCommand, BackupCommand, MaintainCommand, MonitorCommand, SetupCommand, DirsCommand, VersionCommand, TagsCommand, TopicCommand, };
|
|
35
36
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,E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ChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI,CAwBnE;AAED;;GAEG;AACH,OAAO,EACL,WAAW,EACX,YAAY,EACZ,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,EACpB,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,aAAa,EACb,WAAW,EACX,aAAa,EACb,aAAa,EACb,eAAe,EACf,cAAc,EACd,YAAY,EACZ,WAAW,EACX,cAAc,EACd,WAAW,EACX,YAAY,GACb,CAAC"}
|
package/dist/commands/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Command exports and registration
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.TopicCommand = exports.TagsCommand = exports.VersionCommand = exports.DirsCommand = exports.SetupCommand = exports.MonitorCommand = exports.MaintainCommand = exports.BackupCommand = exports.ConfigCommand = exports.LogsCommand = exports.StatusCommand = exports.HealthCommand = exports.WebUICommand = exports.NormalizeCommand = exports.MigrateConfigCommand = exports.SchedulerCommand = exports.RandomDownloadCommand = exports.DownloadCommand = exports.RefreshCommand = exports.LoginHeadlessCommand = exports.LoginCommand = exports.HelpCommand = void 0;
|
|
6
|
+
exports.TopicCommand = exports.TagsCommand = exports.VersionCommand = exports.DirsCommand = exports.SetupCommand = exports.MonitorCommand = exports.MaintainCommand = exports.BackupCommand = exports.ConfigCommand = exports.LogsCommand = exports.StatusCommand = exports.HealthCommand = exports.WebUICommand = exports.NormalizeCommand = exports.MigrateConfigCommand = exports.SchedulerRunOnceCommand = exports.SchedulerCommand = exports.RandomDownloadCommand = exports.DownloadCommand = exports.RefreshCommand = exports.LoginHeadlessCommand = exports.LoginCommand = exports.HelpCommand = void 0;
|
|
7
7
|
exports.registerAllCommands = registerAllCommands;
|
|
8
8
|
const HelpCommand_1 = require("./HelpCommand");
|
|
9
9
|
Object.defineProperty(exports, "HelpCommand", { enumerable: true, get: function () { return HelpCommand_1.HelpCommand; } });
|
|
@@ -19,6 +19,8 @@ const RandomDownloadCommand_1 = require("./RandomDownloadCommand");
|
|
|
19
19
|
Object.defineProperty(exports, "RandomDownloadCommand", { enumerable: true, get: function () { return RandomDownloadCommand_1.RandomDownloadCommand; } });
|
|
20
20
|
const SchedulerCommand_1 = require("./SchedulerCommand");
|
|
21
21
|
Object.defineProperty(exports, "SchedulerCommand", { enumerable: true, get: function () { return SchedulerCommand_1.SchedulerCommand; } });
|
|
22
|
+
const SchedulerRunOnceCommand_1 = require("./SchedulerRunOnceCommand");
|
|
23
|
+
Object.defineProperty(exports, "SchedulerRunOnceCommand", { enumerable: true, get: function () { return SchedulerRunOnceCommand_1.SchedulerRunOnceCommand; } });
|
|
22
24
|
const MigrateConfigCommand_1 = require("./MigrateConfigCommand");
|
|
23
25
|
Object.defineProperty(exports, "MigrateConfigCommand", { enumerable: true, get: function () { return MigrateConfigCommand_1.MigrateConfigCommand; } });
|
|
24
26
|
const NormalizeCommand_1 = require("./NormalizeCommand");
|
|
@@ -60,6 +62,7 @@ function registerAllCommands(registry) {
|
|
|
60
62
|
registry.register(new DownloadCommand_1.DownloadCommand());
|
|
61
63
|
registry.register(new RandomDownloadCommand_1.RandomDownloadCommand());
|
|
62
64
|
registry.register(new SchedulerCommand_1.SchedulerCommand());
|
|
65
|
+
registry.register(new SchedulerRunOnceCommand_1.SchedulerRunOnceCommand());
|
|
63
66
|
registry.register(new MigrateConfigCommand_1.MigrateConfigCommand());
|
|
64
67
|
registry.register(new NormalizeCommand_1.NormalizeCommand());
|
|
65
68
|
registry.register(new WebUICommand_1.WebUICommand());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AA8BH,kDAwBC;AAnDD,+CAA4C;AAyD1C,4FAzDO,yBAAW,OAyDP;AAxDb,iDAA8C;AAyD5C,6FAzDO,2BAAY,OAyDP;AAxDd,iEAA8D;AAyD5D,qGAzDO,2CAAoB,OAyDP;AAxDtB,qDAAkD;AAyDhD,+FAzDO,+BAAc,OAyDP;AAxDhB,uDAAoD;AAyDlD,gGAzDO,iCAAe,OAyDP;AAxDjB,mEAAgE;AAyD9D,sGAzDO,6CAAqB,OAyDP;AAxDvB,yDAAsD;AAyDpD,iGAzDO,mCAAgB,OAyDP;AAxDlB,uEAAoE;AAyDlE,wGAzDO,iDAAuB,OAyDP;AAxDzB,iEAA8D;AAyD5D,qGAzDO,2CAAoB,OAyDP;AAxDtB,yDAAsD;AAyDpD,iGAzDO,mCAAgB,OAyDP;AAxDlB,iDAA8C;AAyD5C,6FAzDO,2BAAY,OAyDP;AAxDd,mDAAgD;AAyD9C,8FAzDO,6BAAa,OAyDP;AAxDf,mDAAgD;AAyD9C,8FAzDO,6BAAa,OAyDP;AAxDf,+CAA4C;AAyD1C,4FAzDO,yBAAW,OAyDP;AAxDb,mD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CAAC,CAAC;IACvC,QAAQ,CAAC,QAAQ,CAAC,IAAI,6BAAa,EAAE,CAAC,CAAC;IACvC,QAAQ,CAAC,QAAQ,CAAC,IAAI,yBAAW,EAAE,CAAC,CAAC;IACrC,QAAQ,CAAC,QAAQ,CAAC,IAAI,6BAAa,EAAE,CAAC,CAAC;IACvC,QAAQ,CAAC,QAAQ,CAAC,IAAI,6BAAa,EAAE,CAAC,CAAC;IACvC,QAAQ,CAAC,QAAQ,CAAC,IAAI,iCAAe,EAAE,CAAC,CAAC;IACzC,QAAQ,CAAC,QAAQ,CAAC,IAAI,+BAAc,EAAE,CAAC,CAAC;IACxC,QAAQ,CAAC,QAAQ,CAAC,IAAI,2BAAY,EAAE,CAAC,CAAC;IACtC,QAAQ,CAAC,QAAQ,CAAC,IAAI,yBAAW,EAAE,CAAC,CAAC;IACrC,QAAQ,CAAC,QAAQ,CAAC,IAAI,+BAAc,EAAE,CAAC,CAAC;IACxC,QAAQ,CAAC,QAAQ,CAAC,IAAI,yBAAW,EAAE,CAAC,CAAC;IACrC,QAAQ,CAAC,QAAQ,CAAC,IAAI,2BAAY,EAAE,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared runtime for scheduler commands.
|
|
3
|
+
*
|
|
4
|
+
* Both the long-running `scheduler` daemon and the one-shot `scheduler
|
|
5
|
+
* run-once` (refetch) command build the exact same download machinery, so a
|
|
6
|
+
* refetch behaves identically to a scheduled run: same config resolution,
|
|
7
|
+
* same token maintenance, same target selection, same dedupe and delivery.
|
|
8
|
+
*/
|
|
9
|
+
import { ScheduleConfig, StandaloneConfig } from '../config';
|
|
10
|
+
import { Database } from '../storage/Database';
|
|
11
|
+
import { PixivClient } from '../pixiv/PixivClient';
|
|
12
|
+
import { FileService } from '../download/FileService';
|
|
13
|
+
import { createTokenMaintenanceService } from '../utils/token-maintenance';
|
|
14
|
+
export interface SchedulerRuntime {
|
|
15
|
+
config: StandaloneConfig;
|
|
16
|
+
database: Database;
|
|
17
|
+
pixivClient: PixivClient;
|
|
18
|
+
fileService: FileService;
|
|
19
|
+
tokenMaintenance: ReturnType<typeof createTokenMaintenanceService>;
|
|
20
|
+
/** Run one schedule's enabled targets once (the same job the cron fires). */
|
|
21
|
+
runJob(snapshot: StandaloneConfig, schedule: ScheduleConfig): Promise<void>;
|
|
22
|
+
/** Cancel the in-flight download plan, if any. */
|
|
23
|
+
cancelActive(reason: string): void;
|
|
24
|
+
/** Stop token maintenance, cancel any in-flight download and close the DB. */
|
|
25
|
+
close(): void;
|
|
26
|
+
}
|
|
27
|
+
export declare function createSchedulerRuntime(configPathArg?: string): Promise<SchedulerRuntime>;
|
|
28
|
+
//# sourceMappingURL=scheduler-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler-runtime.d.ts","sourceRoot":"","sources":["../../src/commands/scheduler-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAA6B,cAAc,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AACxF,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAK3E,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,gBAAgB,CAAC;IACzB,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,EAAE,WAAW,CAAC;IACzB,WAAW,EAAE,WAAW,CAAC;IACzB,gBAAgB,EAAE,UAAU,CAAC,OAAO,6BAA6B,CAAC,CAAC;IACnE,6EAA6E;IAC7E,MAAM,CAAC,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5E,kDAAkD;IAClD,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,8EAA8E;IAC9E,KAAK,IAAI,IAAI,CAAC;CACf;AAED,wBAAsB,sBAAsB,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAuF9F"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shared runtime for scheduler commands.
|
|
4
|
+
*
|
|
5
|
+
* Both the long-running `scheduler` daemon and the one-shot `scheduler
|
|
6
|
+
* run-once` (refetch) command build the exact same download machinery, so a
|
|
7
|
+
* refetch behaves identically to a scheduled run: same config resolution,
|
|
8
|
+
* same token maintenance, same target selection, same dedupe and delivery.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.createSchedulerRuntime = createSchedulerRuntime;
|
|
12
|
+
const config_1 = require("../config");
|
|
13
|
+
const Database_1 = require("../storage/Database");
|
|
14
|
+
const AuthClient_1 = require("../pixiv/AuthClient");
|
|
15
|
+
const PixivClient_1 = require("../pixiv/PixivClient");
|
|
16
|
+
const FileService_1 = require("../download/FileService");
|
|
17
|
+
const DownloadManager_1 = require("../download/DownloadManager");
|
|
18
|
+
const token_maintenance_1 = require("../utils/token-maintenance");
|
|
19
|
+
const schedules_1 = require("../scheduler/schedules");
|
|
20
|
+
const placeholders_1 = require("../config/placeholders");
|
|
21
|
+
const logger_1 = require("../logger");
|
|
22
|
+
async function createSchedulerRuntime(configPathArg) {
|
|
23
|
+
// Keep TODAY/YESTERDAY placeholders intact. They are resolved afresh for
|
|
24
|
+
// every plan execution, not frozen at daemon startup.
|
|
25
|
+
const configPath = (0, config_1.getConfigPath)(configPathArg);
|
|
26
|
+
const config = (0, config_1.loadConfig)(configPath, false, false);
|
|
27
|
+
const database = new Database_1.Database(config.storage.databasePath);
|
|
28
|
+
database.migrate();
|
|
29
|
+
const auth = new AuthClient_1.PixivAuth(config.pixiv, config.network, database, configPath);
|
|
30
|
+
const pixivClient = new PixivClient_1.PixivClient(auth, config);
|
|
31
|
+
const fileService = new FileService_1.FileService(config.storage);
|
|
32
|
+
await fileService.initialise();
|
|
33
|
+
// Start token maintenance service for automatic token refresh
|
|
34
|
+
const tokenMaintenance = (0, token_maintenance_1.createTokenMaintenanceService)(auth, config.pixiv, config.network, config);
|
|
35
|
+
if (tokenMaintenance) {
|
|
36
|
+
tokenMaintenance.start();
|
|
37
|
+
}
|
|
38
|
+
let activeDownloadManager = null;
|
|
39
|
+
const runJob = async (snapshot, schedule) => {
|
|
40
|
+
const runtimeConfig = (0, placeholders_1.processConfigPlaceholders)(snapshot);
|
|
41
|
+
const targets = (0, schedules_1.selectScheduleTargets)(runtimeConfig.targets, schedule);
|
|
42
|
+
const scopedConfig = { ...runtimeConfig, targets };
|
|
43
|
+
if (targets.length === 0) {
|
|
44
|
+
logger_1.logger.warn('Scheduled plan has no selected targets; skipping', {
|
|
45
|
+
scheduleId: schedule.id,
|
|
46
|
+
targetIds: schedule.targetIds,
|
|
47
|
+
});
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const downloadManager = new DownloadManager_1.DownloadManager(scopedConfig, pixivClient, database, fileService);
|
|
51
|
+
activeDownloadManager = downloadManager;
|
|
52
|
+
await downloadManager.initialise();
|
|
53
|
+
// Apply initial delay if configured
|
|
54
|
+
if (runtimeConfig.initialDelay && runtimeConfig.initialDelay > 0) {
|
|
55
|
+
logger_1.logger.info(`Waiting ${runtimeConfig.initialDelay}ms before starting download...`, {
|
|
56
|
+
scheduleId: schedule.id,
|
|
57
|
+
});
|
|
58
|
+
await new Promise((resolve) => setTimeout(resolve, runtimeConfig.initialDelay));
|
|
59
|
+
}
|
|
60
|
+
logger_1.logger.info('='.repeat(60));
|
|
61
|
+
logger_1.logger.info('Starting scheduled Pixiv download plan', {
|
|
62
|
+
scheduleId: schedule.id,
|
|
63
|
+
targets: targets.map((target) => target.id ?? target.tag ?? target.filterTag ?? target.type),
|
|
64
|
+
});
|
|
65
|
+
logger_1.logger.info('='.repeat(60));
|
|
66
|
+
const startTime = Date.now();
|
|
67
|
+
try {
|
|
68
|
+
await downloadManager.runAllTargets();
|
|
69
|
+
}
|
|
70
|
+
finally {
|
|
71
|
+
if (activeDownloadManager === downloadManager)
|
|
72
|
+
activeDownloadManager = null;
|
|
73
|
+
}
|
|
74
|
+
const duration = Math.round((Date.now() - startTime) / 1000);
|
|
75
|
+
logger_1.logger.info('='.repeat(60));
|
|
76
|
+
logger_1.logger.info(`Scheduled download plan finished (took ${duration}s)`, {
|
|
77
|
+
scheduleId: schedule.id,
|
|
78
|
+
});
|
|
79
|
+
logger_1.logger.info('='.repeat(60));
|
|
80
|
+
};
|
|
81
|
+
const cancelActive = (reason) => {
|
|
82
|
+
activeDownloadManager?.cancel(reason);
|
|
83
|
+
};
|
|
84
|
+
const close = () => {
|
|
85
|
+
cancelActive('process shutdown');
|
|
86
|
+
if (tokenMaintenance) {
|
|
87
|
+
tokenMaintenance.stop();
|
|
88
|
+
}
|
|
89
|
+
database.close();
|
|
90
|
+
};
|
|
91
|
+
return { config, database, pixivClient, fileService, tokenMaintenance, runJob, cancelActive, close };
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=scheduler-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler-runtime.js","sourceRoot":"","sources":["../../src/commands/scheduler-runtime.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;AA2BH,wDAuFC;AAhHD,sCAAwF;AACxF,kDAA+C;AAC/C,oDAAgD;AAChD,sDAAmD;AACnD,yDAAsD;AACtD,iEAA8D;AAC9D,kEAA2E;AAC3E,sDAA+D;AAC/D,yDAAmE;AACnE,sCAAmC;AAgB5B,KAAK,UAAU,sBAAsB,CAAC,aAAsB;IACjE,yEAAyE;IACzE,sDAAsD;IACtD,MAAM,UAAU,GAAG,IAAA,sBAA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GAAG,IAAI,CAAC;QAC9E,CAAC;QACD,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC;QAE7D,eAAM,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;QAC5B,eAAM,CAAC,IAAI,CAAC,0CAA0C,QAAQ,IAAI,EAAE;YAClE,UAAU,EAAE,QAAQ,CAAC,EAAE;SACxB,CAAC,CAAC;QACH,eAAM,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9B,CAAC,CAAC;IAEF,MAAM,YAAY,GAAG,CAAC,MAAc,EAAQ,EAAE;QAC5C,qBAAqB,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACxC,CAAC,CAAC;IAEF,MAAM,KAAK,GAAG,GAAS,EAAE;QACvB,YAAY,CAAC,kBAAkB,CAAC,CAAC;QACjC,IAAI,gBAAgB,EAAE,CAAC;YACrB,gBAAgB,CAAC,IAAI,EAAE,CAAC;QAC1B,CAAC;QACD,QAAQ,CAAC,KAAK,EAAE,CAAC;IACnB,CAAC,CAAC;IAEF,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;AACvG,CAAC"}
|
package/dist/package.json
CHANGED
package/dist/webui/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pixivflow",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.25",
|
|
4
4
|
"description": "🎨 智能的 Pixiv 自动化下载工具 - 支持批量下载插画和小说、定时任务、Docker部署 | Intelligent Pixiv Automation Downloader with batch download, scheduler, and Docker support",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|