More robust import script when using since/until

pull/3467/head
Chocobozzz 2020-12-14 09:40:31 +01:00
parent f98c395295
commit d8794cf855
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 11 additions and 12 deletions

View File

@ -124,19 +124,18 @@ function processVideo (parameters: {
const videoInfo = await fetchObject(youtubeInfo)
log.debug('Fetched object.', videoInfo)
if (program['since']) {
if (buildOriginallyPublishedAt(videoInfo).getTime() < program['since'].getTime()) {
log.info('Video "%s" has been published before "%s", don\'t upload it.\n',
videoInfo.title, formatDate(program['since']))
return res()
}
const originallyPublishedAt = buildOriginallyPublishedAt(videoInfo)
if (program['since'] && originallyPublishedAt && originallyPublishedAt.getTime() < program['since'].getTime()) {
log.info('Video "%s" has been published before "%s", don\'t upload it.\n',
videoInfo.title, formatDate(program['since']))
return res()
}
if (program['until']) {
if (buildOriginallyPublishedAt(videoInfo).getTime() > program['until'].getTime()) {
log.info('Video "%s" has been published after "%s", don\'t upload it.\n',
videoInfo.title, formatDate(program['until']))
return res()
}
if (program['until'] && originallyPublishedAt && originallyPublishedAt.getTime() > program['until'].getTime()) {
log.info('Video "%s" has been published after "%s", don\'t upload it.\n',
videoInfo.title, formatDate(program['until']))
return res()
}
const result = await searchVideoWithSort(url, videoInfo.title, '-match')