From cbdd81da96ece934acac0735362f534fbc307bfd Mon Sep 17 00:00:00 2001
From: Chocobozzz <me@florianbigard.com>
Date: Fri, 16 Sep 2022 09:52:50 +0200
Subject: Fix import script

---
 server/tools/peertube-import-videos.ts | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

(limited to 'server/tools')

diff --git a/server/tools/peertube-import-videos.ts b/server/tools/peertube-import-videos.ts
index 76338ea3c..938eed0ef 100644
--- a/server/tools/peertube-import-videos.ts
+++ b/server/tools/peertube-import-videos.ts
@@ -131,12 +131,20 @@ async function processVideo (parameters: {
   const videoInfo = await fetchObject(youtubeInfo)
   log.debug('Fetched object.', videoInfo)
 
-  if (options.since && videoInfo.originallyPublishedAt && videoInfo.originallyPublishedAt.getTime() < options.since.getTime()) {
+  if (
+    options.since &&
+    videoInfo.originallyPublishedAtWithoutTime &&
+    videoInfo.originallyPublishedAtWithoutTime.getTime() < options.since.getTime()
+  ) {
     log.info('Video "%s" has been published before "%s", don\'t upload it.\n', videoInfo.name, formatDate(options.since))
     return true
   }
 
-  if (options.until && videoInfo.originallyPublishedAt && videoInfo.originallyPublishedAt.getTime() > options.until.getTime()) {
+  if (
+    options.until &&
+    videoInfo.originallyPublishedAtWithoutTime &&
+    videoInfo.originallyPublishedAtWithoutTime.getTime() > options.until.getTime()
+  ) {
     log.info('Video "%s" has been published after "%s", don\'t upload it.\n', videoInfo.name, formatDate(options.until))
     return true
   }
@@ -212,8 +220,8 @@ async function uploadVideoOnPeerTube (parameters: {
   const attributes = {
     ...baseAttributes,
 
-    originallyPublishedAt: videoInfo.originallyPublishedAt
-      ? videoInfo.originallyPublishedAt.toISOString()
+    originallyPublishedAtWithoutTime: videoInfo.originallyPublishedAtWithoutTime
+      ? videoInfo.originallyPublishedAtWithoutTime.toISOString()
       : null,
 
     thumbnailfile,
-- 
cgit v1.2.3