aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-12-14 09:40:31 +0100
committerChocobozzz <me@florianbigard.com>2020-12-14 09:55:30 +0100
commitd8794cf85554a17e1f110f49a0c965be825a9b4a (patch)
tree6d12f57cc806fd6f3c35dc7ade9589a29607893f /server
parentf98c39529505cdd409babdb7674dcc779f0ec5af (diff)
downloadPeerTube-d8794cf85554a17e1f110f49a0c965be825a9b4a.tar.gz
PeerTube-d8794cf85554a17e1f110f49a0c965be825a9b4a.tar.zst
PeerTube-d8794cf85554a17e1f110f49a0c965be825a9b4a.zip
More robust import script when using since/until
Diffstat (limited to 'server')
-rw-r--r--server/tools/peertube-import-videos.ts23
1 files changed, 11 insertions, 12 deletions
diff --git a/server/tools/peertube-import-videos.ts b/server/tools/peertube-import-videos.ts
index d04ddfe06..1b2c63af2 100644
--- a/server/tools/peertube-import-videos.ts
+++ b/server/tools/peertube-import-videos.ts
@@ -124,19 +124,18 @@ function processVideo (parameters: {
124 const videoInfo = await fetchObject(youtubeInfo) 124 const videoInfo = await fetchObject(youtubeInfo)
125 log.debug('Fetched object.', videoInfo) 125 log.debug('Fetched object.', videoInfo)
126 126
127 if (program['since']) { 127 const originallyPublishedAt = buildOriginallyPublishedAt(videoInfo)
128 if (buildOriginallyPublishedAt(videoInfo).getTime() < program['since'].getTime()) { 128
129 log.info('Video "%s" has been published before "%s", don\'t upload it.\n', 129 if (program['since'] && originallyPublishedAt && originallyPublishedAt.getTime() < program['since'].getTime()) {
130 videoInfo.title, formatDate(program['since'])) 130 log.info('Video "%s" has been published before "%s", don\'t upload it.\n',
131 return res() 131 videoInfo.title, formatDate(program['since']))
132 } 132 return res()
133 } 133 }
134 if (program['until']) { 134
135 if (buildOriginallyPublishedAt(videoInfo).getTime() > program['until'].getTime()) { 135 if (program['until'] && originallyPublishedAt && originallyPublishedAt.getTime() > program['until'].getTime()) {
136 log.info('Video "%s" has been published after "%s", don\'t upload it.\n', 136 log.info('Video "%s" has been published after "%s", don\'t upload it.\n',
137 videoInfo.title, formatDate(program['until'])) 137 videoInfo.title, formatDate(program['until']))
138 return res() 138 return res()
139 }
140 } 139 }
141 140
142 const result = await searchVideoWithSort(url, videoInfo.title, '-match') 141 const result = await searchVideoWithSort(url, videoInfo.title, '-match')