run-weixin-video-import-single.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { initDatabase, PlatformAccount } from '../models/index.js';
  2. import { logger } from '../utils/logger.js';
  3. import { WeixinVideoDataCenterImportService } from '../services/WeixinVideoDataCenterImportService.js';
  4. async function main() {
  5. try {
  6. await initDatabase();
  7. const accountName = '凝光AI';
  8. const accountRepository = (await import('../models/index.js')).AppDataSource.getRepository(
  9. PlatformAccount
  10. );
  11. const account = await accountRepository.findOne({
  12. where: {
  13. platform: 'weixin_video' as any,
  14. accountName,
  15. },
  16. });
  17. if (!account) {
  18. logger.error(`[WX Import] Weixin video account not found for name=${accountName}`);
  19. process.exit(1);
  20. return;
  21. }
  22. logger.info(
  23. `[WX Import] Single-account run start. accountId=${account.id} name=${account.accountName}`
  24. );
  25. const svc = new WeixinVideoDataCenterImportService();
  26. await svc.importAccountLast30Days(account);
  27. logger.info(
  28. `[WX Import] Single-account run done. accountId=${account.id} name=${account.accountName}`
  29. );
  30. process.exit(0);
  31. } catch (e) {
  32. logger.error('[WX Import] Single-account run failed:', e);
  33. process.exit(1);
  34. }
  35. }
  36. void main();