Unverified Commit e291096f authored by mj-saunders's avatar mj-saunders Committed by GitHub
Browse files

Apply import interval only when reasonable (#4552)

* Apply import interval only when reasonable

When importing videos from another service, an interval can be applied
between each download.
It only really makes sense to apply this interval when the last
attempted download actually happened, and not when it was skipped.

* Fix boolean notation
parent 1622e095
......@@ -95,14 +95,15 @@ async function run (url: string, username: string, password: string) {
log.info('Will download and upload %d videos.\n', infoArray.length)
let skipInterval = true
for (const [ index, info ] of infoArray.entries()) {
try {
if (index > 0 && options.waitInterval) {
if (index > 0 && options.waitInterval && !skipInterval) {
log.info("Wait for %d seconds before continuing.", options.waitInterval / 1000)
await wait(options.waitInterval)
}
await processVideo({
skipInterval = await processVideo({
cwd: options.tmpdir,
url,
username,
......@@ -134,12 +135,12 @@ async function processVideo (parameters: {
if (options.since && videoInfo.originallyPublishedAt && videoInfo.originallyPublishedAt.getTime() < options.since.getTime()) {
log.info('Video "%s" has been published before "%s", don\'t upload it.\n', videoInfo.name, formatDate(options.since))
return
return true
}
if (options.until && videoInfo.originallyPublishedAt && videoInfo.originallyPublishedAt.getTime() > options.until.getTime()) {
log.info('Video "%s" has been published after "%s", don\'t upload it.\n', videoInfo.name, formatDate(options.until))
return
return true
}
const server = buildServer(url)
......@@ -155,7 +156,7 @@ async function processVideo (parameters: {
if (data.find(v => v.name === videoInfo.name)) {
log.info('Video "%s" already exists, don\'t reupload it.\n', videoInfo.name)
return
return true
}
const path = join(cwd, sha256(videoInfo.url) + '.mp4')
......@@ -184,6 +185,8 @@ async function processVideo (parameters: {
} catch (err) {
log.error(err.message)
}
return false
}
async function uploadVideoOnPeerTube (parameters: {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment