From 3204f4d17dec79413a94eae8a71b72e0c7ec7ba5 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Sep 2022 09:37:07 +0200 Subject: Fix sync import of latest videos --- server/lib/job-queue/handlers/video-channel-import.ts | 4 +++- server/lib/sync-channel.ts | 5 ++++- server/lib/video-import.ts | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) (limited to 'server/lib') diff --git a/server/lib/job-queue/handlers/video-channel-import.ts b/server/lib/job-queue/handlers/video-channel-import.ts index 9aaad659e..600292844 100644 --- a/server/lib/job-queue/handlers/video-channel-import.ts +++ b/server/lib/job-queue/handlers/video-channel-import.ts @@ -5,7 +5,7 @@ import { synchronizeChannel } from '@server/lib/sync-channel' import { VideoChannelModel } from '@server/models/video/video-channel' import { VideoChannelSyncModel } from '@server/models/video/video-channel-sync' import { MChannelSync } from '@server/types/models' -import { VideoChannelImportPayload } from '@shared/models' +import { VideoChannelImportPayload, VideoChannelSyncState } from '@shared/models' export async function processVideoChannelImport (job: Job) { const payload = job.data as VideoChannelImportPayload @@ -42,5 +42,7 @@ export async function processVideoChannelImport (job: Job) { }) } catch (err) { logger.error(`Failed to import channel ${videoChannel.name}`, { err }) + channelSync.state = VideoChannelSyncState.FAILED + await channelSync.save() } } diff --git a/server/lib/sync-channel.ts b/server/lib/sync-channel.ts index 3a81daac0..6cd1fc26d 100644 --- a/server/lib/sync-channel.ts +++ b/server/lib/sync-channel.ts @@ -93,7 +93,10 @@ async function skipImport (channel: MChannel, targetUrl: string, onlyAfter?: Dat const videoInfo = await youtubeDL.getInfoForDownload() - if (videoInfo.originallyPublishedAt.getTime() < onlyAfter.getTime()) { + const onlyAfterWithoutTime = new Date(onlyAfter) + onlyAfterWithoutTime.setHours(0, 0, 0) + + if (videoInfo.originallyPublishedAtWithoutTime.getTime() >= onlyAfterWithoutTime.getTime()) { return true } } diff --git a/server/lib/video-import.ts b/server/lib/video-import.ts index de95116aa..d9da09040 100644 --- a/server/lib/video-import.ts +++ b/server/lib/video-import.ts @@ -125,7 +125,7 @@ async function buildVideoFromImport ({ channelId, importData, importDataOverride channelId, originallyPublishedAt: importDataOverride?.originallyPublishedAt ? new Date(importDataOverride?.originallyPublishedAt) - : importData.originallyPublishedAt + : importData.originallyPublishedAtWithoutTime } videoData = await Hooks.wrapObject( -- cgit v1.2.3