aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tools
diff options
context:
space:
mode:
Diffstat (limited to 'server/tools')
-rw-r--r--server/tools/peertube-import-videos.ts13
1 files changed, 8 insertions, 5 deletions
diff --git a/server/tools/peertube-import-videos.ts b/server/tools/peertube-import-videos.ts
index 54ac910e6..a758beef9 100644
--- a/server/tools/peertube-import-videos.ts
+++ b/server/tools/peertube-import-videos.ts
@@ -95,14 +95,15 @@ async function run (url: string, username: string, password: string) {
95 95
96 log.info('Will download and upload %d videos.\n', infoArray.length) 96 log.info('Will download and upload %d videos.\n', infoArray.length)
97 97
98 let skipInterval = true
98 for (const [ index, info ] of infoArray.entries()) { 99 for (const [ index, info ] of infoArray.entries()) {
99 try { 100 try {
100 if (index > 0 && options.waitInterval) { 101 if (index > 0 && options.waitInterval && !skipInterval) {
101 log.info("Wait for %d seconds before continuing.", options.waitInterval / 1000) 102 log.info("Wait for %d seconds before continuing.", options.waitInterval / 1000)
102 await wait(options.waitInterval) 103 await wait(options.waitInterval)
103 } 104 }
104 105
105 await processVideo({ 106 skipInterval = await processVideo({
106 cwd: options.tmpdir, 107 cwd: options.tmpdir,
107 url, 108 url,
108 username, 109 username,
@@ -134,12 +135,12 @@ async function processVideo (parameters: {
134 135
135 if (options.since && videoInfo.originallyPublishedAt && videoInfo.originallyPublishedAt.getTime() < options.since.getTime()) { 136 if (options.since && videoInfo.originallyPublishedAt && videoInfo.originallyPublishedAt.getTime() < options.since.getTime()) {
136 log.info('Video "%s" has been published before "%s", don\'t upload it.\n', videoInfo.name, formatDate(options.since)) 137 log.info('Video "%s" has been published before "%s", don\'t upload it.\n', videoInfo.name, formatDate(options.since))
137 return 138 return true
138 } 139 }
139 140
140 if (options.until && videoInfo.originallyPublishedAt && videoInfo.originallyPublishedAt.getTime() > options.until.getTime()) { 141 if (options.until && videoInfo.originallyPublishedAt && videoInfo.originallyPublishedAt.getTime() > options.until.getTime()) {
141 log.info('Video "%s" has been published after "%s", don\'t upload it.\n', videoInfo.name, formatDate(options.until)) 142 log.info('Video "%s" has been published after "%s", don\'t upload it.\n', videoInfo.name, formatDate(options.until))
142 return 143 return true
143 } 144 }
144 145
145 const server = buildServer(url) 146 const server = buildServer(url)
@@ -155,7 +156,7 @@ async function processVideo (parameters: {
155 156
156 if (data.find(v => v.name === videoInfo.name)) { 157 if (data.find(v => v.name === videoInfo.name)) {
157 log.info('Video "%s" already exists, don\'t reupload it.\n', videoInfo.name) 158 log.info('Video "%s" already exists, don\'t reupload it.\n', videoInfo.name)
158 return 159 return true
159 } 160 }
160 161
161 const path = join(cwd, sha256(videoInfo.url) + '.mp4') 162 const path = join(cwd, sha256(videoInfo.url) + '.mp4')
@@ -184,6 +185,8 @@ async function processVideo (parameters: {
184 } catch (err) { 185 } catch (err) {
185 log.error(err.message) 186 log.error(err.message)
186 } 187 }
188
189 return false
187} 190}
188 191
189async function uploadVideoOnPeerTube (parameters: { 192async function uploadVideoOnPeerTube (parameters: {