X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftools%2Fpeertube-import-videos.ts;h=938eed0ef5255ff96405efaa400b2d1426c4edd0;hb=f67ac646a2c081e02b28a7ab1dc856db6ee20e2f;hp=661a4cf35c1d1f6f78d9cd2acbbb34de8a73d859;hpb=3318147300b4f998adf728eb0a5a14a4c1829c51;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tools/peertube-import-videos.ts b/server/tools/peertube-import-videos.ts index 661a4cf35..938eed0ef 100644 --- a/server/tools/peertube-import-videos.ts +++ b/server/tools/peertube-import-videos.ts @@ -37,7 +37,7 @@ command .option('--last ', 'Process last n elements of returned playlist') .option('--wait-interval ', 'Duration between two video imports (in seconds)', convertIntoMs) .option('-T, --tmpdir ', 'Working directory', __dirname) - .usage("[global options] [ -- youtube-dl options]") + .usage('[global options] [ -- youtube-dl options]') .parse(process.argv) const options = command.opts() @@ -97,7 +97,7 @@ async function run (url: string, username: string, password: string) { for (const [ index, info ] of infoArray.entries()) { try { if (index > 0 && options.waitInterval && !skipInterval) { - log.info("Wait for %d seconds before continuing.", options.waitInterval / 1000) + log.info('Wait for %d seconds before continuing.', options.waitInterval / 1000) await wait(options.waitInterval) } @@ -131,12 +131,20 @@ async function processVideo (parameters: { const videoInfo = await fetchObject(youtubeInfo) log.debug('Fetched object.', videoInfo) - if (options.since && videoInfo.originallyPublishedAt && videoInfo.originallyPublishedAt.getTime() < options.since.getTime()) { + if ( + options.since && + videoInfo.originallyPublishedAtWithoutTime && + videoInfo.originallyPublishedAtWithoutTime.getTime() < options.since.getTime() + ) { log.info('Video "%s" has been published before "%s", don\'t upload it.\n', videoInfo.name, formatDate(options.since)) return true } - if (options.until && videoInfo.originallyPublishedAt && videoInfo.originallyPublishedAt.getTime() > options.until.getTime()) { + if ( + options.until && + videoInfo.originallyPublishedAtWithoutTime && + videoInfo.originallyPublishedAtWithoutTime.getTime() > options.until.getTime() + ) { log.info('Video "%s" has been published after "%s", don\'t upload it.\n', videoInfo.name, formatDate(options.until)) return true } @@ -165,7 +173,7 @@ async function processVideo (parameters: { const youtubeDLBinary = await YoutubeDLCLI.safeGet() const output = await youtubeDLBinary.download({ url: videoInfo.url, - format: YoutubeDLCLI.getYoutubeDLVideoFormat([]), + format: YoutubeDLCLI.getYoutubeDLVideoFormat([], false), output: path, additionalYoutubeDLArgs: command.args, processOptions @@ -212,8 +220,8 @@ async function uploadVideoOnPeerTube (parameters: { const attributes = { ...baseAttributes, - originallyPublishedAt: videoInfo.originallyPublishedAt - ? videoInfo.originallyPublishedAt.toISOString() + originallyPublishedAtWithoutTime: videoInfo.originallyPublishedAtWithoutTime + ? videoInfo.originallyPublishedAtWithoutTime.toISOString() : null, thumbnailfile, @@ -251,7 +259,7 @@ async function fetchObject (info: any) { const youtubeDLCLI = await YoutubeDLCLI.safeGet() const result = await youtubeDLCLI.getInfo({ url, - format: YoutubeDLCLI.getYoutubeDLVideoFormat([]), + format: YoutubeDLCLI.getYoutubeDLVideoFormat([], false), processOptions }) @@ -336,7 +344,7 @@ function exitError (message: string, ...meta: any[]) { function getYoutubeDLInfo (youtubeDLCLI: YoutubeDLCLI, url: string, args: string[]) { return youtubeDLCLI.getInfo({ url, - format: YoutubeDLCLI.getYoutubeDLVideoFormat([]), + format: YoutubeDLCLI.getYoutubeDLVideoFormat([], false), additionalYoutubeDLArgs: [ '-j', '--flat-playlist', '--playlist-reverse', ...args ], processOptions })