diff options
author | BRAINS YUM <43896676+McFlat@users.noreply.github.com> | 2018-10-24 13:07:51 -0500 |
---|---|---|
committer | Rigel Kent <par@rigelk.eu> | 2018-10-24 20:07:51 +0200 |
commit | fa27f07637dd941577ab78de528cbef044b46248 (patch) | |
tree | 40e456b02f3a970fe51560e0d5617b3984f4cf11 /server/tools | |
parent | 8684f3c1f6d5b94153fc27dd71ce1659797967ec (diff) | |
download | PeerTube-fa27f07637dd941577ab78de528cbef044b46248.tar.gz PeerTube-fa27f07637dd941577ab78de528cbef044b46248.tar.zst PeerTube-fa27f07637dd941577ab78de528cbef044b46248.zip |
allow peertube-import-videos.ts CLI script to run concurrently (#1334)
allows running multiple imports at the same time, whereas previously a concurrent instance of the script deleted another processe's file.
Diffstat (limited to 'server/tools')
-rw-r--r-- | server/tools/peertube-import-videos.ts | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/server/tools/peertube-import-videos.ts b/server/tools/peertube-import-videos.ts index 13090a028..21505b79d 100644 --- a/server/tools/peertube-import-videos.ts +++ b/server/tools/peertube-import-videos.ts | |||
@@ -10,6 +10,7 @@ import { getClient, getVideoCategories, login, searchVideoWithSort, uploadVideo | |||
10 | import { truncate } from 'lodash' | 10 | import { truncate } from 'lodash' |
11 | import * as prompt from 'prompt' | 11 | import * as prompt from 'prompt' |
12 | import { remove } from 'fs-extra' | 12 | import { remove } from 'fs-extra' |
13 | import { sha256 } from '../helpers/core-utils' | ||
13 | import { safeGetYoutubeDL } from '../helpers/youtube-dl' | 14 | import { safeGetYoutubeDL } from '../helpers/youtube-dl' |
14 | import { getSettings, netrc } from './cli' | 15 | import { getSettings, netrc } from './cli' |
15 | 16 | ||
@@ -133,8 +134,7 @@ async function run (user, url: string) { | |||
133 | await processVideo(info, program['language'], processOptions.cwd, url, user) | 134 | await processVideo(info, program['language'], processOptions.cwd, url, user) |
134 | } | 135 | } |
135 | 136 | ||
136 | // https://www.youtube.com/watch?v=2Upx39TBc1s | 137 | console.log('Video/s for user %s imported: %s', program['username'], program['targetUrl']) |
137 | console.log('I\'m finished!') | ||
138 | process.exit(0) | 138 | process.exit(0) |
139 | }) | 139 | }) |
140 | } | 140 | } |
@@ -155,7 +155,7 @@ function processVideo (info: any, languageCode: string, cwd: string, url: string | |||
155 | return res() | 155 | return res() |
156 | } | 156 | } |
157 | 157 | ||
158 | const path = join(cwd, new Date().getTime() + '.mp4') | 158 | const path = join(cwd, sha256(videoInfo.url) + '.mp4') |
159 | 159 | ||
160 | console.log('Downloading video "%s"...', videoInfo.title) | 160 | console.log('Downloading video "%s"...', videoInfo.title) |
161 | 161 | ||
@@ -192,7 +192,7 @@ async function uploadVideoOnPeerTube (videoInfo: any, videoPath: string, cwd: st | |||
192 | 192 | ||
193 | let thumbnailfile | 193 | let thumbnailfile |
194 | if (videoInfo.thumbnail) { | 194 | if (videoInfo.thumbnail) { |
195 | thumbnailfile = join(cwd, 'thumbnail.jpg') | 195 | thumbnailfile = join(cwd, sha256(videoInfo.thumbnail) + '.jpg') |
196 | 196 | ||
197 | await doRequestAndSaveToFile({ | 197 | await doRequestAndSaveToFile({ |
198 | method: 'GET', | 198 | method: 'GET', |