From fa27f07637dd941577ab78de528cbef044b46248 Mon Sep 17 00:00:00 2001 From: BRAINS YUM <43896676+McFlat@users.noreply.github.com> Date: Wed, 24 Oct 2018 13:07:51 -0500 Subject: [PATCH] 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. --- server/tools/peertube-import-videos.ts | 8 ++++---- 1 file 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 import { truncate } from 'lodash' import * as prompt from 'prompt' import { remove } from 'fs-extra' +import { sha256 } from '../helpers/core-utils' import { safeGetYoutubeDL } from '../helpers/youtube-dl' import { getSettings, netrc } from './cli' @@ -133,8 +134,7 @@ async function run (user, url: string) { await processVideo(info, program['language'], processOptions.cwd, url, user) } - // https://www.youtube.com/watch?v=2Upx39TBc1s - console.log('I\'m finished!') + console.log('Video/s for user %s imported: %s', program['username'], program['targetUrl']) process.exit(0) }) } @@ -155,7 +155,7 @@ function processVideo (info: any, languageCode: string, cwd: string, url: string return res() } - const path = join(cwd, new Date().getTime() + '.mp4') + const path = join(cwd, sha256(videoInfo.url) + '.mp4') console.log('Downloading video "%s"...', videoInfo.title) @@ -192,7 +192,7 @@ async function uploadVideoOnPeerTube (videoInfo: any, videoPath: string, cwd: st let thumbnailfile if (videoInfo.thumbnail) { - thumbnailfile = join(cwd, 'thumbnail.jpg') + thumbnailfile = join(cwd, sha256(videoInfo.thumbnail) + '.jpg') await doRequestAndSaveToFile({ method: 'GET', -- 2.25.1