aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tools/import-videos.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tools/import-videos.ts')
-rw-r--r--server/tools/import-videos.ts23
1 files changed, 14 insertions, 9 deletions
diff --git a/server/tools/import-videos.ts b/server/tools/import-videos.ts
index 809d69e4c..2f38ea7c7 100644
--- a/server/tools/import-videos.ts
+++ b/server/tools/import-videos.ts
@@ -76,7 +76,6 @@ async function run () {
76 await processVideo(info, program['language']) 76 await processVideo(info, program['language'])
77 } 77 }
78 78
79 // https://www.youtube.com/watch?v=2Upx39TBc1s
80 console.log('I\'m finished!') 79 console.log('I\'m finished!')
81 process.exit(0) 80 process.exit(0)
82 }) 81 })
@@ -103,15 +102,21 @@ function processVideo (info: any, languageCode: number) {
103 console.log('Downloading video "%s"...', videoInfo.title) 102 console.log('Downloading video "%s"...', videoInfo.title)
104 103
105 const options = [ '-f', 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best', '-o', path ] 104 const options = [ '-f', 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best', '-o', path ]
106 youtubeDL.exec(videoInfo.url, options, processOptions, async (err, output) => { 105 try {
107 if (err) return console.error(err) 106 youtubeDL.exec(videoInfo.url, options, processOptions, async (err, output) => {
108 107 if (err) {
109 console.log(output.join('\n')) 108 console.error(err)
110 109 return res()
111 await uploadVideoOnPeerTube(normalizeObject(videoInfo), path, languageCode) 110 }
112 111
112 console.log(output.join('\n'))
113 await uploadVideoOnPeerTube(normalizeObject(videoInfo), path, languageCode)
114 return res()
115 })
116 } catch (err) {
117 console.log(err.message)
113 return res() 118 return res()
114 }) 119 }
115 }) 120 })
116} 121}
117 122