diff options
author | memorybox <memoryboxes@gmail.com> | 2018-04-03 02:28:25 +0800 |
---|---|---|
committer | Rigel Kent <par@rigelk.eu> | 2018-04-02 20:28:25 +0200 |
commit | f97d299230636b0030ccd6314bf63c304378bed6 (patch) | |
tree | abbf25a0874ec0db16787d66050ae21df08cea13 | |
parent | f209b32afaffbb8b93c265525ebde182ab66c37a (diff) | |
download | PeerTube-f97d299230636b0030ccd6314bf63c304378bed6.tar.gz PeerTube-f97d299230636b0030ccd6314bf63c304378bed6.tar.zst PeerTube-f97d299230636b0030ccd6314bf63c304378bed6.zip |
fix #456 catching errors in import-videos (#457)
-rw-r--r-- | server/tools/import-videos.ts | 23 |
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 | ||